Ver código fonte

发现游戏详情中图片列表修改

zengjiebin 7 anos atrás
pai
commit
8a361f032e

+ 134 - 0
app/src/main/java/com/sheep/gamegroup/heler/DownloadHelper.java

@@ -0,0 +1,134 @@
+package com.sheep.gamegroup.heler;
+
+import android.app.Activity;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.TextView;
+
+import com.arialyy.aria.core.Aria;
+import com.arialyy.aria.core.download.DownloadTarget;
+import com.arialyy.aria.core.inf.IEntity;
+import com.kfzs.duanduan.datashare.provider.download.DownLoadInfo;
+import com.kfzs.duanduan.event.BigEvent;
+import com.kfzs.duanduan.event.EventTypes;
+import com.kfzs.duanduan.services.DownloadTaskService;
+import com.kfzs.duanduan.utils.ApkUtils;
+import com.sheep.gamegroup.model.api.IDownload;
+import com.sheep.gamegroup.view.activity.TaskDetailAct;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
+
+import org.greenrobot.eventbus.EventBus;
+
+import rx.functions.Action1;
+
+/**
+ * Created by realicing on 2018/7/3.
+ * realicing@sina.com
+ * 下载游戏辅助类
+ */
+public class DownloadHelper {
+    private int downLoadType;
+    /**
+     * 更新游戏下载与响应点击
+     * @param activity
+     * @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(final Activity activity, final IDownload iTask, final TextView down_tv, final Action1<Integer> callBack) {
+        if(mDownloadTaskService == null){
+            mDownloadTaskService = new DownloadTaskService(activity);
+        }
+        TaskDetailAct.setBtnStr(iTask, mDownloadTaskService, new Action1<Object>() {
+            @Override
+            public void call(Object o) {
+                if(o instanceof Integer){
+                    downLoadType = (int) o;
+                    if(callBack != null)
+                        callBack.call(downLoadType);
+                } else if( o instanceof String){
+                    down_tv.setText((String) o);
+                } else if( o instanceof Boolean){
+                    down_tv.setEnabled((Boolean) o);
+                }
+            }
+        });
+        down_tv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if(callBack != null)
+                    callBack.call(-1);
+                downloadApp(activity, iTask);
+            }
+        });
+    }
+
+    private DownloadTaskService mDownloadTaskService;
+    private DownloadTarget downloadTarget;
+    //下载应用
+    private void downloadApp(Activity activity, IDownload task) {
+        switch (downLoadType){
+            case DownloadTaskService.STATUS_INIT://可以下载
+                if(TextUtils.isEmpty(task.getDownload_link()) || !task.getDownload_link().contains("http")){
+                    G.showToast(R.string.error_download_link);
+                    return;
+                }
+                this.downloadTarget = Aria.download(activity).load(task.getDownload_link());
+                final DownLoadInfo downLoadInfo = mDownloadTaskService.getDownloadTaskByUrl(task);
+                if(this.downloadTarget != null) {
+                    if (this.downloadTarget.getTaskState() == IEntity.STATE_RUNNING) {
+                        this.downloadTarget.stop();
+                    } else if (this.downloadTarget.getTaskState() == IEntity.STATE_FAIL) {
+                        this.downloadTarget.cancel(true);
+                        this.downloadTarget.removeRecord();
+                    } else {
+                        mDownloadTaskService.start(downLoadInfo);
+                    }
+                    new Thread(new Runnable() {
+                        @Override
+                        public void run() {
+                            if(mDownloadTaskService.addDownloadTask(downLoadInfo)){//添加数据到数据库,可以在下载管理中看到
+                                //发送红点信息
+                                EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.TIPS_DOWN_ICON));
+                            }
+                        }
+                    }).start();
+                }
+                break;
+            case DownloadTaskService.STATUS_FINISH://已经下载完成,可以安装
+                String path = PackageUtil.isExistsFile(task.getPackage_names());
+                if(TextUtils.isEmpty(path)){//数据库保存有下载完成的状态,但是应用已经被删除,需要修复其下载状态
+                    if(TextUtils.isEmpty(task.getDownload_link()) || !task.getDownload_link().contains("http")){
+                        G.showToast(R.string.error_download_link);
+                        return;
+                    }
+                    this.downloadTarget = Aria.download(activity).load(task.getDownload_link());
+                    if(this.downloadTarget != null) {
+                        this.downloadTarget.cancel(true);
+                        this.downloadTarget.removeRecord();
+                        mDownloadTaskService.start(mDownloadTaskService.getDownloadTaskByUrl(task));
+                        mDownloadTaskService.setDownloadTaskStatus(task.getDownload_link(), DownloadTaskService.STATUS_INIT);
+                        downLoadType = DownloadTaskService.STATUS_INIT;
+                    }
+                } else {
+                    ApkUtils.installApk(activity, PackageUtil.isExistsFile(task.getPackage_names()));
+                }
+                break;
+            case DownloadTaskService.STATUS_INSTALLED://已经安装,可以试玩
+                PackageUtil.startApp(activity, task.getPackage_names());
+                break;
+        }
+    }
+
+    /**
+     * 更新下载状态
+     * @param status
+     */
+    public void updateState(int status) {
+        downLoadType = status;
+    }
+}

