Selaa lähdekoodia

修改2.2.0倒计时崩溃bug

xieshengqi 5 vuotta sitten
vanhempi
commit
bcff2e3315

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

@@ -96,6 +96,8 @@ public class NewsFindFragment extends BaseFragment {
96 96
     @Override
97 97
     public void onDestroy() {
98 98
         super.onDestroy();
99
+        if (timer_tv != null)
100
+            timer_tv.onCancle();
99 101
         EventBus.getDefault().unregister(this);
100 102
     }
101 103
 
@@ -195,7 +197,7 @@ public class NewsFindFragment extends BaseFragment {
195 197
 //                bundle.putInt(MainActivity.GO_TYPE, 2);
196 198
 //                intent.putExtras(bundle);
197 199
 //                startActivity(intent);
198
-         onFinish();
200
+                onFinish();
199 201
             }
200 202
         });
201 203
         checkCanShowGoldTask();
@@ -240,6 +242,9 @@ public class NewsFindFragment extends BaseFragment {
240 242
             @Override
241 243
             public void onClick(View v) {
242 244
                 isCloseGif = true;
245
+                if (timer_tv != null) {
246
+                    timer_tv.onCancle();
247
+                }
243 248
                 gif_layout.setVisibility(View.GONE);
244 249
             }
245 250
         });
@@ -299,7 +304,8 @@ public class NewsFindFragment extends BaseFragment {
299 304
             timer_tv.setTime(time, new CountDownTimeTextView.OnFinishListener() {
300 305
                 @Override
301 306
                 public void onFinish() {
302
-                    timer_tv.setText("签到赚钱");
307
+                    if (timer_tv != null)
308
+                        timer_tv.setText("签到赚钱");
303 309
                 }
304 310
             });
305 311
             timer_tv.start();
@@ -319,10 +325,14 @@ public class NewsFindFragment extends BaseFragment {
319 325
         for (NewsTypeJson datum : titles) {
320 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 338
     public void onFinish() {

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

@@ -1207,10 +1207,16 @@ public class NewsFragment extends BaseFragment {
1207 1207
             }
1208 1208
         }).prepareToShowNewsDialog(ADConstants.AD_NEWS_ITEM, 3, coin);
1209 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 1221
         EventBus.getDefault().post(new GoldRefreshEvent().setNewsItem(true));
1216 1222
         EventBus.getDefault().post(new GoldGetForNetEvent());

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

@@ -156,9 +156,15 @@ public class CountDownTimeTextView extends AppCompatTextView {
156 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 168
     private String getMillisecondsTimes(long l) {
163 169
         l = l % MS_IN_AN_HOUR;
164 170
         long minutes = l / MS_IN_A_MINUTE; //分
@@ -223,6 +229,7 @@ public class CountDownTimeTextView extends AppCompatTextView {
223 229
     }
224 230
 
225 231
     public void start() {
232
+
226 233
         timer.start();
227 234
     }
228 235
 

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

@@ -33,10 +33,10 @@ public class AwardDialog extends Dialog {
33 33
     private Context mContext;
34 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 37
         super(context);
38 38
         this.mContext = context;
39
-        this.image_url =image_url;
39
+        this.image_url = image_url;
40 40
 //        getImageUrl();
41 41
     }
42 42
 
@@ -62,7 +62,7 @@ public class AwardDialog extends Dialog {
62 62
             @Override
63 63
             public void onClick(View view) {
64 64
                 dismiss();
65
-                if(listener!=null)
65
+                if (listener != null)
66 66
                     listener.onDeleteimgClick();
67 67
             }
68 68
         });