|
|
@@ -16,6 +16,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.arialyy.annotations.Download;
|
|
|
import com.arialyy.aria.core.Aria;
|
|
|
@@ -32,12 +33,14 @@ import com.kfzs.duanduan.utils.ApkUtils;
|
|
|
import com.sheep.gamegroup.absBase.AbsChooseImageActivity;
|
|
|
import com.sheep.gamegroup.di.components.DaggerTaskDetailComponent;
|
|
|
import com.sheep.gamegroup.di.modules.TaskDetailModule;
|
|
|
+import com.sheep.gamegroup.model.entity.AppRecord;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.DialogEntity;
|
|
|
import com.sheep.gamegroup.model.entity.Ext;
|
|
|
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
|
|
|
import com.sheep.gamegroup.model.entity.TaskChild;
|
|
|
import com.sheep.gamegroup.model.entity.TaskEty;
|
|
|
+import com.sheep.gamegroup.model.entity.TaskListen;
|
|
|
import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
import com.sheep.gamegroup.model.util.EntityUtils;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
@@ -46,10 +49,14 @@ import com.sheep.gamegroup.presenter.TaskDetailPresenter;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DeviceUtil;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.LocationUtils;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.MyListview;
|
|
|
import com.sheep.gamegroup.util.TimeUtil;
|
|
|
import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
import com.sheep.gamegroup.view.adapter.AdpTaskDetailChildListview;
|
|
|
+import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
@@ -62,6 +69,7 @@ import org.greenrobot.eventbus.EventBus;
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
@@ -258,7 +266,10 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
- if (type >= 3 && taskEty.getInspect_type() != 3) {
|
|
|
+ if(taskEty.getInspect_type() == 3){//应用自动审核任务
|
|
|
+ btnUpImag.setText("领取奖励");
|
|
|
+ }
|
|
|
+ if (type >= 3) {
|
|
|
|
|
|
btnUpImag.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
|
@@ -479,8 +490,16 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
|
|
|
}
|
|
|
break;
|
|
|
case R.id.btn_up_imag:
|
|
|
- showChooseDialog(false, true, DEFAULT_MAX_COUNT);
|
|
|
- UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_UPLOAD_PICTURE);
|
|
|
+ if(taskEty.getInspect_type() == 3) {//应用自动审核任务
|
|
|
+ try {
|
|
|
+ checkAndCommitTask();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showChooseDialog(false, true, DEFAULT_MAX_COUNT);
|
|
|
+ UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_UPLOAD_PICTURE);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
} catch (Exception ignore) {
|
|
|
@@ -489,6 +508,58 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 尝试提交应用自动审核任务
|
|
|
+ */
|
|
|
+ private void checkAndCommitTask() {
|
|
|
+ TaskListen taskEty = SheepApp.getInstance().getTaskEty();
|
|
|
+ if(taskEty != null) {
|
|
|
+ if(TextUtils.isEmpty(taskEty.getPackage_names())){
|
|
|
+ G.showToast(R.string.error_package_link);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String gps = LocationUtils.getInstance().getLongitudeLatitude(getApplicationContext());
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("gps", gps);
|
|
|
+ long runTime = MyDbManager.getInstance().getAppRunTime(taskEty.getPackage_names());
|
|
|
+
|
|
|
+ AppRecord lastAppRecord = SheepApp.getInstance().getLastAppRecord();
|
|
|
+ if(lastAppRecord != null && TextUtils.equals(taskEty.getPackage_names(), lastAppRecord.getPackageName())){
|
|
|
+ runTime += System.currentTimeMillis() - SheepApp.getInstance().getLastTime();
|
|
|
+ SheepApp.getInstance().setLastTime(System.currentTimeMillis());
|
|
|
+ }
|
|
|
+ if(runTime <= 0){//时间小于等于0则不提交
|
|
|
+ G.showToast("该任务时长未达到,请继续去体验应用哦!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ MyDbManager.getInstance().removeAppRecord();
|
|
|
+ LogUtil.println("MonitorAppService runTime = "+runTime);
|
|
|
+ object.put("task_time", runTime/1000);
|
|
|
+ object.put("release_task_id", taskEty.getRelease_task_id());
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().commitAutoTask(object)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(getApplicationContext()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ LogUtil.println("MonitorAppService baseMessage onNext "+ JSON.toJSONString(baseMessage));
|
|
|
+ CommonUtil.getInstance().setTAskEnty(null);
|
|
|
+ G.showToast(String.format(Locale.CHINA, "恭喜你,任务已完成,获得奖励%s元", taskReleaseEty.getBonus()));
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ LogUtil.println("MonitorAppService baseMessage onError "+JSON.toJSONString(baseMessage));
|
|
|
+ G.showToast("该任务时长未达到,请继续去体验应用哦!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ G.showToast(R.string.unknown_error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 任务进度
|
|
|
*/
|
|
|
private void taskSchedule() {
|