|
|
@@ -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());
|
|
|
}
|
|
|
}
|