|
|
@@ -1,5 +1,6 @@
|
|
|
package com.sheep.gamegroup.module.task.fragments;
|
|
|
|
|
|
+import android.app.Dialog;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -9,6 +10,7 @@ import com.sheep.gamegroup.model.entity.Release_task;
|
|
|
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.DeviceUtil;
|
|
|
import com.sheep.gamegroup.util.LocationUtils;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
|
@@ -32,29 +34,31 @@ public abstract class FgtVideoTaskBase extends BaseFragment {
|
|
|
protected TaskAcceptedEty acceptedTask;
|
|
|
protected int watchCount = 0;
|
|
|
|
|
|
- public FgtVideoTaskBase setReleaseTaskId(int taskId){
|
|
|
+ public FgtVideoTaskBase setReleaseTaskId(int taskId) {
|
|
|
releaseTaskId = taskId;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public FgtVideoTaskBase setReleaseTask(Release_task task){
|
|
|
+ public FgtVideoTaskBase setReleaseTask(Release_task task) {
|
|
|
releaseTask = task;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean onBackPressed(){
|
|
|
- ViewUtil.showConfirmDialog(getContext(),
|
|
|
+ public boolean onBackPressed() {
|
|
|
+ Dialog dialog = ViewUtil.showConfirmDialog(getContext(),
|
|
|
"提示",
|
|
|
"你确定要放弃奖励吗?",
|
|
|
"放弃", "继续观看",
|
|
|
d -> giveUpTask(),
|
|
|
- d -> LogUtil.logI("continue watch video")).show();
|
|
|
+ d -> LogUtil.logI("continue watch video"));
|
|
|
+ dialog.setCancelable(false);
|
|
|
+ dialog.show();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public void giveUpTask() {
|
|
|
- if(acceptedTask!=null) {
|
|
|
+ if (acceptedTask != null) {
|
|
|
SheepApp.getInstance()
|
|
|
.getNetComponent()
|
|
|
.getApiService()
|
|
|
@@ -75,12 +79,14 @@ public abstract class FgtVideoTaskBase extends BaseFragment {
|
|
|
}
|
|
|
|
|
|
protected void resubmitAutoCheck() {
|
|
|
- ViewUtil.showConfirmDialog(getContext(),
|
|
|
+ Dialog dialog = ViewUtil.showConfirmDialog(getContext(),
|
|
|
"提示",
|
|
|
"提交任务失败,需要重新提交吗?",
|
|
|
"放弃", "重试",
|
|
|
d -> giveUpTask(),
|
|
|
- d -> commitAutoTask()).show();
|
|
|
+ d -> commitAutoTask());
|
|
|
+ dialog.setCancelable(false);
|
|
|
+ dialog.show();
|
|
|
}
|
|
|
|
|
|
protected void commitAutoTask() {
|
|
|
@@ -89,7 +95,8 @@ public abstract class FgtVideoTaskBase extends BaseFragment {
|
|
|
params.put("gps", gps);
|
|
|
params.put("release_task_id", releaseTaskId);
|
|
|
params.put("create_time", System.currentTimeMillis() / 1000L);//这里添加时间戳,防止用户抓包后重复使用
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().commitAutoTask(params)
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService()
|
|
|
+ .commitAutoTask(params)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@@ -101,13 +108,14 @@ public abstract class FgtVideoTaskBase extends BaseFragment {
|
|
|
String amount = releaseTask.getBonusText();
|
|
|
try {
|
|
|
Map h = JSON.parseObject(baseMessage.getData() + "");
|
|
|
-
|
|
|
- amount = h.get("amount") + "";
|
|
|
+ amount = h.get("amount") + "元";
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- ViewUtil.showMsgDialog(getContext(), String.format(Locale.CHINA, "奖励已完成,获得奖励%s元", TextUtils.isEmpty(amount) ? releaseTask.getBonusText() : amount), "恭喜你", true);
|
|
|
+ ViewUtil.showMsgDialog(getContext(), "奖励已完成,获得奖励" +
|
|
|
+ (TextUtils.isEmpty(amount) ? releaseTask.getShowValue(DataUtil.getInstance().getUserEntity().isVIP()) : amount),
|
|
|
+ "恭喜你", true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -157,38 +165,46 @@ public abstract class FgtVideoTaskBase extends BaseFragment {
|
|
|
if (watchCount == 0) {
|
|
|
loadAd();
|
|
|
} else {
|
|
|
- ViewUtil.showConfirmDialog(getContext(),
|
|
|
+ Dialog dialog = ViewUtil.showConfirmDialog(getContext(),
|
|
|
"提示",
|
|
|
- "你需要观看" + releaseTask.getTask().getVideo_num() + "个视频, 即可获得" + releaseTask.getBonusText() + "元",
|
|
|
+ "你需要观看" + releaseTask.getTask().getVideo_num() + "个视频, 即可获得" +
|
|
|
+ releaseTask.getShowValue(DataUtil.getInstance().getUserEntity().isVIP()),
|
|
|
"放弃", "继续观看",
|
|
|
d -> giveUpTask(),
|
|
|
- d -> loadAd()).show();
|
|
|
+ d -> loadAd());
|
|
|
+ dialog.setCancelable(false);
|
|
|
+ dialog.show();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- protected void handleNext(){
|
|
|
+ protected void handleNext() {
|
|
|
watchCount++;
|
|
|
if (watchCount >= releaseTask.getTask().getVideo_num()) {
|
|
|
commitAutoTask();
|
|
|
} else {
|
|
|
- ViewUtil.showConfirmDialog(getContext(),
|
|
|
+ Dialog dialog = ViewUtil.showConfirmDialog(getContext(),
|
|
|
"提示",
|
|
|
- "你需要观看" + (releaseTask.getTask().getVideo_num() - watchCount) + "个视频, 即可获得" + releaseTask.getBonusText() + "元",
|
|
|
+ "你需要观看" + (releaseTask.getTask().getVideo_num() - watchCount) + "个视频, 即可获得" +
|
|
|
+ releaseTask.getShowValue(DataUtil.getInstance().getUserEntity().isVIP()),
|
|
|
"放弃", "继续观看",
|
|
|
d -> giveUpTask(),
|
|
|
- d -> loadAd()).show();
|
|
|
+ d -> loadAd());
|
|
|
+ dialog.setCancelable(false);
|
|
|
+ dialog.show();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onViewCreated(){
|
|
|
+ public void onViewCreated() {
|
|
|
initView();
|
|
|
initData();
|
|
|
}
|
|
|
|
|
|
protected abstract void initView();
|
|
|
+
|
|
|
protected abstract void initData();
|
|
|
+
|
|
|
protected abstract void loadAd();
|
|
|
|
|
|
}
|