Kaynağa Gözat

优化下载管理

zengjiebin 7 yıl önce
ebeveyn
işleme
919576efe0
28 değiştirilmiş dosya ile 210 ekleme ve 286 silme
  1. 25 48
      app/src/main/java/com/sheep/gamegroup/absBase/AbsGetDownloadListener.java
  2. 9 10
      app/src/main/java/com/sheep/gamegroup/helper/DownloadHelper.java
  3. 25 38
      app/src/main/java/com/sheep/gamegroup/helper/FindAppHelper.java
  4. 1 1
      app/src/main/java/com/sheep/gamegroup/helper/TaskHelper.java
  5. 1 2
      app/src/main/java/com/sheep/gamegroup/module/game/activity/ActDownloadManager.java
  6. 3 3
      app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java
  7. 3 17
      app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameCenterTypeList.java
  8. 10 3
      app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtDownloadManager.java
  9. 4 4
      app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtMyGameList.java
  10. 1 1
      app/src/main/java/com/sheep/gamegroup/module/game/model/DownloadInfoHelper.java
  11. 40 59
      app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java
  12. 1 1
      app/src/main/java/com/sheep/gamegroup/util/DownloadUtil.java
  13. 4 4
      app/src/main/java/com/sheep/gamegroup/view/activity/ActArticle.java
  14. 2 2
      app/src/main/java/com/sheep/gamegroup/view/activity/ActGcGameAppDetail.java
  15. 1 1
      app/src/main/java/com/sheep/gamegroup/view/activity/ActReservation.java
  16. 2 2
      app/src/main/java/com/sheep/gamegroup/view/activity/ActSearchGame.java
  17. 1 1
      app/src/main/java/com/sheep/gamegroup/view/activity/ActXiaomiGame.java
  18. 1 1
      app/src/main/java/com/sheep/gamegroup/view/activity/TaskDetailAct.java
  19. 7 7
      app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameItemAdapter.java
  20. 9 11
      app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameListAdapter.java
  21. 16 22
      app/src/main/java/com/sheep/gamegroup/view/adapter/TryMakeMoneyAdp.java
  22. 6 6
      app/src/main/java/com/sheep/gamegroup/view/adapter/WelfareAdapter.java
  23. 1 1
      app/src/main/java/com/sheep/gamegroup/view/dialog/DialogGameOrTaskOrGift.java
  24. 3 2
      app/src/main/java/com/sheep/gamegroup/view/fragment/BaseListFragment6.java
  25. 4 4
      app/src/main/java/com/sheep/gamegroup/view/fragment/FgtArticleComment.java
  26. 4 4
      app/src/main/java/com/sheep/gamegroup/view/fragment/FgtFindChild.java
  27. 21 27
      app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPlaGameGift.java
  28. 5 4
      app/src/main/java/com/sheep/jiuyan/samllsheep/service/DownloadService.java

+ 25 - 48
app/src/main/java/com/sheep/gamegroup/absBase/AbsGetDownloadListener.java

