|
|
@@ -105,7 +105,6 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
private GameEntity gameEntity;
|
|
|
private PlayGameEntity playGameEntity;
|
|
|
private boolean isNeedReservation = false;
|
|
|
- private Map<String, TextView> downLoadTextViewMap = new HashMap<>();
|
|
|
|
|
|
private GiftpackListAdapter mAdapter;
|
|
|
private int curPosition = 0;
|
|
|
@@ -269,9 +268,9 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
welfare_gift_layout.setVisibility(View.GONE);
|
|
|
}else {
|
|
|
welfare_gift_layout.setVisibility(View.VISIBLE);
|
|
|
+ mAdapter.add(FgtPlaGameGift.newInstance(gameEntity), "礼包");
|
|
|
if(gameEntity.isGift()){
|
|
|
gift_tv.setVisibility(View.VISIBLE);
|
|
|
- mAdapter.add(FgtPlaGameGift.newInstance(gameEntity), "礼包");
|
|
|
}else {
|
|
|
gift_tv.setVisibility(View.GONE);
|
|
|
}
|
|
|
@@ -295,59 +294,8 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
|
|
|
//更新按钮状态与添加点击事件
|
|
|
private void updateView(final Activity activity, PlayGameEntity playGameEntity, TextView textView) {
|
|
|
- final TaskReleaseEty releaseEty = gameEntity.getRelease_task();
|
|
|
- final TaskEty taskEty = releaseEty != null?releaseEty.getTask():null;
|
|
|
- if(releaseEty != null && taskEty != null){
|
|
|
-
|
|
|
- if(taskEty.isGameReservationCantDownload()){//游戏任务中的预约任务,且不能下载情况下
|
|
|
- textView.setText("预约下载");
|
|
|
- textView.setEnabled(true);
|
|
|
- textView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- CommonUtil.getInstance().reservationGameTask(activity, releaseEty, new Action1<Integer>() {
|
|
|
- @Override
|
|
|
- public void call(Integer integer) {
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- if (gameEntity.getReceived_voucher()) {//已领取
|
|
|
- if (gameEntity.getCan_download()) {
|
|
|
- downLoadTextViewMap.put(playGameEntity.getDownload_url(), textView);
|
|
|
- downLoadTextViewMap.put(playGameEntity.getPackage_name(), textView);
|
|
|
- releaseEty.getDownloadHelper().updateDownloadTaskView((Activity) activity, taskEty, textView);
|
|
|
- } else {
|
|
|
- textView.setEnabled(false);
|
|
|
- textView.setText("已经预约");
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- textView.setText("领取奖励");
|
|
|
- textView.setEnabled(true);
|
|
|
- textView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- CommonUtil.getInstance().receiveAward(activity, releaseEty, new Action1<Integer>() {
|
|
|
- @Override
|
|
|
- public void call(Integer integer) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }else
|
|
|
- if (playGameEntity.isCanDonload()) {//可下载
|
|
|
- downLoadTextViewMap.put(playGameEntity.getDownload_url(), textView);
|
|
|
- downLoadTextViewMap.put(playGameEntity.getPackage_name(), textView);
|
|
|
- playGameEntity.getFindAppHelper().updateDownloadTaskView(activity, playGameEntity, textView);
|
|
|
- } else {//预约下载
|
|
|
- playGameEntity.getFindAppHelper().updateReservationView(activity, playGameEntity, textView);
|
|
|
- }
|
|
|
+ CommonUtil.getInstance().palyGameDetailBtnValue(activity,gameEntity,textView);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -385,57 +333,42 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
super.onDestroy();
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
}
|
|
|
- //获取任务对应的TextView来更新进度
|
|
|
- private TextView getTextViewByTask(DownloadTask task) {
|
|
|
- return getTextViewByKey(task.getKey());
|
|
|
- }
|
|
|
-
|
|
|
- private TextView getTextViewByKey(String key) {
|
|
|
- if (downLoadTextViewMap.containsKey(key))
|
|
|
- return downLoadTextViewMap.get(key);
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
//下载状态监听
|
|
|
|
|
|
@Download.onPre
|
|
|
void onPre(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText("准备下载中");
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText("准备下载中");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Download.onTaskStart
|
|
|
void taskStart(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText("开始下载中");
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText("开始下载中");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Download.onTaskResume
|
|
|
void taskResume(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText("恢复下载中");
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText("恢复下载中");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//在这里处理任务执行中的状态,如进度进度条的刷新
|
|
|
@Download.onTaskRunning
|
|
|
protected void running(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText(String.format(Locale.CHINA, "%d%%", Math.abs(task.getPercent())));
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText(String.format(Locale.CHINA, "%d%%", Math.abs(task.getPercent())));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Download.onTaskStop
|
|
|
void taskStop(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText(CommonUtil.CONTINUE_DOWNLOAD);
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText(CommonUtil.CONTINUE_DOWNLOAD);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -445,25 +378,22 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
|
|
|
@Download.onTaskCancel
|
|
|
void taskCancel(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText("已经取消");
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText("已经取消");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Download.onTaskFail
|
|
|
void taskFail(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText(CommonUtil.FAIL_DOWNLOAD);
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText(CommonUtil.FAIL_DOWNLOAD);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Download.onTaskComplete
|
|
|
void taskComplete(DownloadTask task) {
|
|
|
- TextView textView = getTextViewByTask(task);
|
|
|
- if (textView != null) {
|
|
|
- textView.setText(CommonUtil.START_INSTALL);
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
+ find_game_down_tv.setText(CommonUtil.START_INSTALL);
|
|
|
}
|
|
|
if (gameEntity != null && gameEntity.getApp() != null && TextUtils.equals(task.getKey(), gameEntity.getApp().getDownload_link()))
|
|
|
gameEntity.getApp().updateState(DownloadTaskService.STATUS_FINISH);
|
|
|
@@ -474,18 +404,17 @@ public class ActPlayGameDetail extends BaseActivity implements Action1<Integer>
|
|
|
if (intent != null && intent.getAction() != null && intent.getDataString() != null && intent.getDataString().contains("package:")) {
|
|
|
String packageName = intent.getDataString().replace("package:", "");
|
|
|
|
|
|
- TextView textView = getTextViewByKey(packageName);
|
|
|
- if (textView != null) {
|
|
|
+ if (find_game_down_tv != null) {
|
|
|
switch (intent.getAction()) {
|
|
|
case ACTION_PACKAGE_ADDED:
|
|
|
- textView.setText(CommonUtil.GAME_OPEN);
|
|
|
+ find_game_down_tv.setText(CommonUtil.GAME_OPEN);
|
|
|
break;
|
|
|
case ACTION_PACKAGE_REMOVED:
|
|
|
String path = PackageUtil.isExistsFile(packageName);
|
|
|
if (TextUtils.isEmpty(path)) {
|
|
|
- textView.setText(CommonUtil.START_DOWNLOAD);
|
|
|
+ find_game_down_tv.setText(CommonUtil.START_DOWNLOAD);
|
|
|
} else {
|
|
|
- textView.setText(CommonUtil.START_INSTALL);
|
|
|
+ find_game_down_tv.setText(CommonUtil.START_INSTALL);
|
|
|
}
|
|
|
break;
|
|
|
}
|