|
|
@@ -1,6 +1,8 @@
|
|
|
package com.sheep.gamegroup.util;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.text.Html;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
@@ -82,7 +84,8 @@ public class TaskHelper {
|
|
|
return taskReleaseEty != null && taskReleaseEty.getTask() != null;
|
|
|
}
|
|
|
|
|
|
- public void loadTask(View itemView) {
|
|
|
+ private RxjavaCountDownTimer timer;
|
|
|
+ public void loadTask(final View itemView) {
|
|
|
itemView.setVisibility(View.VISIBLE);
|
|
|
final TaskEty taskEty = taskReleaseEty.getTask();
|
|
|
ImageView find_information_game_icon = (ImageView)itemView.findViewById(R.id.find_information_game_icon);
|
|
|
@@ -91,19 +94,111 @@ public class TaskHelper {
|
|
|
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_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);
|
|
|
ViewUtil.setImage(find_information_game_icon, taskEty.getIcon());
|
|
|
ViewUtil.setText(find_information_game_name, taskEty.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", TimeUtil.TimeStamp2Date(NumberFormatUtils.parseLong(taskReleaseEty.getDeadline()), "yyyy/MM/dd\tHH:mm")));
|
|
|
ViewUtil.setText(find_information_game_yuan, String.format(Locale.CHINA, "+%s元", taskReleaseEty.getBonus()));
|
|
|
find_information_game_yuan.setVisibility(View.VISIBLE);
|
|
|
- find_information_game_task.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- G.showToast("点击接受任务");
|
|
|
- }
|
|
|
- });
|
|
|
+ if(taskAcceptedEty != null){
|
|
|
+ switch (taskAcceptedEty.getStatus()) {
|
|
|
+ case 1://"已接受任务";
|
|
|
+ case 2:// "正在进行中";
|
|
|
+ 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) {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().giveUpTask(taskReleaseEty.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);
|
|
|
+ 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 {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
@@ -111,4 +206,20 @@ public class TaskHelper {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ //刷新界面
|
|
|
+ public void refreshTask() {
|
|
|
+ clear();
|
|
|
+ taskAcceptedEty = null;
|
|
|
+ taskReleaseEty = null;
|
|
|
+ initAcceptedTask(activity, release_task_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清理计时器
|
|
|
+ */
|
|
|
+ public void clear() {
|
|
|
+ if(timer != null)
|
|
|
+ timer.clear();
|
|
|
+ timer = null;
|
|
|
+ }
|
|
|
}
|