Pārlūkot izejas kodu

福利中心空指针判断

zengjiebin 7 gadi atpakaļ
vecāks
revīzija
200d94264c

+ 12 - 19
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtWelfareCenter.java

@@ -183,25 +183,21 @@ public class FgtWelfareCenter extends BaseFragment{
                     .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                         @Override
                         public void onNext(BaseMessage baseMessage) {
-                            if(wcHotWelfareList == null){
-                                return;
-                            }
                             refreshHotWelfare = false;
                             ArrayList<TaskReleaseEty> newList = baseMessage.getDataList(TaskReleaseEty.class);
                             hotWelfareList.clear();
                             ListUtil.addAll(hotWelfareList, newList);
-                            wcHotWelfareList.getAdapter().notifyDataSetChanged();
+                            if(wcHotWelfareList != null)
+                                wcHotWelfareList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
 
                         @Override
                         public void onError(BaseMessage baseMessage) {
-                            if(wcHotWelfareList == null){
-                                return;
-                            }
                             refreshHotWelfare = false;
                             hotWelfareList.clear();
-                            wcHotWelfareList.getAdapter().notifyDataSetChanged();
+                            if(wcHotWelfareList != null)
+                                wcHotWelfareList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
                     });
@@ -218,7 +214,8 @@ public class FgtWelfareCenter extends BaseFragment{
                             ArrayList<TaskReleaseEty> newList = baseMessage.getDataList(TaskReleaseEty.class);
                             downloadWelfareList.clear();
                             ListUtil.addAll(downloadWelfareList, newList);
-                            wcDownloadWelfareList.getAdapter().notifyDataSetChanged();
+                            if(wcDownloadWelfareList != null)
+                                wcDownloadWelfareList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
 
@@ -226,7 +223,8 @@ public class FgtWelfareCenter extends BaseFragment{
                         public void onError(BaseMessage baseMessage) {
                             refreshDownloadWelfare = false;
                             downloadWelfareList.clear();
-                            wcDownloadWelfareList.getAdapter().notifyDataSetChanged();
+                            if(wcDownloadWelfareList != null)
+                                wcDownloadWelfareList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
                     });
@@ -243,7 +241,8 @@ public class FgtWelfareCenter extends BaseFragment{
                             ArrayList<GiftBagApp> newList = baseMessage.getDataList(GiftBagApp.class);
                             giftCenterList.clear();
                             ListUtil.addAll(giftCenterList, newList);
-                            wcGiftCenterList.getAdapter().notifyDataSetChanged();
+                            if(wcGiftCenterList != null)
+                                wcGiftCenterList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
 
@@ -251,7 +250,8 @@ public class FgtWelfareCenter extends BaseFragment{
                         public void onError(BaseMessage baseMessage) {
                             refreshGiftCenter = false;
                             giftCenterList.clear();
-                            wcGiftCenterList.getAdapter().notifyDataSetChanged();
+                            if(wcGiftCenterList != null)
+                                wcGiftCenterList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
                     });
@@ -268,13 +268,6 @@ public class FgtWelfareCenter extends BaseFragment{
         wc_gift_center_title_line.setVisibility(giftCenterList.isEmpty() ? View.GONE : View.VISIBLE);
     }
 
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        // TODO: inflate a fragment view
-        View rootView = super.onCreateView(inflater, container, savedInstanceState);
-        return rootView;
-    }
-
 
     @OnClick({R.id.wc_all_welfare, R.id.wc_all_gift})
     public void onViewClicked(View view) {