|
|
@@ -1,6 +1,7 @@
|
|
|
package com.sheep.gamegroup.view.dialog;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
@@ -8,6 +9,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
+import com.sheep.gamegroup.helper.DownloadHelper;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.CashAwarsEntity;
|
|
|
import com.sheep.gamegroup.model.entity.CommendApp;
|
|
|
@@ -21,6 +23,7 @@ import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.gamegroup.view.activity.ActMain;
|
|
|
import com.sheep.gamegroup.view.adapter.GiftCenterAdapter;
|
|
|
import com.sheep.gamegroup.view.adapter.WelfareAdapter;
|
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
@@ -36,6 +39,7 @@ import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GIFT_BAG_COPY_CODE;
|
|
|
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
|
|
|
|
|
|
|
|
|
public class DialogGameOrTaskOrGift {
|
|
|
@@ -74,6 +78,7 @@ public class DialogGameOrTaskOrGift {
|
|
|
ViewUtil.setVisibility2(dialog_gift_info_tv, false);
|
|
|
dialog_btn_left.setText("换一个");
|
|
|
dialog_btn_right.setText("立即下载");
|
|
|
+ dialog_btn_right.setTag("null");
|
|
|
}
|
|
|
|
|
|
private void loadData() {
|
|
|
@@ -99,6 +104,7 @@ public class DialogGameOrTaskOrGift {
|
|
|
ViewUtil.setText(dialog_gift_tv, giftBag.getGiftName());
|
|
|
ViewUtil.setText(dialog_gift_code_tv, giftBagApp.getCode());
|
|
|
ViewUtil.setText(dialog_gift_info_tv, giftBag.getUseMethod());
|
|
|
+ dialog_btn_right.setTag("null");
|
|
|
if (giftBagApp.isReceived()) {//已经领取礼包
|
|
|
ViewUtil.setText(dialog_btn_right, "复制礼包码");
|
|
|
dialog_btn_right.setOnClickListener(new View.OnClickListener() {
|
|
|
@@ -159,24 +165,16 @@ public class DialogGameOrTaskOrGift {
|
|
|
GlideImageLoader.setGameImage(dialog_iv, commendApp.getApp().getIcon());
|
|
|
ViewUtil.setText(dialog_name_tv, commendApp.getApp().getName());
|
|
|
ViewUtil.setText(dialog_gift_tv, commendApp.getApp().getManufacturer());//这里显示的是开发商名字
|
|
|
- ViewUtil.setText(dialog_btn_right, "立即下载");
|
|
|
- dialog_btn_right.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- ViewUtil.setText(dialog_btn_right, "正在下载");
|
|
|
- DownloadService.sysDownload(activity, commendApp.getApp().getDownload_url(), commendApp.getApp().getName());
|
|
|
- }
|
|
|
- });
|
|
|
+ commendApp.getApp().getFindAppHelper().getDownloadHelper().updateDownloadTaskView(activity, commendApp.getApp(), dialog_btn_right);
|
|
|
+ dialog_btn_right.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + commendApp.getApp().getDownload_url());
|
|
|
} else {
|
|
|
if (BuildConfig.DEBUG)
|
|
|
G.showToast("不是礼包,不是现金任务,不是游戏,还可能是什么");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void bindViews(View view) {
|
|
|
-
|
|
|
dialog_iv = (ImageView) view.findViewById(R.id.dialog_iv);
|
|
|
dialog_name_tv = (TextView) view.findViewById(R.id.dialog_name_tv);
|
|
|
dialog_iv_2 = (ImageView) view.findViewById(R.id.dialog_iv_2);
|
|
|
@@ -190,6 +188,9 @@ public class DialogGameOrTaskOrGift {
|
|
|
dialog_btn_left = (TextView) view.findViewById(R.id.dialog_btn_left);
|
|
|
dialog_btn_center = view.findViewById(R.id.dialog_btn_center);
|
|
|
dialog_btn_right = (TextView) view.findViewById(R.id.dialog_btn_right);
|
|
|
+ if(activity instanceof ActMain){
|
|
|
+ ((ActMain) activity).setProgressView(view);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private AlertDialog mAlertDialog;
|
|
|
@@ -203,11 +204,25 @@ public class DialogGameOrTaskOrGift {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
mAlertDialog.dismiss();
|
|
|
+ onCancelOrClickClose();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
bindViews(view);
|
|
|
-
|
|
|
+ mAlertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss(DialogInterface dialogInterface) {
|
|
|
+ if(activity instanceof ActMain){
|
|
|
+ ((ActMain) activity).setProgressView(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
|
+ @Override
|
|
|
+ public void onCancel(DialogInterface dialogInterface) {
|
|
|
+ onCancelOrClickClose();
|
|
|
+ }
|
|
|
+ });
|
|
|
final View dialog_close = view.findViewById(R.id.dialog_close);
|
|
|
dialog_close.setOnClickListener(onClickListener);
|
|
|
try {
|
|
|
@@ -220,6 +235,15 @@ public class DialogGameOrTaskOrGift {
|
|
|
return mAlertDialog;
|
|
|
}
|
|
|
|
|
|
+ private void onCancelOrClickClose() {
|
|
|
+ if(activity instanceof ActMain) {
|
|
|
+ if (DataUtil.getAsBoolean("tryShowHalfScreenAd", false)) {
|
|
|
+ DataUtil.putAsBoolean("tryShowHalfScreenAd", false);
|
|
|
+ Jump2View.getInstance().tryShowHalfScreenAd(activity, ((ActMain) activity).getContainer());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private CommendApp commendApp;
|
|
|
public static final int FIRST_ORDER = 1;//第一次调用会长推广游戏的接口时,传入的order的默认值
|
|
|
|
|
|
@@ -229,7 +253,7 @@ public class DialogGameOrTaskOrGift {
|
|
|
} else if(commendApp != null && commendApp.hasNextShow()){
|
|
|
loadData();
|
|
|
} else {
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().getGameOrTaskOrGift(gameId, commendApp == null ? FIRST_ORDER : commendApp.getOrder())
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getCommendApp(gameId, commendApp == null ? FIRST_ORDER : commendApp.getOrder())
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@@ -247,6 +271,7 @@ public class DialogGameOrTaskOrGift {
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
if(commendApp == null){//没有获取到过commendApp的情况下,直接弹出抢任务弹出框
|
|
|
+ mAlertDialog.dismiss();
|
|
|
showTaskDialog();
|
|
|
} else {
|
|
|
showChange();
|
|
|
@@ -289,6 +314,10 @@ public class DialogGameOrTaskOrGift {
|
|
|
ViewUtil.newInstance().showRobDutyDialog(activity, robTask);
|
|
|
} else {
|
|
|
G.showToast("任务已被抢光!请实时关注任务发布!");
|
|
|
+ if (activity instanceof ActMain && DataUtil.getAsBoolean("tryShowHalfScreenAd", false)) {
|
|
|
+ DataUtil.putAsBoolean("tryShowHalfScreenAd", false);
|
|
|
+ Jump2View.getInstance().tryShowHalfScreenAd(activity, ((ActMain) activity).getContainer());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|