|
|
@@ -1,18 +1,27 @@
|
|
|
package com.usai.apex.mainframe;
|
|
|
|
|
|
|
|
|
+import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.ListFragment;
|
|
|
+import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.BaseAdapter;
|
|
|
+import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.usai.apex.R;
|
|
|
+import com.usai.apex.Result.PullRefreshListView;
|
|
|
import com.usai.util.commonUtil;
|
|
|
|
|
|
import org.apache.http.util.EncodingUtils;
|
|
|
@@ -122,6 +131,10 @@ public class TrackingListFragment extends ListFragment {
|
|
|
|
|
|
return datalist;
|
|
|
}
|
|
|
+
|
|
|
+ public void clear() {
|
|
|
+ datalist.clear();
|
|
|
+ }
|
|
|
}
|
|
|
private class TrackingAdapter extends BaseAdapter
|
|
|
{
|
|
|
@@ -250,6 +263,9 @@ public class TrackingListFragment extends ListFragment {
|
|
|
{
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
|
+ progressDialog = new ProgressDialog(mContext);
|
|
|
+ progressDialog.setCancelable(false);
|
|
|
+
|
|
|
setupAdapter();
|
|
|
customize_style();
|
|
|
|
|
|
@@ -340,4 +356,129 @@ public class TrackingListFragment extends ListFragment {
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ ProgressDialog progressDialog;
|
|
|
+ boolean isLoading = false;//表示是否正处于加载状态
|
|
|
+ Context mContext;
|
|
|
+ SwipeRefreshLayout mSwipeRefresh;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAttach(Context context) {
|
|
|
+ super.onAttach(context);
|
|
|
+ mContext = context;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void showProgressDialog(String title, String msg) {
|
|
|
+ if (!getUserVisibleHint()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ progressDialog.setTitle(title);
|
|
|
+ progressDialog.setMessage(msg);
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void showAlert(String msg) {
|
|
|
+
|
|
|
+ if (!getUserVisibleHint()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (msg == null || msg.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ new AlertDialog.Builder(mContext)
|
|
|
+ .setMessage(msg)
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+ static final int INTERNAL_EMPTY_ID = 0x00ff0001;
|
|
|
+ static final int INTERNAL_PROGRESS_CONTAINER_ID = 0x00ff0002;
|
|
|
+ static final int INTERNAL_LIST_CONTAINER_ID = 0x00ff0003;
|
|
|
+
|
|
|
+ protected PullRefreshListView mPullRefreshListView;
|
|
|
+ protected View refresh_footer;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
+ Bundle savedInstanceState) {
|
|
|
+ final Context context = getContext();
|
|
|
+
|
|
|
+ FrameLayout root = new FrameLayout(context);
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ LinearLayout pframe = new LinearLayout(context);
|
|
|
+ pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
|
|
|
+ pframe.setOrientation(LinearLayout.VERTICAL);
|
|
|
+ pframe.setVisibility(View.GONE);
|
|
|
+ pframe.setGravity(Gravity.CENTER);
|
|
|
+
|
|
|
+ ProgressBar progress = new ProgressBar(context, null,
|
|
|
+ android.R.attr.progressBarStyleLarge);
|
|
|
+ pframe.addView(progress, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
|
+
|
|
|
+ root.addView(pframe, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ FrameLayout lframe = new FrameLayout(context);
|
|
|
+ lframe.setId(INTERNAL_LIST_CONTAINER_ID);
|
|
|
+
|
|
|
+ TextView tv = new TextView(context);
|
|
|
+ tv.setId(INTERNAL_EMPTY_ID);
|
|
|
+ tv.setGravity(Gravity.CENTER);
|
|
|
+ lframe.addView(tv, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+
|
|
|
+ // Swipe
|
|
|
+ SwipeRefreshLayout swipeRefreshLayout = new SwipeRefreshLayout(context);
|
|
|
+ mSwipeRefresh = swipeRefreshLayout;
|
|
|
+ mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh() {
|
|
|
+ requestData();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ PullRefreshListView lv = new PullRefreshListView(context);
|
|
|
+ mPullRefreshListView = lv;
|
|
|
+ lv.setId(android.R.id.list);
|
|
|
+ lv.setDrawSelectorOnTop(false);
|
|
|
+
|
|
|
+ swipeRefreshLayout.addView(lv, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+ lframe.addView(swipeRefreshLayout, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+ root.addView(lframe, new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ root.setLayoutParams(new FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
+
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
|
+ super.setUserVisibleHint(isVisibleToUser);
|
|
|
+
|
|
|
+ if (isVisibleToUser) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void requestData() {
|
|
|
+
|
|
|
+ }
|
|
|
}
|