@@ -30,88 +30,65 @@ public abstract class AbsGetDownloadListener {
     private AbsDownloadListener absDownloadListener = new AbsDownloadListener() {
         @Override
         public void removedApk(final String packageName) {
-            checkPackageName(packageName, new ICallBack2<TextView, String>() {
-                @Override
-                public void call(TextView textView, String downloadUrl) {
-                    String path = PackageUtil.isExistsFile(packageName, downloadUrl);
-                    if (TextUtils.isEmpty(path)) {
-                        textView.setText(DownloadTextUtl.getStartDownloadText(showSimpleText));
-                    } else {
-                        textView.setText(DownloadTextUtl.getStartInstallText(showSimpleText));
-                    }
+            checkPackageName(packageName, (textView, downloadUrl) -> {
+                String path = PackageUtil.isExistsFile(packageName, downloadUrl);
+                if (TextUtils.isEmpty(path)) {
+                    textView.setText(DownloadTextUtl.getStartDownloadText(showSimpleText));
+                } else {
+                    textView.setText(DownloadTextUtl.getStartInstallText(showSimpleText));
                 }
             });
         }
 
         @Override
         public void addedApk(String packageName) {
-            checkPackageName(packageName, new ICallBack2<TextView, String>() {
-                @Override
-                public void call(TextView textView, String downloadUrl) {
-                    textView.setText(DownloadTextUtl.getStartOpenText(showSimpleText));
-                }
-            });
+            checkPackageName(packageName, (textView, downloadUrl) -> textView.setText(DownloadTextUtl.getStartOpenText(showSimpleText)));
         }
 
         @Override
         public void running(final DownLoadInfo task) {
-            checkUrl(task.getMDownloadUrl(), new Action1<TextView>() {
-                @Override
-                public void call(TextView textView) {
-                    if (textView != null) {
-                        textView.setText(DownloadTextUtl.getProgressText(showSimpleText, task));
-                    }
+            checkUrl(task.getMDownloadUrl(), textView -> {
+                if (textView != null) {
+                    textView.setText(DownloadTextUtl.getProgressText(showSimpleText, task));
                 }
             });
         }
 
         @Override
         public void taskStop(final DownLoadInfo task) {
-            checkUrl(task.getMDownloadUrl(), new Action1<TextView>() {
-                @Override
-                public void call(TextView textView) {
-                    if (textView != null) {
-                        textView.setText(DownloadTextUtl.getContinueDownloadText(showSimpleText));
-                    }
+            checkUrl(task.getMDownloadUrl(), textView -> {
+                if (textView != null) {
+                    textView.setText(DownloadTextUtl.getContinueDownloadText(showSimpleText));
                 }
             });
         }
 
         @Override
         public void taskComplete(final DownLoadInfo task) {
-            checkUrl(task.getMDownloadUrl(), new Action1<TextView>() {
-                @Override
-                public void call(TextView textView) {
-                    if (textView != null) {
-                        textView.setText(DownloadTextUtl.getStartInstallText(showSimpleText));
-                        DownloadHelper downloadHelper = getDownloadHelper(task.getMDownloadUrl());
-                        if (downloadHelper != null)
-                            downloadHelper.updateState(DownloadUtil.STATUS_FINISH);
-                    }
+            checkUrl(task.getMDownloadUrl(), textView -> {
+                if (textView != null) {
+                    textView.setText(DownloadTextUtl.getStartInstallText(showSimpleText));
+                    DownloadHelper downloadHelper = getDownloadHelper(task.getMDownloadUrl());
+                    if (downloadHelper != null)
+                        downloadHelper.updateState(DownloadUtil.STATUS_FINISH);
                 }
             });
         }
 
         @Override
         public void taskCancel(final DownLoadInfo task) {
-            checkUrl(task.getMDownloadUrl(), new Action1<TextView>() {
-                @Override
-                public void call(TextView textView) {
-                    if (textView != null) {
-                        textView.setText(DownloadTextUtl.getTaskCancelText(showSimpleText));
-                    }
+            checkUrl(task.getMDownloadUrl(), textView -> {
+                if (textView != null) {
+                    textView.setText(DownloadTextUtl.getTaskCancelText(showSimpleText));
                 }
             });
         }
 
         @Override
         public void taskFail(final DownLoadInfo task) {
-            checkUrl(task.getMDownloadUrl(), new Action1<TextView>() {
-                @Override
-                public void call(TextView textView) {
-                    if (textView != null) {
-                        textView.setText(DownloadTextUtl.getFailDownloadText(showSimpleText));
-                    }
+            checkUrl(task.getMDownloadUrl(), textView -> {
+                if (textView != null) {
+                    textView.setText(DownloadTextUtl.getFailDownloadText(showSimpleText));
                 }
             });
         }

+ 9 - 10
app/src/main/java/com/sheep/gamegroup/helper/DownloadHelper.java

@@ -35,18 +35,17 @@ public class DownloadHelper {
     private int downLoadType;
     /**
      * 更新游戏下载与响应点击
-     * @param activity
+     * @param showSimpleText
      * @param iTask
      * @param down_tv
      */
-    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv) {
-        updateDownloadTaskView(activity, iTask, down_tv, null);
+    public void updateDownloadTaskView(boolean showSimpleText, final IDownload iTask, final TextView down_tv) {
+        updateDownloadTaskView(showSimpleText, iTask, down_tv, null);
     }
-    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv, final Action1<Object> callBack) {
-        updateDownloadTaskView(activity, iTask, down_tv, callBack,0);
+    public void updateDownloadTaskView(boolean showSimpleText, final IDownload iTask, final TextView down_tv, final Action1<Object> callBack) {
+        updateDownloadTaskView(showSimpleText, iTask, down_tv, callBack,0);
     }
-    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv, final Action1<Object> callBack,int type) {
-        final boolean showSimpleText = down_tv.getText().length() < 4;
+    public void updateDownloadTaskView(boolean showSimpleText, final IDownload iTask, final TextView down_tv, final Action1<Object> callBack,int type) {
         if(downloadUtil == null){
             downloadUtil = new DownloadUtil();
         }
@@ -70,7 +69,7 @@ public class DownloadHelper {
                 public void onClick(View view) {
                     if(callBack != null)
                         callBack.call(-1);
-                    downloadApp(activity, iTask);
+                    downloadApp(iTask);
                 }
             });
         }
@@ -79,11 +78,11 @@ public class DownloadHelper {
     private DownloadUtil downloadUtil;
 
     /**
-     * @param activity
      * @param download
      *   //下载应用
      */
-    private void downloadApp(Activity activity, IDownload download) {
+    private void downloadApp( IDownload download) {
+        Activity activity = SheepApp.getInstance().getCurrentActivity();
         switch (downLoadType){
             case DownloadUtil.STATUS_INIT://可以下载
                 final DownloadTask task;

+ 25 - 38
app/src/main/java/com/sheep/gamegroup/helper/FindAppHelper.java

@@ -2,13 +2,12 @@ package com.sheep.gamegroup.helper;
 
 import android.app.Activity;
 import android.view.Gravity;
-import android.view.View;
 import android.widget.TextView;
 
 import com.sheep.gamegroup.model.api.IDownload;
+import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DialogConfig;
-import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.DownloadTextUtl;
 import com.sheep.gamegroup.util.DownloadUtil;
@@ -20,8 +19,8 @@ import com.sheep.jiuyan.samllsheep.utils.G;
 import java.util.Locale;
 
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
 
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_APP;
 
@@ -40,22 +39,19 @@ public class FindAppHelper {
         downloadHelper.updateState(status);
     }
 
-    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv) {
-        updateDownloadTaskView(activity, iTask, down_tv, 0);
+    public void updateDownloadTaskView(boolean showSimpleText, final IDownload iTask, final TextView down_tv) {
+        updateDownloadTaskView(showSimpleText, iTask, down_tv, 0);
     }
 
-    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv, int type) {
-        downloadHelper.updateDownloadTaskView(activity, iTask, down_tv, new Action1<Object>() {
-            @Override
-            public void call(Object object) {
-                boolean installed = object instanceof Integer && DownloadUtil.STATUS_INIT != (int) object;//-1 点击下载按钮的回调;其它状态直接回调不需要点击按钮
-                boolean downloadLinkError = object instanceof Boolean && !(boolean) object;//false 下载地址错误会传false过来
-                if (installed || downloadLinkError) {
-                    if (iTask instanceof Applications) {
-                        Applications findApp = (Applications) iTask;
-                        recordAppDownloads(activity, findApp, null);
-                        FIND_APP.onEvent("application_id", findApp.getId(), "action", down_tv.getText());
-                    }
+    public void updateDownloadTaskView(boolean showSimpleText, final IDownload iTask, final TextView down_tv, int type) {
+        downloadHelper.updateDownloadTaskView(showSimpleText, iTask, down_tv, object -> {
+            boolean installed = object instanceof Integer && DownloadUtil.STATUS_INIT != (int) object;//-1 点击下载按钮的回调;其它状态直接回调不需要点击按钮
+            boolean downloadLinkError = object instanceof Boolean && !(boolean) object;//false 下载地址错误会传false过来
+            if (installed || downloadLinkError) {
+                if (iTask instanceof Applications) {
+                    Applications findApp = (Applications) iTask;
+                    recordAppDownloads(showSimpleText, findApp, null);
+                    FIND_APP.onEvent("application_id", findApp.getId(), "action", down_tv.getText());
                 }
             }
         }, type);
@@ -64,22 +60,17 @@ public class FindAppHelper {
     /**
      * 更新预约下载状态与响应点击
      *
-     * @param activity
      * @param findApp
      * @param reservation_tv
      */
-    public void updateReservationView(final Activity activity, final Applications findApp, final TextView reservation_tv) {
-        final boolean showSimpleText = reservation_tv.getText().length() < 4;
+    public void updateReservationView(boolean showSimpleText, final Applications findApp, final TextView reservation_tv) {
         if (findApp.isCanRecord()) {
             reservation_tv.setEnabled(true);
             reservation_tv.setText(DownloadTextUtl.getReservationText(showSimpleText));
-            reservation_tv.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View view) {
-                    FIND_APP.onEvent("application_id", findApp.getId(), "action", "预约下载");
-                    reservation_tv.setEnabled(false);
-                    recordAppDownloads(activity, findApp, reservation_tv);
-                }
+            reservation_tv.setOnClickListener(view -> {
+                FIND_APP.onEvent("application_id", findApp.getId(), "action", "预约下载");
+                reservation_tv.setEnabled(false);
+                recordAppDownloads(showSimpleText, findApp, reservation_tv);
             });
         } else {
             reservation_tv.setEnabled(false);
@@ -87,19 +78,15 @@ public class FindAppHelper {
         }
     }
 
-    public void updateReservationView(final Activity activity, final Applications gameApp, final TextView reservation_tv, int type) {
-        final boolean showSimpleText = reservation_tv.getText().length() < 4;
+    public void updateReservationView(boolean showSimpleText, final Applications gameApp, final TextView reservation_tv, int type) {
         if (gameApp.isCanRecord()) {
             reservation_tv.setEnabled(true);
             reservation_tv.setText(DownloadTextUtl.getReservationText(showSimpleText));
             if (type == 0) {
-                reservation_tv.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        FIND_APP.onEvent("application_id", gameApp.getId(), "action", "预约下载");
-                        reservation_tv.setEnabled(false);
-                        recordAppDownloads(activity, gameApp, reservation_tv);
-                    }
+                reservation_tv.setOnClickListener(view -> {
+                    FIND_APP.onEvent("application_id", gameApp.getId(), "action", "预约下载");
+                    reservation_tv.setEnabled(false);
+                    recordAppDownloads(showSimpleText, gameApp, reservation_tv);
                 });
             }
 
@@ -115,14 +102,13 @@ public class FindAppHelper {
      *
      * @param findApp
      */
-    private void recordAppDownloads(final Activity activity, final Applications findApp, final TextView textView) {
+    private void recordAppDownloads(boolean showSimpleText, final Applications findApp, final TextView textView) {
         SheepApp.getInstance().getNetComponent().getApiService().recordAppDownloads(findApp.getId())
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                        final boolean showSimpleText = textView != null && textView.getText().length() < 4;
                         findApp.setRecord(2);//设置为不可记录
                         if (findApp.isCanDownload()) {
                             //提交下载成功
@@ -133,6 +119,7 @@ public class FindAppHelper {
                                 textView.setEnabled(false);
                                 textView.setText(DownloadTextUtl.getHasReservationText(showSimpleText));
                             }
+                            Activity activity = SheepApp.getInstance().getCurrentActivity();
                             ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("预约成功")
                                     .setMsg(String.format(Locale.CHINA, "请在%s准时到小绵羊下载哦", TimeUtil.TimeStamp2Date(findApp.getDownload_at(), "yyyy年MM月dd日HH时mm分")))
                                     .setMsgGravity(Gravity.START).setBtnLeftText("我知道了"));

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/helper/TaskHelper.java

@@ -155,7 +155,7 @@ public class TaskHelper {
             find_information_game_surplus1.setVisibility(View.GONE);
             find_information_game_task.setText("去充值");
             find_information_game_task.setEnabled(true);
-            downloadHelper.updateDownloadTaskView(activity, taskEty, find_information_game_task0);
+            downloadHelper.updateDownloadTaskView(true, taskEty, find_information_game_task0);
             find_information_game_task.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActDownloadManager.java

@@ -10,8 +10,7 @@ import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 /**
  * Created by realicing on 2019/1/21.
  * realicing@sina.com
- *
- * 下载管理界面
+ * 小绵羊3.4.10新增 -- 下载管理界面
  */
 public class ActDownloadManager extends BaseContainerActivity {
     @Override

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java

@@ -268,7 +268,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
                 recyclerView.getAdapter().notifyDataSetChanged();
         }
         //下载按钮
-        CommonUtil.getInstance().palyGameDetailBtnValue(this, gameEntity, gc_game_app_detail_bt2, 0);
+        CommonUtil.getInstance().palyGameDetailBtnValue(false, gameEntity, gc_game_app_detail_bt2, 0);
         fgtGameDetail.loadData(gameEntity);
         if (gameEntity.getApp().getGame_discount_id() == 0) {
             gc_game_app_detail_bt3.setVisibility(View.GONE);
@@ -316,7 +316,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
                             checkData(gameEntity);
                         } else if (gameEntity != null) {
                             //更新下载按钮
-                            CommonUtil.getInstance().palyGameDetailBtnValue(ActGameGroupOrGameDetail.this, gameEntity, gc_game_app_detail_bt2, 0);
+                            CommonUtil.getInstance().palyGameDetailBtnValue(false, gameEntity, gc_game_app_detail_bt2, 0);
                         }
                     }
 
@@ -424,7 +424,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
         Jump2View.getInstance().gotoGameVipRecharge(gameEntity.getApp());
     }
 
-    private AbsGetDownloadListener absGetDownloadListener = new AbsGetDownloadListener(true) {
+    private AbsGetDownloadListener absGetDownloadListener = new AbsGetDownloadListener(false) {
         @Override
         public String getDownloadUrl(String packageName) {
             return gameEntity != null ? gameEntity.getDownloadUrl(packageName) : null;

+ 3 - 17
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameCenterTypeList.java

@@ -2,30 +2,20 @@ package com.sheep.gamegroup.module.game.adapter;
 
 import android.support.annotation.Nullable;
 import android.widget.ImageView;
-import android.widget.ProgressBar;
 import android.widget.TextView;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.BaseViewHolder;
-import com.sheep.gamegroup.absBase.AbsObserver;
-import com.sheep.gamegroup.helper.DownloadHelper;
+import com.sheep.gamegroup.helper.FindAppHelper;
 import com.sheep.gamegroup.model.api.IDownload;
 import com.sheep.gamegroup.model.entity.GameEntity;
-import com.sheep.gamegroup.module.game.model.GameCenterType;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.string.SpannableSb;
 import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.util.List;
 import java.util.Locale;
 
-import io.reactivex.Observable;
-import io.reactivex.ObservableOnSubscribe;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
-import rx.functions.Action1;
-
 import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
 
 /**
@@ -57,12 +47,8 @@ public class AdpGameCenterTypeList extends BaseQuickAdapter<GameEntity, BaseView
                     .getSsb());
 
             item_dm_btn_tv.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + download.getDownload_link());
-            DownloadHelper downloadHelper = item.getDownloadHelper(download.getDownload_link());
-            if(downloadHelper != null){
-                downloadHelper.updateDownloadTaskView(SheepApp.getInstance().getCurrentActivity(), download, item_dm_btn_tv, o -> {
-
-                });
-            }
+            FindAppHelper findAppHelper = item.getApp().getFindAppHelper();
+            findAppHelper.updateDownloadTaskView(true, download, item_dm_btn_tv);
         }
     }
 }

+ 10 - 3
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtDownloadManager.java

@@ -11,6 +11,7 @@ import android.widget.TextView;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.BaseViewHolder;
+import com.liulishuo.okdownload.OkDownload;
 import com.sheep.gamegroup.absBase.AbsApiRefresh;
 import com.sheep.gamegroup.absBase.AbsDownloadListener;
 import com.sheep.gamegroup.absBase.AbsGetDownloadListener;
@@ -52,6 +53,7 @@ import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX
 /**
  * Created by realicing on 2019/1/21.
  * realicing@sina.com
+ * 小绵羊3.4.10新增 -- 下载管理界面
  */
 public class FgtDownloadManager extends BaseListFragment6<String> {
 
@@ -66,7 +68,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
     private NetApiRefresh<GameEntity> apiRefresh2;
     @Override
     protected void addApiRefresh(List<IApiRefresh> apiRefreshList) {
-        tagList.add("已安装");
+        tagList.add("下载游戏");
         tagList.add("猜你喜欢");
         apiRefresh = new AbsApiRefresh<DownLoadInfo>(this) {
 
@@ -204,6 +206,11 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
                 e.printStackTrace();
             }
             try {
+                OkDownload.with().downloadDispatcher().cancelAll();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
                 ClassFileHelper.getInstance().clearDir();
             } catch (Exception e) {
                 e.printStackTrace();
@@ -216,8 +223,8 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
             public void onNext(Integer integer) {
                 if(apiRefresh != null){
                     apiRefresh.clear();
-                    if(downLoadInfoAdapter != null){
-                        downLoadInfoAdapter.notifyDataSetChanged();
+                    if(baseQuickAdapter != null){
+                        baseQuickAdapter.notifyDataSetChanged();
                     }
                 }
             }

+ 4 - 4
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtMyGameList.java

@@ -93,7 +93,7 @@ public class FgtMyGameList extends BaseListFragment6<MyGame> {
                     ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "厂商:%s\u0020包体大小:%sM", applications.getManufacturer(), applications.getPackage_size()));
                 find_information_game_task_center.setVisibility(View.VISIBLE);
 
-                updateView(getActivity(), applications, find_information_game_task_center);
+                updateView(applications, find_information_game_task_center);
 
                 ViewUtil.setVisibility(helper.getView(R.id.item_my_game_v), position > 0);
             }
@@ -112,15 +112,15 @@ public class FgtMyGameList extends BaseListFragment6<MyGame> {
     private Map<String, TextView> downLoadTextViewMap = new HashMap<>();
 
     //更新按钮状态与添加点击事件
-    private void updateView(Activity activity, Applications findApp, TextView textView) {
+    private void updateView(Applications findApp, TextView textView) {
         if (findApp.isCanDownload()) {//可下载
             downLoadTextViewMap.put(findApp.getDownload_link(), textView);
             downLoadTextViewMap.put(findApp.getPackage_name(), textView);
             applicationMap.put(findApp.getDownload_link(), findApp);
             applicationMap.put(findApp.getPackage_name(), findApp);
-            findApp.getFindAppHelper().updateDownloadTaskView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, textView);
         } else {//预约下载
-            findApp.getFindAppHelper().updateReservationView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateReservationView(true, findApp, textView);
         }
     }
 

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/model/DownloadInfoHelper.java

@@ -40,7 +40,7 @@ public class DownloadInfoHelper implements IDownload {
 
     public void updateDownloadTaskView(Activity activity, TextView textView) {
         textView.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + getDownload_link());
-        downloadHelper.updateDownloadTaskView(activity, this, textView);
+        downloadHelper.updateDownloadTaskView(true, this, textView);
     }
 
     @Override

+ 40 - 59
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -1247,9 +1247,9 @@ public class CommonUtil {
 
 
     //对---游戏任务中的预约任务----进行---预约操作
-    public void reservationGameTask(final Context context, final Release_task taskReleaseEty, final Action1<Integer> action1) {
+    public void reservationGameTask(final Release_task taskReleaseEty, final Action1<Integer> action1) {
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("device_id", DeviceUtil.getDeviceId(context));
+        jsonObject.put("device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
         jsonObject.put("release_task_id", taskReleaseEty.getId());
         jsonObject.put("create_time", System.currentTimeMillis() / 1000L);//这里添加时间戳,防止用户抓包后重复使用
         jsonObject.put("app_version", String.valueOf(BuildConfig.VERSION_CODE));
@@ -1260,15 +1260,13 @@ public class CommonUtil {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
                         if (baseMessage.getCode() == 200) {
-                            ViewUtil.showMsgDialog(context, new DialogConfig().setTitle("预约成功")
+                            Activity activity = SheepApp.getInstance().getCurrentActivity();
+                            ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("预约成功")
                                     .setMsg(String.format(Locale.CHINA, "恭喜您获得%s元绵羊币\n注意%s准时开放下载", taskReleaseEty.getBonusText(),
                                             TimeUtil.TimeStamp2Date(taskReleaseEty.getTask().getAppointment_time(), "yyyy-MM-dd\u0020HH:mm")))
-                                    .setBtnLeftText("收入钱包").setBtnLeftOnClickListener(new View.OnClickListener() {
-                                        @Override
-                                        public void onClick(View view) {
-                                            if (action1 != null)
-                                                action1.call(1);
-                                        }
+                                    .setBtnLeftText("收入钱包").setBtnLeftOnClickListener(view -> {
+                                        if (action1 != null)
+                                            action1.call(1);
                                     }));
                         } else if (baseMessage.getCode() == 0) {
                             try {
@@ -1289,9 +1287,9 @@ public class CommonUtil {
                 });
     }
 
-    public void acceptedTask(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
+    public void acceptedTask(final GameEntity gameEntity, final Action1<Integer> action1) {
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("device_id", DeviceUtil.getDeviceId(context));
+        jsonObject.put("device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
         jsonObject.put("release_task_id", gameEntity.getRelease_task().getId());
         jsonObject.put("create_time", System.currentTimeMillis() / 1000L);//这里添加时间戳,防止用户抓包后重复使用
         jsonObject.put("app_version", String.valueOf(BuildConfig.VERSION_CODE));
@@ -1309,7 +1307,7 @@ public class CommonUtil {
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
-                            receiveAwards(context, gameEntity, action1);
+                            receiveAwards(gameEntity, action1);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
@@ -1323,19 +1321,19 @@ public class CommonUtil {
     }
 
     //对---游戏任务中的领取奖励
-    public void receiveAward(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
+    public void receiveAward(final GameEntity gameEntity, final Action1<Integer> action1) {
         RECEIVE_AWARD_GAME_TASK.onEvent();
         if (gameEntity.getAccepted_task_id() < 1) {
-            acceptedTask(context, gameEntity, action1);
+            acceptedTask(gameEntity, action1);
         } else {
-            receiveAwards(context, gameEntity, action1);
+            receiveAwards(gameEntity, action1);
         }
 
 
     }
 
     //领取奖励
-    public void receiveAwards(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
+    public void receiveAwards(final GameEntity gameEntity, final Action1<Integer> action1) {
         SheepApp.getInstance()
                 .getNetComponent()
                 .getApiService()
@@ -1352,7 +1350,7 @@ public class CommonUtil {
                     public void onNext(BaseMessage baseMessage) {
                         //这里领取了奖励,要刷新用户信息
                         CommonUtil.getInstance().updateUserInfo(null);
-                        ViewUtil.showMsgDialog(context,
+                        ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(),
 //                               gameEntity.getRelease_task().getFuliContent(),
                                 "恭喜你获得" + gameEntity.getBonusText() + "元奖励",
                                 "提示",
@@ -1363,14 +1361,14 @@ public class CommonUtil {
                 });
     }
 
-    private void giveUpTask(final Context context, final Release_task taskReleaseEty, final Action1<Integer> action1) {
+    private void giveUpTask(final Release_task taskReleaseEty, final Action1<Integer> action1) {
         SheepApp.getInstance().getNetComponent().getApiService().giveUpTask(taskReleaseEty.getAccepted_task_id())
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(context) {
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                        reservationGameTask(context, taskReleaseEty, action1);
+                        reservationGameTask(taskReleaseEty, action1);
                     }
 
                     @Override
@@ -1380,15 +1378,10 @@ public class CommonUtil {
                 });
     }
 
-    public void tryGiveUpTask(final Context context, final Release_task taskReleaseEty, final Action1<Integer> action1) {
-        ViewUtil.showMsgDialog(context, new DialogConfig().setTitle("提示")
-                .setMsg(context.getString(R.string.give_up_doing_task_or_not)).setBtnRightText("否")
-                .setBtnLeftText("是").setBtnLeftOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        giveUpTask(context, taskReleaseEty, action1);
-                    }
-                }));
+    public void tryGiveUpTask(final Release_task taskReleaseEty, final Action1<Integer> action1) {
+        ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(), new DialogConfig().setTitle("提示")
+                .setMsg(SheepApp.getInstance().getString(R.string.give_up_doing_task_or_not)).setBtnRightText("否")
+                .setBtnLeftText("是").setBtnLeftOnClickListener(view -> giveUpTask(taskReleaseEty, action1)));
     }
 
     /**
@@ -2333,10 +2326,9 @@ public class CommonUtil {
      * type 1
      * 0,--------1,已接受任务 2,正在进行中,3完成任务,4放弃任务,5任务失败,6审核失败,7提交审核,8任务已下线,9至少完成了一个任务了
      */
-    public void palyGameDetailBtnValue(final Context context, final GameEntity gameEntity, final TextView detail_task_tv_center, final int type) {
+    public void palyGameDetailBtnValue(boolean showSimpleText, final GameEntity gameEntity, final TextView detail_task_tv_center, final int type) {
         if (detail_task_tv_center == null)
             return;
-        final boolean showSimpleText = detail_task_tv_center.getText().length() < 4;
         final Release_task releaseEty = gameEntity.getRelease_task();
         final TaskEty taskEty = releaseEty != null ? releaseEty.getTask() : null;
         if (releaseEty != null && taskEty != null) {//游戏任务
@@ -2348,45 +2340,34 @@ public class CommonUtil {
                     detail_task_tv_center.setText(DownloadTextUtl.getReservationText(showSimpleText));
                     detail_task_tv_center.setEnabled(true);
                     if (type == 0) {
-                        detail_task_tv_center.setOnClickListener(new View.OnClickListener() {
-                            @Override
-                            public void onClick(View view) {
-                                CommonUtil.getInstance().reservationGameTask(context, releaseEty, new Action1<Integer>() {
-                                    @Override
-                                    public void call(Integer integer) {
-                                        if (integer > 0) {
-                                            gameEntity.setAccepted_task_id(integer);
-                                            detail_task_tv_center.setText(DownloadTextUtl.getHasReservationText(showSimpleText));
-                                            detail_task_tv_center.setEnabled(false);
-
-                                        }
-                                    }
-                                });
+                        detail_task_tv_center.setOnClickListener(view -> CommonUtil.getInstance().reservationGameTask(releaseEty, integer -> {
+                            if (integer > 0) {
+                                gameEntity.setAccepted_task_id(integer);
+                                detail_task_tv_center.setText(DownloadTextUtl.getHasReservationText(showSimpleText));
+                                detail_task_tv_center.setEnabled(false);
+
                             }
-                        });
+                        }));
 
                     }
                 }
             } else {
-                releaseEty.getDownloadHelper().updateDownloadTaskView((Activity) context, taskEty, detail_task_tv_center, new Action1<Object>() {
-                    @Override
-                    public void call(Object o) {
-                        if(o instanceof Integer){//下载游戏时判断是否领取了任务
-                            CommonUtil.getInstance().receiveAward(context, gameEntity, new Action1<Integer>() {
-                                @Override
-                                public void call(Integer integer) {
-                                    gameEntity.setReceived_voucher(true);
-                                }
-                            });
-                        }
+                releaseEty.getDownloadHelper().updateDownloadTaskView(showSimpleText, taskEty, detail_task_tv_center, o -> {
+                    if(o instanceof Integer){//下载游戏时判断是否领取了任务
+                        CommonUtil.getInstance().receiveAward(gameEntity, new Action1<Integer>() {
+                            @Override
+                            public void call(Integer integer) {
+                                gameEntity.setReceived_voucher(true);
+                            }
+                        });
                     }
                 }, type);
             }
         } else if (gameEntity.getApp().isCanDownload()) {//可下载
-            gameEntity.getApp().getFindAppHelper().updateDownloadTaskView((Activity) context, gameEntity.getApp(), detail_task_tv_center, type);
+            gameEntity.getApp().getFindAppHelper().updateDownloadTaskView(showSimpleText, gameEntity.getApp(), detail_task_tv_center, type);
             detail_task_tv_center.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + gameEntity.getApp().getDownload_link());
         } else {//预约下载
-            gameEntity.getApp().getFindAppHelper().updateReservationView((Activity) context, gameEntity.getApp(), detail_task_tv_center, type);
+            gameEntity.getApp().getFindAppHelper().updateReservationView(showSimpleText, gameEntity.getApp(), detail_task_tv_center, type);
             detail_task_tv_center.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + gameEntity.getApp().getDownload_link());
         }
     }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/DownloadUtil.java

@@ -386,7 +386,7 @@ public class DownloadUtil {
     public static DownloadTask getTask(String downloadUrl, String filePath){
         DownloadTask.Builder builder = new DownloadTask.Builder(downloadUrl, new File(filePath));
         // Set the minimum internal milliseconds of progress callbacks to 100ms.(default is 3000)
-        builder.setMinIntervalMillisCallbackProcess(100);
+        builder.setMinIntervalMillisCallbackProcess(1000);
         // set the priority of the task to 10, higher means less time to wait to download.(default is 0)
         builder.setPriority(10);
         // set the read buffer to 8192 bytes for the response input-stream.(default is 4096)

+ 4 - 4
app/src/main/java/com/sheep/gamegroup/view/activity/ActArticle.java

@@ -222,7 +222,7 @@ public class ActArticle extends BaseActivity implements Action1<Integer> {
             ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "厂商:%s\u0020包体大小:%sM", findApp.getManufacturer(), findApp.getPackage_size()));
         find_information_game_task_center.setVisibility(View.VISIBLE);
 
-        updateView(this, findApp, find_information_game_task_center);
+        updateView(findApp, find_information_game_task_center);
 
         itemView.setOnClickListener(view -> Jump2View.getInstance().goFindGame(article));
     }
@@ -347,13 +347,13 @@ public class ActArticle extends BaseActivity implements Action1<Integer> {
     }
 
     //更新按钮状态与添加点击事件
-    private void updateView(Activity activity, Applications findApp, TextView textView) {
+    private void updateView(Applications findApp, TextView textView) {
         if (findApp.isCanDownload()) {//可下载
             downLoadTextViewMap.put(findApp.getDownload_link(), textView);
             downLoadTextViewMap.put(findApp.getPackage_name(), textView);
-            findApp.getFindAppHelper().updateDownloadTaskView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, textView);
         } else {//预约下载
-            findApp.getFindAppHelper().updateReservationView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateReservationView(true, findApp, textView);
         }
     }
 

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActGcGameAppDetail.java

@@ -228,7 +228,7 @@ public class ActGcGameAppDetail extends BaseActivity {
                 recyclerView.getAdapter().notifyDataSetChanged();
         }
         //下载按钮
-        CommonUtil.getInstance().palyGameDetailBtnValue(this, gameEntity, gc_game_app_detail_bt2, 0);
+        CommonUtil.getInstance().palyGameDetailBtnValue(true, gameEntity, gc_game_app_detail_bt2, 0);
         fgtGcPlayGameDetail.loadData(gameEntity);
         if (gameEntity.getApp().getGame_discount_id() == 0) {
             gc_game_app_detail_bt3.setVisibility(View.GONE);
@@ -266,7 +266,7 @@ public class ActGcGameAppDetail extends BaseActivity {
                             checkData(gameEntity);
                         } else if (gameEntity != null) {
                             //更新下载按钮
-                            CommonUtil.getInstance().palyGameDetailBtnValue(ActGcGameAppDetail.this, gameEntity, gc_game_app_detail_bt2, 0);
+                            CommonUtil.getInstance().palyGameDetailBtnValue(true, gameEntity, gc_game_app_detail_bt2, 0);
                         }
                     }
 

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActReservation.java

@@ -135,7 +135,7 @@ public class ActReservation extends BaseActivity {
                 downLoadTextViewMap.put(findApp.getPackage_name(), find_information_game_bt1);
                 findAppMap.put(findApp.getDownload_link(), findApp);
                 findAppMap.put(findApp.getPackage_name(), findApp);
-                findApp.getFindAppHelper().updateDownloadTaskView(this, findApp, find_information_game_bt1);
+                findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, find_information_game_bt1);
                 find_information_game_bt2.setEnabled(false);
             } else {
                 find_information_game_bt1.setEnabled(false);

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActSearchGame.java

@@ -161,7 +161,7 @@ public class ActSearchGame extends BaseActivity {
                             ViewUtil.showGamePayAccount(activity, taskEty.getThird_task_id(), items.getName());
                         }
                     });
-                    items.getDownloadHelper().updateDownloadTaskView(activity, taskEty, find_information_game_task_bottom);
+                    items.getDownloadHelper().updateDownloadTaskView(false, taskEty, find_information_game_task_bottom);
                     find_information_game_task_bottom.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + taskEty.getDownload_link());
                 }else if(item instanceof XiaomiGameEntity){
                     final XiaomiGameEntity  items = (XiaomiGameEntity) item;
@@ -177,7 +177,7 @@ public class ActSearchGame extends BaseActivity {
                         CommonUtil.getInstance()
                                 .xiaomiRevieceAcctoun(find_information_game_task_center, items, activity);
                     }else {
-                        items.getDownloadHelper().updateDownloadTaskView((Activity) activity, items, find_information_game_task_center);
+                        items.getDownloadHelper().updateDownloadTaskView(false, items, find_information_game_task_center);
                         find_information_game_task_center.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + items.getDownload_url());
                     }
                 }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActXiaomiGame.java

@@ -134,7 +134,7 @@ public class ActXiaomiGame extends BaseActivity {
                     CommonUtil.getInstance()
                             .xiaomiRevieceAcctoun(detail_task_tv_center, item, activity);
                 }else {
-                    item.getDownloadHelper().updateDownloadTaskView((Activity) activity, item, detail_task_tv_center);
+                    item.getDownloadHelper().updateDownloadTaskView(true, item, detail_task_tv_center);
                     detail_task_tv_center.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + item.getDownload_url());
                 }
                 rootConvertView.setOnClickListener(v -> Jump2View.getInstance().goFindGame(item.getId()));

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/TaskDetailAct.java

@@ -930,7 +930,7 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
             }
         } else if (taskEty.isGameTask()) {
             if (taskEty.isGameReservationCantDownload()) {
-                CommonUtil.getInstance().reservationGameTask(activity, taskReleaseEty, new Action1<Integer>() {
+                CommonUtil.getInstance().reservationGameTask(taskReleaseEty, new Action1<Integer>() {
                     @Override
                     public void call(Integer integer) {
                         isFresh = true;

+ 7 - 7
app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameItemAdapter.java

@@ -1,6 +1,5 @@
 package com.sheep.gamegroup.view.adapter;
 
-import android.app.Activity;
 import android.content.Context;
 import android.view.View;
 import android.widget.ImageView;
@@ -26,8 +25,9 @@ import java.util.List;
  * Created by ljy on 2018/9/3.
  */
 
-public class PlayGameItemAdapter extends AdbCommonRecycler<GameEntity>{
+public class PlayGameItemAdapter extends AdbCommonRecycler<GameEntity> {
     private Context activity;
+
     public PlayGameItemAdapter(Context context, List<GameEntity> list) {
         super(context, list);
         activity = context;
@@ -41,7 +41,7 @@ public class PlayGameItemAdapter extends AdbCommonRecycler<GameEntity>{
     @Override
     public void convert(ViewHolder holder, final GameEntity gameEntity) {
         holder.itemView.setOnClickListener(v -> Jump2View.getInstance().goPlayGameDetail(gameEntity.getApp().getId()));
-        if(TestUtil.isTest())
+        if (TestUtil.isTest())
             holder.itemView.setOnLongClickListener(view -> {
                 IDownload download = gameEntity.getDownload();
                 DownloadUtil downloadUtil = new DownloadUtil();
@@ -59,14 +59,14 @@ public class PlayGameItemAdapter extends AdbCommonRecycler<GameEntity>{
         LinearLayout ll_game_tag = holder.itemView.findViewById(R.id.ll_game_tag);
 
         ViewUtil.setText(item_name_tv, gameEntity.getApp().getName());
-        ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size()+"M");
-        GlideImageLoader.setGameImage((ImageView) holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
-        CommonUtil.getInstance().palyGameDetailBtnValue(context,gameEntity,detail_task_tv_center, 1);
+        ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size() + "M");
+        GlideImageLoader.setGameImage(holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
+        CommonUtil.getInstance().palyGameDetailBtnValue(true, gameEntity, detail_task_tv_center, 1);
 
         item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
 
         //tag 标签绘制
-        CommonUtil.getInstance().paintLineaLayout(gameEntity, ll_game_tag, 4,R.color.txt_bule, R.drawable.shape_blue_stroke_rectangle_no_lb);
+        CommonUtil.getInstance().paintLineaLayout(gameEntity, ll_game_tag, 4, R.color.txt_bule, R.drawable.shape_blue_stroke_rectangle_no_lb);
 
 
     }

+ 9 - 11
app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameListAdapter.java

@@ -1,6 +1,5 @@
 package com.sheep.gamegroup.view.adapter;
 
-import android.app.Activity;
 import android.content.Context;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -17,7 +16,6 @@ import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.service.DownloadService;
 
 import java.util.List;
@@ -26,7 +24,7 @@ import java.util.List;
  * Created by ljy on 2018/9/3.
  */
 
-public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEntity, GameListType>>{
+public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEntity, GameListType>> {
     public PlayGameListAdapter(Context context, List<ListTypeList<GameEntity, GameListType>> list) {
         super(context, list);
     }
@@ -41,7 +39,7 @@ public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEnti
         RecyclerView recyclerView = holderParent.getView(R.id.release_task_listview, RecyclerView.class);
         recyclerView.setHasFixedSize(true);
         recyclerView.setLayoutManager(new LinearLayoutManager(context));
-        recyclerView.setAdapter(new AdbCommonRecycler<GameEntity>(context, item.getList()){
+        recyclerView.setAdapter(new AdbCommonRecycler<GameEntity>(context, item.getList()) {
             @Override
             public int getViewIdByType(int type) {
                 return R.layout.play_game_vertical_list_item;
@@ -58,31 +56,31 @@ public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEnti
                 LinearLayout ll_game_tag = holder.itemView.findViewById(R.id.ll_game_tag);
 
                 ViewUtil.setText(item_name_tv, gameEntity.getApp().getName());
-                ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size()+"M");
+                ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size() + "M");
                 GlideImageLoader.setGameImage(holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
-                CommonUtil.getInstance().palyGameDetailBtnValue(context,gameEntity,detail_task_tv_center, 1);
+                CommonUtil.getInstance().palyGameDetailBtnValue(true, gameEntity, detail_task_tv_center, 1);
 
                 item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
 
                 //tag 标签绘制
-                CommonUtil.getInstance().paintLineaLayout(gameEntity, ll_game_tag, 4,R.color.txt_bule, R.drawable.shape_blue_stroke_rectangle_no_lb);
+                CommonUtil.getInstance().paintLineaLayout(gameEntity, ll_game_tag, 4, R.color.txt_bule, R.drawable.shape_blue_stroke_rectangle_no_lb);
             }
         });
 
 
-
     }
 
     /**
      * 设置游戏中心中游戏的点击与长按
+     *
      * @param view
      * @param item
      */
-    public static void setOnClickGameEntity(View view, final GameEntity item){
-        if(item.getApp() != null){
+    public static void setOnClickGameEntity(View view, final GameEntity item) {
+        if (item.getApp() != null) {
             DownloadService.setDownLoadLongClick(view, item.getApp());
             view.setOnClickListener(v -> Jump2View.getInstance().goPlayGameDetail(item.getApp().getId()));
-        } else if(item.getRelease_task() != null) {
+        } else if (item.getRelease_task() != null) {
             DownloadService.setDownLoadLongClick(view, item.getRelease_task().getTask());
         }
     }

+ 16 - 22
app/src/main/java/com/sheep/gamegroup/view/adapter/TryMakeMoneyAdp.java

@@ -480,7 +480,7 @@ public class TryMakeMoneyAdp extends AdbCommonRecycler<RecyleObj> {
 //                    viewHolder.itemView.setEnabled(false);
                     detail_task_tv.setVisibility(View.GONE);
                     detail_task_tv_down.setVisibility(View.VISIBLE);
-                    taskReleaseEty.getDownloadHelper().updateDownloadTaskView((Activity) context, taskEty, detail_task_tv_down);
+                    taskReleaseEty.getDownloadHelper().updateDownloadTaskView(true, taskEty, detail_task_tv_down);
                     detail_task_tv_down.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + taskEty.getDownload_link());
                 }else {
                     detail_task_tv.setVisibility(View.VISIBLE);
@@ -641,34 +641,28 @@ public class TryMakeMoneyAdp extends AdbCommonRecycler<RecyleObj> {
                 }
 
 
-                detail_task_tv.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        if(taskEty.isGameReservationCantDownload()) {//游戏任务中的预约任务,且不能下载情况下
-                            Action1<Integer> action1 = new Action1<Integer>() {
-                                @Override
-                                public void call(Integer type) {
-                                    switch (type) {
-                                        case 1:
-                                            Jump2View.getInstance().goGameMakeMoney(context, 1);
-                                            break;
-                                    }
-                                }
-                            };
-                            if(taskReleaseEty.getAccepted_task_id() < 1){//没有正在进行的任务
-                                CommonUtil.getInstance().reservationGameTask(context, taskReleaseEty, action1);
-                            } else {//先取消正在进行的任务
-                                CommonUtil.getInstance().tryGiveUpTask(context, taskReleaseEty, action1);
+                detail_task_tv.setOnClickListener(v -> {
+                    if(taskEty.isGameReservationCantDownload()) {//游戏任务中的预约任务,且不能下载情况下
+                        Action1<Integer> action1 = type -> {
+                            switch (type) {
+                                case 1:
+                                    Jump2View.getInstance().goGameMakeMoney(context, 1);
+                                    break;
                             }
-                            return;
+                        };
+                        if(taskReleaseEty.getAccepted_task_id() < 1){//没有正在进行的任务
+                            CommonUtil.getInstance().reservationGameTask(taskReleaseEty, action1);
+                        } else {//先取消正在进行的任务
+                            CommonUtil.getInstance().tryGiveUpTask(taskReleaseEty, action1);
                         }
-                        viewHolder.itemView.performClick();
+                        return;
+                    }
+                    viewHolder.itemView.performClick();
 //                        taskEty.setRunTask(0);
 //                        taskEty.setRelease_task_id(taskReleaseEty.getId());
 //                        taskEty.setName(taskReleaseEty.getName());
 //                        taskEty.setAcceptedTaskId(taskReleaseEty.getAccepted_task_id());
 //                        Jump2View.getInstance().goDialogActivityView(context, taskEty);
-                    }
                 });
                 viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                     @Override

+ 6 - 6
app/src/main/java/com/sheep/gamegroup/view/adapter/WelfareAdapter.java

@@ -7,13 +7,13 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
-import com.sheep.gamegroup.util.DownloadUtil;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.model.entity.Release_task;
+import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DeviceUtil;
+import com.sheep.gamegroup.util.DownloadUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.UMConfigUtils;
@@ -28,8 +28,8 @@ import com.sheep.jiuyan.samllsheep.utils.G;
 import java.util.List;
 
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
 
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.RECEIVE_AWARD_GAME_TASK;
 import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
@@ -104,14 +104,14 @@ public class WelfareAdapter extends AdbCommonRecycler<Release_task>{
                     item_download_welfare_money.setVisibility(View.VISIBLE);
                     item_download_welfare_btn_top.setVisibility(View.INVISIBLE);
                     item_download_welfare_btn_bottom.setEnabled(true);
-                    item.getDownloadHelper().updateDownloadTaskView((Activity) context, itemTask, item_download_welfare_btn_bottom);
+                    item.getDownloadHelper().updateDownloadTaskView(true, itemTask, item_download_welfare_btn_bottom);
                     if(item.getDownloadHelper().getDownLoadType() == DownloadUtil.STATUS_INSTALLED){//已经安装的话
                         item_download_welfare_btn_bottom.setText("领取奖励");
                         item_download_welfare_btn_bottom.setOnClickListener(new View.OnClickListener() {
                             @Override
                             public void onClick(View view) {
                                 if (itemTask.isGameReservationCantDownload()) {
-                                    CommonUtil.getInstance().reservationGameTask(context, item, new Action1<Integer>() {
+                                    CommonUtil.getInstance().reservationGameTask(item, new Action1<Integer>() {
                                         @Override
                                         public void call(Integer integer) {
                                             if(action1 != null)
@@ -129,7 +129,7 @@ public class WelfareAdapter extends AdbCommonRecycler<Release_task>{
                     ViewUtil.setH5Text(item_download_welfare_num_tv, item.getH5BonusText());
                     item_download_welfare_money.setVisibility(View.INVISIBLE);
                     item_download_welfare_btn_top.setVisibility(View.VISIBLE);
-                    item.getDownloadHelper().updateDownloadTaskView((Activity) context, itemTask, item_download_welfare_btn_bottom);
+                    item.getDownloadHelper().updateDownloadTaskView(true, itemTask, item_download_welfare_btn_bottom);
                     if(item.getDownloadHelper().getDownLoadType() == DownloadUtil.STATUS_INSTALLED) {//已经安装的话
                         item_download_welfare_btn_bottom.setText("启动");
                     }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/dialog/DialogGameOrTaskOrGift.java

@@ -170,7 +170,7 @@ public class DialogGameOrTaskOrGift {
                 GlideImageLoader.setGameImage(dialog_iv, commendApp.getApp().getIcon());
                 ViewUtil.setText(dialog_name_tv, commendApp.getApp().getName());
                 ViewUtil.setText(dialog_gift_tv, commendApp.getApp().getManufacturer());//这里显示的是开发商名字
-                commendApp.getApp().getFindAppHelper().getDownloadHelper().updateDownloadTaskView(activity, commendApp.getApp(), dialog_btn_right);
+                commendApp.getApp().getFindAppHelper().getDownloadHelper().updateDownloadTaskView(true, commendApp.getApp(), dialog_btn_right);
                 dialog_btn_right.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + commendApp.getApp().getDownload_url());
                 if(activity instanceof ActMain){
                     ((ActMain) activity).setDownloadHelper(commendApp.getApp().getFindAppHelper().getDownloadHelper());

+ 3 - 2
app/src/main/java/com/sheep/gamegroup/view/fragment/BaseListFragment6.java

@@ -175,8 +175,9 @@ public abstract class BaseListFragment6<T> extends BaseFragment implements IRefr
     }
 
     public void notifyDataSetChanged(int page, boolean hasMore) {
-        if (recyclerView == null)
-            recyclerView = findViewById(R.id.recyclerView);
+        if (recyclerView == null){
+            return;
+        }
         ListUtil.forEach(apiRefreshList, apiRefresh -> apiRefresh.setLoadMore(false));
         ViewUtil.notifyDataSetChanged(recyclerView);
         if (hasMore) {

+ 4 - 4
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtArticleComment.java

@@ -267,7 +267,7 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> implements
             ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "厂商:%s\u0020包体大小:%sM", findApp.getManufacturer(), findApp.getPackage_size()));
         find_information_game_task_center.setVisibility(View.VISIBLE);
 
-        updateView(activity, findApp, find_information_game_task_center);
+        updateView(findApp, find_information_game_task_center);
 
         itemView.setOnClickListener(view -> Jump2View.getInstance().goFindGame(article));
     }
@@ -374,13 +374,13 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> implements
     }
 
     //更新按钮状态与添加点击事件
-    private void updateView(Activity activity, Applications findApp, TextView textView) {
+    private void updateView(Applications findApp, TextView textView) {
         if (findApp.isCanDownload()) {//可下载
             downLoadTextViewMap.put(findApp.getDownload_link(), textView);
             downLoadTextViewMap.put(findApp.getPackage_name(), textView);
-            findApp.getFindAppHelper().updateDownloadTaskView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, textView);
         } else {//预约下载
-            findApp.getFindAppHelper().updateReservationView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateReservationView(true, findApp, textView);
         }
     }
 

+ 4 - 4
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtFindChild.java

@@ -150,15 +150,15 @@ public class FgtFindChild extends BaseListFragment5<Article> {
     }
 
     //更新按钮状态与添加点击事件
-    private void updateView(Activity activity, Applications findApp, TextView textView) {
+    private void updateView(Applications findApp, TextView textView) {
         if (findApp.isCanDownload()) {//可下载
             downLoadTextViewMap.put(findApp.getDownload_link(), textView);
             downLoadTextViewMap.put(findApp.getPackage_name(), textView);
             findAppMap.put(findApp.getDownload_link(), findApp);
             findAppMap.put(findApp.getPackage_name(), findApp);
-            findApp.getFindAppHelper().updateDownloadTaskView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, textView);
         } else {//预约下载
-            findApp.getFindAppHelper().updateReservationView(activity, findApp, textView);
+            findApp.getFindAppHelper().updateReservationView(true, findApp, textView);
         }
     }
 
@@ -369,7 +369,7 @@ public class FgtFindChild extends BaseListFragment5<Article> {
             if (item.isGame()) {
                 find_item_download.setVisibility(View.VISIBLE);
                 Applications findApp = item.getApplication();
-                updateView(activity, findApp, find_item_download);
+                updateView(findApp, find_item_download);
             } else {
                 find_item_download.setVisibility(View.GONE);
             }

+ 21 - 27
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPlaGameGift.java

@@ -43,7 +43,7 @@ public class FgtPlaGameGift extends BaseFragment {
     private List<GiftBagApp> has_gift_bag = new ArrayList<>();
     private List<Object> objectList = new ArrayList<>();
 
-    public static FgtPlaGameGift newInstance(GameEntity gameEntity){
+    public static FgtPlaGameGift newInstance(GameEntity gameEntity) {
         FgtPlaGameGift fgt = new FgtPlaGameGift();
         Bundle bundle = new Bundle();
         DataUtil.putObject(bundle, gameEntity);
@@ -58,12 +58,12 @@ public class FgtPlaGameGift extends BaseFragment {
 
     @Override
     public void onViewCreated() {
-        if(gameEntity == null)
+        if (gameEntity == null)
             return;
         has_gift_bag.clear();
         has_gift_bag.addAll(gameEntity.getHas_gift_bag());
         objectList.clear();
-        if(!TextUtils.isEmpty(gameEntity.getBonusText()) && gameEntity.getRelease_task() != null)
+        if (!TextUtils.isEmpty(gameEntity.getBonusText()) && gameEntity.getRelease_task() != null)
             objectList.add(gameEntity.getRelease_task());
         objectList.addAll(gameEntity.getHas_gift_bag());
 
@@ -77,14 +77,14 @@ public class FgtPlaGameGift extends BaseFragment {
 
             @Override
             public void convert(ViewHolder holder, final Object giftBagApp) {
-                if (giftBagApp instanceof GiftBagApp){
+                if (giftBagApp instanceof GiftBagApp) {
                     bindGfitData(holder, (GiftBagApp) giftBagApp);
-                }else if(giftBagApp instanceof Release_task){
+                } else if (giftBagApp instanceof Release_task) {
                     bindReleaseData(holder, (Release_task) giftBagApp);
                 }
             }
 
-            private void bindGfitData(ViewHolder holder, final GiftBagApp giftBagApp){
+            private void bindGfitData(ViewHolder holder, final GiftBagApp giftBagApp) {
 
                 View view = holder.itemView;
                 ViewUtil.setText((TextView) holder.getView(R.id.name_tv), giftBagApp.getGift_bag().getGiftName());
@@ -92,7 +92,7 @@ public class FgtPlaGameGift extends BaseFragment {
 
                 final TextView btn_tv = holder.getView(R.id.btn_tv);
 
-                if (!giftBagApp.isReceived()){
+                if (!giftBagApp.isReceived()) {
                     btn_tv.setText("领取");
                     btn_tv.setEnabled(true);
                     btn_tv.setTextColor(activity.getResources().getColor(R.color.txt_bule));
@@ -100,7 +100,7 @@ public class FgtPlaGameGift extends BaseFragment {
                     btn_tv.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            if(CommonUtil.getInstance().isInstallApp(gameEntity.getApp().getPackage_name(), gameEntity.getApp().getName())){
+                            if (CommonUtil.getInstance().isInstallApp(gameEntity.getApp().getPackage_name(), gameEntity.getApp().getName())) {
                                 CommonUtil.getInstance().receiveGiftById(activity, giftBagApp, new Action1<Integer>() {
                                     @Override
                                     public void call(Integer integer) {
@@ -109,12 +109,12 @@ public class FgtPlaGameGift extends BaseFragment {
                                         btn_tv.setEnabled(false);
                                         notifyDataSetChanged();
                                     }
-                                },gameEntity.getApp().getPackage_name());
+                                }, gameEntity.getApp().getPackage_name());
                             }
 
                         }
                     });
-                }else {
+                } else {
                     btn_tv.setText("已领取");
                     btn_tv.setEnabled(false);
                     btn_tv.setTextColor(activity.getResources().getColor(R.color.time_created));
@@ -123,7 +123,7 @@ public class FgtPlaGameGift extends BaseFragment {
                 holder.getView(R.id.line_tv).setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
             }
 
-            private void bindReleaseData(ViewHolder holder, final Release_task giftBagApp){
+            private void bindReleaseData(ViewHolder holder, final Release_task giftBagApp) {
 
                 View view = holder.itemView;
                 ViewUtil.setText((TextView) holder.getView(R.id.name_tv), giftBagApp.getName());
@@ -131,30 +131,24 @@ public class FgtPlaGameGift extends BaseFragment {
 
                 final TextView btn_tv = holder.getView(R.id.btn_tv);
 
-                if (!gameEntity.getReceived_voucher()){
+                if (!gameEntity.getReceived_voucher()) {
                     btn_tv.setText("领取");
                     btn_tv.setEnabled(true);
 
                     btn_tv.setTextColor(activity.getResources().getColor(R.color.txt_bule));
                     btn_tv.setBackgroundResource(R.drawable.shape_blue_stroke_rectangle);
-                    btn_tv.setOnClickListener(new View.OnClickListener() {
-                        @Override
-                        public void onClick(View v) {
-                            if(CommonUtil.getInstance().isInstallApp(giftBagApp.getTask().getPackage_names(), giftBagApp.getName())){
-                                CommonUtil.getInstance().receiveAward(activity, gameEntity, new Action1<Integer>() {
-                                    @Override
-                                    public void call(Integer integer) {
-                                        gameEntity.setReceived_voucher(true);
-                                        btn_tv.setText("已领取");
-                                        btn_tv.setEnabled(false);
-                                        notifyDataSetChanged();
-                                    }
-                                });
+                    btn_tv.setOnClickListener(v -> {
+                        if (CommonUtil.getInstance().isInstallApp(giftBagApp.getTask().getPackage_names(), giftBagApp.getName())) {
+                            CommonUtil.getInstance().receiveAward(gameEntity, integer -> {
+                                gameEntity.setReceived_voucher(true);
+                                btn_tv.setText("已领取");
+                                btn_tv.setEnabled(false);
+                                notifyDataSetChanged();
+                            });
 
-                            }
                         }
                     });
-                }else {
+                } else {
                     btn_tv.setText("已领取");
                     btn_tv.setEnabled(false);
                     btn_tv.setTextColor(activity.getResources().getColor(R.color.time_created));

+ 5 - 4
app/src/main/java/com/sheep/jiuyan/samllsheep/service/DownloadService.java

@@ -20,7 +20,6 @@ import com.kfzs.duanduan.view.DialogStorageLow;
 import com.liulishuo.okdownload.DownloadListener;
 import com.liulishuo.okdownload.DownloadTask;
 import com.liulishuo.okdownload.SpeedCalculator;
-import com.liulishuo.okdownload.core.Util;
 import com.liulishuo.okdownload.core.breakpoint.BlockInfo;
 import com.liulishuo.okdownload.core.breakpoint.BreakpointInfo;
 import com.liulishuo.okdownload.core.cause.EndCause;
@@ -152,7 +151,6 @@ public class DownloadService extends Service {
             if (realCause != null) {
                 realCause.printStackTrace();
             }
-            new Exception("Download exception: ").printStackTrace();
             DownLoadInfo downLoadInfo;
             switch (cause) {
                 case COMPLETED://下载完成
@@ -184,12 +182,15 @@ public class DownloadService extends Service {
                         if (realCause != null)
                             downLoadInfo.setRealCauseMsg(realCause.getMessage());
                         DDProviderHelper.getInstance().updateDownload(downLoadInfo);
-                        EventBus.getDefault().post(new BigEvent().setEventTypes(EventTypes.DOWNLOAD_FAIL).setData(downLoadInfo));
                     }
                     int retry = (int) task.getTag(TAG_RETRY);
-                    if (retry < 15) {
+                    if (retry < 15 && task.getFile() != null) {
                         startDownload(task.getUrl(), task.getFile().getAbsolutePath(), ++retry);
                         Log.e("DownloadRetry", "Retry " + retry + "   " + task.getUrl());
+                    } else {
+                        if (downLoadInfo != null) {
+                            EventBus.getDefault().post(new BigEvent().setEventTypes(EventTypes.DOWNLOAD_FAIL).setData(downLoadInfo));
+                        }
                     }
                     break;
                 case CANCELED://取消下载