Browse Source

修改2.2.0倒计时崩溃bug

xieshengqi 5 years ago
parent
commit
bcff2e3315

+ 16 - 6
app/src/main/java/com/kuxuan/moneynote/ui/fragments/NewsFindFragment.java

96
     @Override
96
     @Override
97
     public void onDestroy() {
97
     public void onDestroy() {
98
         super.onDestroy();
98
         super.onDestroy();
99
+        if (timer_tv != null)
100
+            timer_tv.onCancle();
99
         EventBus.getDefault().unregister(this);
101
         EventBus.getDefault().unregister(this);
100
     }
102
     }
101
 
103
 
195
 //                bundle.putInt(MainActivity.GO_TYPE, 2);
197
 //                bundle.putInt(MainActivity.GO_TYPE, 2);
196
 //                intent.putExtras(bundle);
198
 //                intent.putExtras(bundle);
197
 //                startActivity(intent);
199
 //                startActivity(intent);
198
-         onFinish();
200
+                onFinish();
199
             }
201
             }
200
         });
202
         });
201
         checkCanShowGoldTask();
203
         checkCanShowGoldTask();
240
             @Override
242
             @Override
241
             public void onClick(View v) {
243
             public void onClick(View v) {
242
                 isCloseGif = true;
244
                 isCloseGif = true;
245
+                if (timer_tv != null) {
246
+                    timer_tv.onCancle();
247
+                }
243
                 gif_layout.setVisibility(View.GONE);
248
                 gif_layout.setVisibility(View.GONE);
244
             }
249
             }
245
         });
250
         });
299
             timer_tv.setTime(time, new CountDownTimeTextView.OnFinishListener() {
304
             timer_tv.setTime(time, new CountDownTimeTextView.OnFinishListener() {
300
                 @Override
305
                 @Override
301
                 public void onFinish() {
306
                 public void onFinish() {
302
-                    timer_tv.setText("签到赚钱");
307
+                    if (timer_tv != null)
308
+                        timer_tv.setText("签到赚钱");
303
                 }
309
                 }
304
             });
310
             });
305
             timer_tv.start();
311
             timer_tv.start();
319
         for (NewsTypeJson datum : titles) {
325
         for (NewsTypeJson datum : titles) {
320
             datas.add(NewsFragment.getInstance(datum.getKey()).setMlis(listener));
326
             datas.add(NewsFragment.getInstance(datum.getKey()).setMlis(listener));
321
         }
327
         }
322
-        newsfindViewpager.setOffscreenPageLimit(5);
323
-        MyViewPageAdapter viewPageAdapter = new MyViewPageAdapter(getActivity().getSupportFragmentManager(), datas, titles);
324
-        newsfindViewpager.setAdapter(viewPageAdapter);
325
-        newsfindTablayout.setupWithViewPager(newsfindViewpager);
328
+        try {
329
+            newsfindViewpager.setOffscreenPageLimit(5);
330
+            MyViewPageAdapter viewPageAdapter = new MyViewPageAdapter(getActivity().getSupportFragmentManager(), datas, titles);
331
+            newsfindViewpager.setAdapter(viewPageAdapter);
332
+            newsfindTablayout.setupWithViewPager(newsfindViewpager);
333
+        } catch (Exception e) {
334
+
335
+        }
326
     }
336
     }
327
 
337
 
328
     public void onFinish() {
338
     public void onFinish() {

+ 10 - 4
app/src/main/java/com/kuxuan/moneynote/ui/fragments/NewsFragment.java

1207
             }
1207
             }
1208
         }).prepareToShowNewsDialog(ADConstants.AD_NEWS_ITEM, 3, coin);
1208
         }).prepareToShowNewsDialog(ADConstants.AD_NEWS_ITEM, 3, coin);
1209
         //删除已领取的当前item
1209
         //删除已领取的当前item
1210
-        if (position == mData.size()) {
1211
-            mData.remove(position - 1);
1212
-        } else {
1213
-            mData.remove(position);
1210
+        try {
1211
+            if(position<=mData.size()){
1212
+                if (position == mData.size()) {
1213
+                    mData.remove(position - 1);
1214
+                } else {
1215
+                    mData.remove(position);
1216
+                }
1217
+            }
1218
+        }catch (Exception e){
1219
+
1214
         }
1220
         }
1215
         EventBus.getDefault().post(new GoldRefreshEvent().setNewsItem(true));
1221
         EventBus.getDefault().post(new GoldRefreshEvent().setNewsItem(true));
1216
         EventBus.getDefault().post(new GoldGetForNetEvent());
1222
         EventBus.getDefault().post(new GoldGetForNetEvent());

+ 8 - 1
app/src/main/java/com/kuxuan/moneynote/ui/view/CountDownTimeTextView.java

156
                 listener.onFinish();
156
                 listener.onFinish();
157
             }
157
             }
158
         };
158
         };
159
-
160
     }
159
     }
161
 
160
 
161
+    /**
162
+     * 取消操作
163
+     */
164
+    public void onCancle(){
165
+        if(timer!=null)
166
+            timer.cancel();
167
+    }
162
     private String getMillisecondsTimes(long l) {
168
     private String getMillisecondsTimes(long l) {
163
         l = l % MS_IN_AN_HOUR;
169
         l = l % MS_IN_AN_HOUR;
164
         long minutes = l / MS_IN_A_MINUTE; //分
170
         long minutes = l / MS_IN_A_MINUTE; //分
223
     }
229
     }
224
 
230
 
225
     public void start() {
231
     public void start() {
232
+
226
         timer.start();
233
         timer.start();
227
     }
234
     }
228
 
235
 

+ 3 - 3
app/src/main/java/com/kuxuan/moneynote/ui/weight/AwardDialog.java

33
     private Context mContext;
33
     private Context mContext;
34
     private String image_url;
34
     private String image_url;
35
 
35
 
36
-    public AwardDialog(@NonNull Context context,String image_url) {
36
+    public AwardDialog(@NonNull Context context, String image_url) {
37
         super(context);
37
         super(context);
38
         this.mContext = context;
38
         this.mContext = context;
39
-        this.image_url =image_url;
39
+        this.image_url = image_url;
40
 //        getImageUrl();
40
 //        getImageUrl();
41
     }
41
     }
42
 
42
 
62
             @Override
62
             @Override
63
             public void onClick(View view) {
63
             public void onClick(View view) {
64
                 dismiss();
64
                 dismiss();
65
-                if(listener!=null)
65
+                if (listener != null)
66
                     listener.onDeleteimgClick();
66
                     listener.onDeleteimgClick();
67
             }
67
             }
68
         });
68
         });