+ 114 - 0
app/src/main/java/com/sheep/gamegroup/heler/FindAppHelper.java

@@ -0,0 +1,114 @@
+package com.sheep.gamegroup.heler;
+
+import android.app.Activity;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.kfzs.duanduan.services.DownloadTaskService;
+import com.sheep.gamegroup.model.api.IDownload;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.DialogConfig;
+import com.sheep.gamegroup.model.entity.FindApp;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.TimeUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import java.util.Locale;
+
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_APP;
+
+/**
+ * Created by realicing on 2018/6/29.
+ * realicing@sina.com
+ */
+public class FindAppHelper{
+    private DownloadHelper downloadHelper = new DownloadHelper();
+
+    public void updateState(int status) {
+        downloadHelper.updateState(status);
+    }
+    public void updateDownloadTaskView(final Activity activity, final IDownload iTask, final TextView down_tv) {
+        downloadHelper.updateDownloadTaskView(activity, iTask, down_tv, new Action1<Integer>() {
+            @Override
+            public void call(Integer integer) {
+                if(DownloadTaskService.STATUS_INIT != integer){//-1 点击下载按钮的回调;其它状态直接回调不需要点击按钮
+                    if(iTask instanceof FindApp) {
+                        FindApp findApp = (FindApp) iTask;
+                        recordAppDownloads(activity, findApp, down_tv);
+                        FIND_APP.onEvent("application_id", findApp.getId(), "action", down_tv.getText());
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * 更新预约下载状态与响应点击
+     * @param activity
+     * @param findApp
+     * @param reservation_tv
+     */
+    public void updateReservationView(final Activity activity, final FindApp findApp, final TextView reservation_tv) {
+        if(findApp.isCanRecord()) {
+            reservation_tv.setEnabled(true);
+            reservation_tv.setText("预约下载");
+            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);
+                }
+            });
+        } else {
+            reservation_tv.setEnabled(false);
+            reservation_tv.setText("已经预约");
+        }
+    }
+
+
+    /**
+     * 点击预约下载与立即下载时,需要调用这个接口记录到服务器
+     * @param findApp
+     */
+    private void recordAppDownloads(final Activity activity, final FindApp 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) {
+                        LogUtil.println("baseMessage onNext "+ JSON.toJSONString(baseMessage));
+                        findApp.setRecord(2);//设置为不可记录
+                        if(findApp.isCanDonload()){
+                            //提交下载成功
+                            textView.setEnabled(true);
+                        } else {//提交预约成功
+                            textView.setEnabled(false);
+                            textView.setText("已经预约");
+                            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("我知道了"));
+                        }
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                        if(!findApp.isCanDonload()){
+                            G.showToast("预约失败");
+                        }
+                        textView.setEnabled(true);
+                    }
+                });
+    }
+}

+ 360 - 0
app/src/main/java/com/sheep/gamegroup/heler/TaskHelper.java

