瀏覽代碼

2.修改Android Apex Mobile 一些空指针错误,以及恢复后Home显示不正确。

Pen Li 7 年之前
父節點
當前提交
ee747e9e76

+ 5 - 3
ApexDrivers/apexmobile/src/main/java/com/usai/apex/mainframe/HistoryFragment.java

@@ -63,15 +63,17 @@ public class HistoryFragment extends TrackingListFragment {
                 return;
             }
 
-            mPullRefreshListView.completeRefresh();
+            if (mPullRefreshListView != null) {
+                mPullRefreshListView.completeRefresh();
+            }
             showProgress(false);
-            if (mSwipeRefresh.isRefreshing()) {
+            if (mSwipeRefresh != null && mSwipeRefresh.isRefreshing()) {
                 mSwipeRefresh.setRefreshing(false);
             }
 
             dismissProgressDialog();
 
-            if (jsobj != null) {
+            if (jsobj != null && searchresult != null && adapter != null) {
 
                 try {
                     int result = jsobj.getInt("result");

+ 17 - 11
ApexDrivers/apexmobile/src/main/java/com/usai/apex/mainframe/HomeFragment.java

@@ -40,11 +40,15 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
 
         if(ApexTrackingApplication.get_instance().recentactive)
         {
-            recentFragment.checkDirty();
+            if (recentFragment != null) {
+                recentFragment.checkDirty();
+            }
         }
         else
         {
-            kpiFragment.checkDirty();
+            if (kpiFragment != null) {
+                kpiFragment.checkDirty();
+            }
         }
     }
     private int mode = 0;
@@ -56,8 +60,6 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
         View v= inflater.inflate(R.layout.fragment_home, container, false);
 
 
-
-
         if(kpiFragment==null) {
             kpiFragment = new KPIFragment();
 
@@ -70,7 +72,6 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
 //                    .add(R.id.container, recentFragment).commit();
         }
 
-        showFragment(mode);
 
 //        if(mode==0)
 //            ft.replace(R.id.container,kpiFragment);
@@ -134,6 +135,16 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
                 showFragment(mode);
             }
         });
+
+
+
+        if(savedInstanceState!=null) {
+            mode = savedInstanceState.getInt("mode");
+            mSegmentView.setSelect(mode);
+        }
+        showFragment(mode);
+
+
         return v;
     }
 
@@ -147,7 +158,7 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
             ApexTrackingApplication.getInstance().recentactive = false;
         FragmentManager fm=getChildFragmentManager();
         FragmentTransaction ft= fm .beginTransaction();
-        if(activeFragment!=null)
+        if(activeFragment!=null && activeFragment.isAdded())
             ft.hide(activeFragment);
         Fragment fragment = null;
         String tag = "";
@@ -211,11 +222,6 @@ public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScroll
     @Override
     public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
         super.onViewStateRestored(savedInstanceState);
-
-            if(savedInstanceState!=null) {
-                mode = savedInstanceState.getInt("mode");
-                mSegmentView.setSelect(mode);
-            }
     }
 
     @Override

+ 10 - 4
ApexDrivers/apexmobile/src/main/java/com/usai/apex/mainframe/TrackingListFragment.java

@@ -558,6 +558,10 @@ TrackingListSearchResult searchresult	= new TrackingListSearchResult();
 
     public void showAlert(String msg) {
 
+        if (mContext == null) {
+            return;
+        }
+
         if (!getUserVisibleHint()) {
             return;
         }
@@ -590,10 +594,12 @@ TrackingListSearchResult searchresult	= new TrackingListSearchResult();
         }
     }
     public void showProgress(boolean show) {
-        if (show) {
-            mProgressLayout.setVisibility(View.VISIBLE);
-        } else {
-            mProgressLayout.setVisibility(View.GONE);
+        if (mProgressLayout != null) {
+            if (show) {
+                mProgressLayout.setVisibility(View.VISIBLE);
+            } else {
+                mProgressLayout.setVisibility(View.GONE);
+            }
         }
     }