@@ -0,0 +1,360 @@
+package com.sheep.gamegroup.heler;
+
+import android.app.Activity;
+import android.text.TextUtils;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.OrienteeringDetail;
+import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
+import com.sheep.gamegroup.model.entity.TaskEty;
+import com.sheep.gamegroup.model.entity.TaskReleaseEty;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.RxjavaCountDownTimer;
+import com.sheep.gamegroup.util.TimeUtil;
+import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import java.util.Locale;
+
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_TASK;
+
+/**
+ * Created by realicing on 2018/7/3.
+ * realicing@sina.com
+ */
+public class TaskHelper {
+    private Action1<Integer> action1;
+    public TaskHelper(Action1<Integer> action1){
+        this.action1 = action1;
+    }
+
+    private TaskAcceptedEty taskAcceptedEty;
+    private int release_task_id;
+    private Activity activity;
+    public void initAcceptedTask(Activity activity, final int release_task_id) {
+        this.activity = activity;
+        this.release_task_id = release_task_id;
+        SheepApp.getInstance().getNetComponent().getApiService().getAcceptedTaskDetail(release_task_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onNext "+ JSON.toJSONString(baseMessage));
+                        taskAcceptedEty = baseMessage.getData(TaskAcceptedEty.class);
+                        initTask(release_task_id);
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                        initTask(release_task_id);
+                    }
+                });
+    }
+    private TaskReleaseEty taskReleaseEty;
+    private void initTask(int release_task_id) {
+        SheepApp.getInstance().getNetComponent().getApiService().taskDesc(release_task_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
+                        taskReleaseEty = baseMessage.getData(TaskReleaseEty.class);
+                        if(action1 != null)
+                            action1.call(1);//刷新界面
+
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                    }
+                });
+    }
+    private OrienteeringDetail orienteeringDetail;
+    private void initGameTask(final View itemView, String third_task_id) {
+        SheepApp.getInstance().getNetComponent().getApiService().getMyGame(third_task_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
+                        orienteeringDetail = baseMessage.getData(OrienteeringDetail.class);
+                        loadTask(itemView);
+
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                    }
+                });
+    }
+
+    public boolean hasTask() {
+        return taskReleaseEty != null && taskReleaseEty.getTask() != null;
+    }
+
+    private RxjavaCountDownTimer timer;
+    public void loadTask(final View itemView) {
+        itemView.setVisibility(View.VISIBLE);
+        if(taskReleaseEty == null){
+            return;
+        }
+        final TaskEty taskEty = taskReleaseEty.getTask();
+        if(taskEty == null){
+            return;
+        }
+        ImageView find_information_game_icon = (ImageView)itemView.findViewById(R.id.find_information_game_icon);
+        TextView find_information_game_name = (TextView)itemView.findViewById(R.id.find_information_game_name);
+        TextView find_information_game_surplus = (TextView)itemView.findViewById(R.id.find_information_game_surplus);
+        TextView find_information_game_time = (TextView)itemView.findViewById(R.id.find_information_game_time);
+        TextView find_information_game_yuan = (TextView)itemView.findViewById(R.id.find_information_game_yuan);
+        TextView find_information_game_task0 = (TextView)itemView.findViewById(R.id.find_information_game_task0);
+        TextView find_information_game_task = (TextView)itemView.findViewById(R.id.find_information_game_task);
+        final TextView find_information_game_task_end_time = (TextView)itemView.findViewById(R.id.find_information_game_task_end_time);
+        if(orienteeringDetail != null){//已经完成的游戏任务
+            find_information_game_task.setVisibility(View.VISIBLE);
+            find_information_game_task0.setVisibility(View.VISIBLE);
+            find_information_game_yuan.setVisibility(View.INVISIBLE);
+            find_information_game_surplus.setText(String.format(Locale.CHINA, "可定向消费:%.1f元", orienteeringDetail.getBalance()));
+            find_information_game_surplus.setTextColor(activity.getResources().getColor(R.color.red_fd2d54));
+            find_information_game_task.setText("去充值");
+            find_information_game_task.setEnabled(true);
+            downloadHelper.updateDownloadTaskView(activity, taskEty, find_information_game_task0);
+            find_information_game_task.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    ViewUtil.showGamePayAccount(activity, orienteeringDetail.getGame_id());
+                }
+            });
+            itemView.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    reloadDataType = 1;//回来后将刷新界面数据 taskAcceptedEty
+                    Jump2View.getInstance().goGameTaskDetailView(activity,  release_task_id, orienteeringDetail.getGame_id(),1);
+                    UMConfigUtils.IdEvent.TASK.commit(release_task_id);
+                }
+            });
+            return;
+        }
+        GlideImageLoader.centerImage(find_information_game_icon, taskEty.getIcon());
+        ViewUtil.setText(find_information_game_name, taskReleaseEty.getName());
+        ViewUtil.setText(find_information_game_surplus, String.format(Locale.CHINA, "剩余%s份", taskReleaseEty.getLast_num()));
+        ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "截止日期:%s", taskReleaseEty.getDeadline().equals("永久") ? taskReleaseEty.getDeadline() : TimeUtil.TimeStamp2Date(NumberFormatUtils.parseLong(taskReleaseEty.getDeadline()), "yyyy/MM/dd HH:mm")));
+        ViewUtil.setText(find_information_game_yuan, String.format(Locale.CHINA, "+%s元", taskReleaseEty.getBonus()));
+        find_information_game_task0.setVisibility(View.GONE);
+        find_information_game_yuan.setVisibility(View.VISIBLE);
+        switch (taskEty.getTask_type()) {// 1时间试玩任务 2 信用卡任务 3应用下载 4h5业务 1001畅思 1000连续任务, 1002 1003游戏任务
+            case 2://信用卡任务
+                find_information_game_task.setVisibility(View.GONE);
+                find_information_game_task_end_time.setVisibility(View.GONE);
+                find_information_game_yuan.setGravity(Gravity.END);
+                String[] remarks = new String[0];
+                if(!TextUtils.isEmpty(taskEty.getRemarks())) {
+                    remarks = taskEty.getRemarks().split(";");
+                }
+                find_information_game_time.setText(remarks.length > 0 ? remarks[0] : "");
+                find_information_game_surplus.setText(remarks.length > 1 ? remarks[1] : "");
+                itemView.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        Jump2View.getInstance().goCreditCardTaskDetail(activity, taskReleaseEty.getId());
+                    }
+                });
+                break;
+            case 1001:
+                break;
+            case 1://时间试玩任务
+            case 3://应用下载
+            case 4://h5业务
+            case 1000://连续任务
+            case 1002://游戏任务
+            case 1003://游戏任务
+            default:
+                find_information_game_yuan.setGravity(Gravity.CENTER);
+                if(taskAcceptedEty != null){
+                    switch (taskAcceptedEty.getStatus()) {
+                        case 1://"已接受任务";
+                        case 2:// "正在进行中";
+                            if(taskReleaseEty.getDeadline().equals("永久")){
+                                find_information_game_task_end_time.setVisibility(View.GONE);
+                            } else {
+                                find_information_game_task_end_time.setVisibility(View.VISIBLE);
+                                find_information_game_task_end_time.setText(TimeUtil.getHours(taskAcceptedEty.getEnd_time() * 1000));
+                                timer = RxjavaCountDownTimer.getInstance(taskAcceptedEty.getEnd_time())
+                                        .setOnTickListener(new RxjavaCountDownTimer.OnTickListener() {
+                                            @Override
+                                            public void onFinish() {
+                                                find_information_game_task_end_time.setVisibility(View.GONE);
+                                                refreshTask();
+                                            }
+
+                                            @Override
+                                            public void onTicker(long time) {
+                                                find_information_game_task_end_time.setText(TimeUtil.getHours(time * 1000));
+                                            }
+                                        }).start();
+                            }
+                            find_information_game_task.setText("取消任务");
+                            find_information_game_task.setEnabled(true);
+                            find_information_game_task.setOnClickListener(new View.OnClickListener() {
+                                @Override
+                                public void onClick(View view) {
+                                    FIND_TASK.onEvent("release_task_id", release_task_id, "action", "取消任务");
+                                    SheepApp.getInstance().getNetComponent().getApiService().giveUpTask(taskAcceptedEty.getId())
+                                            .subscribeOn(Schedulers.io())
+                                            .observeOn(AndroidSchedulers.mainThread())
+                                            .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                                                @Override
+                                                public void onNext(BaseMessage baseMessage) {
+                                                    LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
+                                                    refreshTask();
+                                                }
+
+                                                @Override
+                                                public void onError(BaseMessage baseMessage) {
+                                                    LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                                                    G.showToast(baseMessage);
+                                                }
+                                            });
+                                    //暂停下载
+                                    CommonUtil.getInstance().stopDownloadTask(activity, taskEty.getDownload_link());
+                                }
+                            });
+                            break;
+                        case 6://审核失败
+                            find_information_game_task_end_time.setVisibility(View.GONE);
+                            find_information_game_task.setVisibility(View.VISIBLE);
+                            find_information_game_task.setText("审核失败");
+                            find_information_game_task.setEnabled(false);
+                            break;
+                        //不可操作
+                        case 7:// "提交审核";
+                            find_information_game_task_end_time.setVisibility(View.GONE);
+                            find_information_game_task.setVisibility(View.VISIBLE);
+                            find_information_game_task.setText("正在审核");
+                            find_information_game_task.setEnabled(false);
+                            break;
+                        case 3://完成任务
+                            find_information_game_task_end_time.setVisibility(View.GONE);
+                            find_information_game_task.setVisibility(View.VISIBLE);
+                            find_information_game_task.setText("已经完成");
+                            find_information_game_task.setEnabled(false);
+                            if(taskEty.isGameTask()){
+                                initGameTask(itemView, taskEty.getThird_task_id());
+                            }
+                            break;
+                        case 8://任务已经下线
+                            find_information_game_task_end_time.setVisibility(View.GONE);
+                            find_information_game_task.setVisibility(View.VISIBLE);
+                            find_information_game_task.setText("已经下线");
+                            find_information_game_task.setEnabled(false);
+                            break;
+                        case 9:// "至少完成一个任务了";
+                        default:
+                            find_information_game_task_end_time.setVisibility(View.GONE);
+                            find_information_game_task.setVisibility(View.GONE);
+                            break;
+                    }
+                } else if(taskReleaseEty.isOffline()){//任务已经下线
+                    find_information_game_task_end_time.setVisibility(View.GONE);
+                    find_information_game_task.setVisibility(View.VISIBLE);
+                    find_information_game_task.setText("已经下线");
+                    find_information_game_task.setEnabled(false);
+                } else if("0".equals(taskReleaseEty.getLast_num())){
+                    find_information_game_task_end_time.setVisibility(View.GONE);
+                    find_information_game_task.setVisibility(View.VISIBLE);
+                    find_information_game_task.setText("任务已抢光");
+                    find_information_game_task.setEnabled(false);
+                } else {
+                    find_information_game_task_end_time.setVisibility(View.GONE);
+                    find_information_game_task.setVisibility(View.VISIBLE);
+                    find_information_game_task.setText("领取任务");
+                    find_information_game_task.setEnabled(true);
+                    find_information_game_task.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            taskEty.setRunTask(0);
+                            taskEty.setRelease_task_id(taskReleaseEty.getId());
+                            taskEty.setName(taskReleaseEty.getName());
+                            taskEty.setAcceptedTaskId(taskReleaseEty.getAccepted_task_id());
+                            Jump2View.getInstance().goDialogActivityView(activity, taskEty);
+                            FIND_TASK.onEvent("release_task_id", release_task_id, "action", "领取任务");
+                        }
+                    });
+                }
+                itemView.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        reloadDataType = 1;//回来后将刷新界面数据 taskAcceptedEty
+                        Jump2View.getInstance().goTaskDetailView(activity, release_task_id);
+                    }
+                });
+                break;
+        }
+    }
+
+    //刷新界面
+    public void refreshTask() {
+        clear();
+        taskAcceptedEty = null;
+        taskReleaseEty = null;
+        initAcceptedTask(activity, release_task_id);
+    }
+    private int reloadDataType;//0 不刷新数据 1刷新 taskAcceptedEty
+    public void onResume() {
+        switch (reloadDataType){
+            case 1:
+                refreshTask();
+                break;
+        }
+    }
+    /**
+     * 清理计时器
+     */
+    public void clear() {
+        if(timer != null)
+            timer.clear();
+        timer = null;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+    private DownloadHelper downloadHelper = new DownloadHelper();
+
+    public void updateState(int status) {
+        downloadHelper.updateState(status);
+    }
+
+}

+ 8 - 1
app/src/main/java/com/sheep/gamegroup/usage/AppUsageManager.java

@@ -2,6 +2,7 @@ package com.sheep.gamegroup.usage;
 
 import android.annotation.SuppressLint;
 import android.app.Activity;
+import android.app.AppOpsManager;
 import android.app.Service;
 import android.app.usage.UsageEvents;
 import android.app.usage.UsageStats;
@@ -141,7 +142,13 @@ public class AppUsageManager {
                 }
                 MyDbManager.getInstance().saveOrUpdate(appUsageList);//保存或者更新AppUsage,以便之后用来显示时间
             }
-            return isEmpty;
+            AppOpsManager appOps = (AppOpsManager) SheepApp.getInstance().getSystemService(Context.APP_OPS_SERVICE);
+            int mode = -1;
+            if(appOps != null) {
+                mode = appOps.checkOpNoThrow("android:get_usage_stats", android.os.Process.myUid(), SheepApp.getInstance().getPackageName());
+            }
+            boolean granted = mode == AppOpsManager.MODE_ALLOWED;
+            return isEmpty || granted;
         } else{
             return false;
         }

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

@@ -169,12 +169,12 @@ public class ImageGlarryDrawable<T> {
             super.handleMessage(msg);
             switch (msg.what){
                 case 1:
-                    pagerAdapter.notifyDataSetChanged();
                     if (mActivity.isFinishing() || ListUtil.size(mList) < 2) {
                         return;
                     }
                     int lastIndex = (mViewPager.getCurrentItem() + 1) % ListUtil.size(mList);
                     mViewPager.setCurrentItem(lastIndex, true);
+                    pagerAdapter.notifyDataSetChanged();
                     handler.removeMessages(1);
                     sendEmptyMessageDelayed(1, mIntDelayTime);
                     break;

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

@@ -284,7 +284,7 @@ public class TestUtil {
      * @param activity
      */
     public static void test(final Activity activity) {
-        final String[] items = {"测试代理页面","第三方应用使用情况","开启第三方应用使用情况","h5跳转","新手对话框","md5","空间不足提示框",
+        final String[] items = {"尝试开启第三方应用使用情况","测试代理页面","第三方应用使用情况","开启第三方应用使用情况","h5跳转","新手对话框","md5","空间不足提示框",
                 "显示已经安装应用列表","复制token","复制faq地址","复制代理地址","复制世界杯地址","任务游戏列表","世界杯活动","交通银行信用卡测试",
                 "浦发银行信用卡测试", "测试游戏模块","打卡成功提示","定向货币详情","进入绑定身份认证界面时的提示","提交身份认证时的提示", "检查标签",
                 "友盟分享", "了解小绵羊", "提现成功"};
@@ -297,6 +297,9 @@ public class TestUtil {
                             case "测试代理页面":
                                 Jump2View.getInstance().goWeb(activity, "http://10.8.210.172:8081/#/?authorization=123123", "代理服务");
                                 break;
+                            case "尝试开启第三方应用使用情况":
+                                AppUsageManager.getInstance().tryOpenLookAppUsageStatsPermisson(false);
+                                break;
                             case "第三方应用使用情况":
                                 AppUsageManager.getInstance().println();
                                 break;