Commit 09f487aa authored by mengcuiguang's avatar mengcuiguang

提现代码

parent 8409c607
......@@ -9,8 +9,8 @@ android {
applicationId "com.mints.goodmoney"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 5
versionName "1.0.4"
versionCode 6
versionName "1.0.5"
flavorDimensions "default"
// dex突破65535的限制
......
......@@ -31,14 +31,10 @@ object BannerManager {
fun getTtBanner(codeId: String, frameLayout: FrameLayout?) {
var expressViewAcceptedSizeWidth: Float = 380f
var expressViewAcceptedSizeHeight: Float = 280f
var imageAcceptedSizeWidth: Int = 600
var imageAcceptedSizeHeight: Int = 500
when (codeId) {
TtCsjAdManager.TT_AD_BANNER_MY -> {
expressViewAcceptedSizeWidth = 380f
expressViewAcceptedSizeHeight = 280f
imageAcceptedSizeWidth = 600
imageAcceptedSizeHeight = 500
}
}
......@@ -48,7 +44,7 @@ object BannerManager {
.setSupportDeepLink(true)
.setAdCount(1) //请求广告数量为1到3条
.setExpressViewAcceptedSize(expressViewAcceptedSizeWidth, expressViewAcceptedSizeHeight) //期望模板广告view的size,单位dp
.setImageAcceptedSize(imageAcceptedSizeWidth, imageAcceptedSizeHeight) //这个参数设置即可,不影响模板广告的size
.setImageAcceptedSize(640, 320) //这个参数设置即可,不影响模板广告的size
.build()
it.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) {
......@@ -61,7 +57,6 @@ object BannerManager {
override fun onError(code: Int, msg: String) {
LogUtil.d("BannerManager", "onError code:${code} msg:${msg}")
// frameLayout?.removeAllViews()
}
})
}
......
......@@ -50,7 +50,6 @@ public class CsjVedioAdManager extends BaseVideoAd {
private CsjVedioAdManager(Activity activity) {
super(activity);
init(activity);
return;
}
private void init(Activity activity) {
......@@ -98,6 +97,7 @@ public class CsjVedioAdManager extends BaseVideoAd {
codeId = TtCsjAdManager.TT_AD_VEDIO_DRINK;
break;
case Constant.CARRIER_CHALLENGE_TURN:// 大转盘
case Constant.CARRIER_DRAWCASH:// 提现
codeId = TtCsjAdManager.TT_AD_VEDIO_TURNABLE;
break;
case Constant.CARRIER_CHALLENGE_CARD:// 刮刮乐
......@@ -125,90 +125,98 @@ public class CsjVedioAdManager extends BaseVideoAd {
.setMediaExtra(JsonUtil.toJson(getAdMapVO(carrierType, tid)))
.setOrientation(TTAdConstant.VERTICAL)
.build();
ttAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int code, String message) {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
if (ttAdNative != null) {
LogUtil.d("CsjVedioAdManager", "onError " + code + message);
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdFail();
}
}
ttAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int code, String message) {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
//视频广告加载后,视频资源缓存到本地的回调,在此回调后,播放本地视频,流畅不阻塞。
@Override
public void onRewardVideoCached() {
if (mttRewardVideoAd != null) {
mttRewardVideoAd.showRewardVideoAd(activity);
mttRewardVideoAd = null;
} else {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
LogUtil.d("CsjVedioAdManager", "onError " + code + message);
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdFail();
}
}
}
//视频广告的素材加载完毕,比如视频url等,在此回调后,可以播放在线视频,网络不好可能出现加载缓冲,影响体验。
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ad) {
mttRewardVideoAd = ad;
mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {//视频广告展示回调
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ZERO, "", "");
}
@Override
public void onAdVideoBarClick() {//广告的下载bar点击回调
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioDownload();
}
}
@Override
public void onAdClose() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_THREE, "", "");
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdSuccess();
}
}
@Override
public void onVideoComplete() {
}
@Override
public void onVideoError() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "VideoError");
//视频广告加载后,视频资源缓存到本地的回调,在此回调后,播放本地视频,流畅不阻塞。
@Override
public void onRewardVideoCached() {
if (mttRewardVideoAd != null) {
mttRewardVideoAd.showRewardVideoAd(activity);
mttRewardVideoAd = null;
} else {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdFail();
}
}
}
@Override
public void onRewardVerify(boolean var1, int var2, String var3, int var4, String var5) {
}
@Override
public void onSkippedVideo() {
//视频广告的素材加载完毕,比如视频url等,在此回调后,可以播放在线视频,网络不好可能出现加载缓冲,影响体验。
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ad) {
mttRewardVideoAd = ad;
if (mttRewardVideoAd != null) {
mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {//视频广告展示回调
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ZERO, "", "");
}
@Override
public void onAdVideoBarClick() {//广告的下载bar点击回调
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioDownload();
}
}
@Override
public void onAdClose() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_THREE, "", "");
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdSuccess();
}
}
@Override
public void onVideoComplete() {
}
@Override
public void onVideoError() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "VideoError");
if (csjVedioAdListener != null) {
csjVedioAdListener.csjVedioAdFail();
}
}
@Override
public void onRewardVerify(boolean var1, int var2, String var3, int var4, String var5) {
}
@Override
public void onSkippedVideo() {
}
});
}
});
}
});
}
});
}
}
/**
......
......@@ -46,7 +46,6 @@ public class VedioAdingManager {
private VedioAdingManager(Activity activity) {
init(activity);
return;
}
/**
......
......@@ -55,7 +55,7 @@ class WnVedioAdManager private constructor(activity: Activity) :
when (carrierType) {
Constant.CARRIER_VERSUS_VIDEO -> postId = WnManager.WN_AD_VEDIO_MAIN_POSTID
Constant.CARRIER_HOMEWATER -> postId = WnManager.WN_AD_VEDIO_DRINK_POSTID
Constant.CARRIER_CHALLENGE_TURN -> postId = WnManager.WN_AD_VEDIO_TURNABLE_POSTID
Constant.CARRIER_CHALLENGE_TURN,Constant.CARRIER_DRAWCASH -> postId = WnManager.WN_AD_VEDIO_TURNABLE_POSTID
Constant.CARRIER_CHALLENGE_CARD -> postId = WnManager.WN_AD_VEDIO_ERASE_POSTID
else -> postId = WnManager.WN_AD_VEDIO_MOREDIALOG_POSTID
}
......
......@@ -44,7 +44,6 @@ public class YlhVedioAdManager extends BaseVideoAd implements VedioAdManagerView
private YlhVedioAdManager(Activity activity) {
super(activity);
init(activity);
return;
}
private void init(Activity activity) {
......@@ -86,6 +85,7 @@ public class YlhVedioAdManager extends BaseVideoAd implements VedioAdManagerView
ylhPostId = YlhAdManager.YLH_AD_VEDIO_DRINK_POSTID;
break;
case Constant.CARRIER_CHALLENGE_TURN:// 大转盘
case Constant.CARRIER_DRAWCASH:// 提现
ylhPostId = YlhAdManager.YLH_AD_VEDIO_TURNABLE_POSTID;
break;
case Constant.CARRIER_CHALLENGE_CARD:// 刮刮乐
......@@ -171,7 +171,7 @@ public class YlhVedioAdManager extends BaseVideoAd implements VedioAdManagerView
public void onADClose() {//激励视频广告被关闭
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_THREE, "", "");
ylhVedioAdPresenter.reportAddCoinMsg(activity, getAdMapVO(carrierType,Constant.AD_SOURCE_YLH,extraId,curCoin));
ylhVedioAdPresenter.reportAddCoinMsg(activity, getAdMapVO(carrierType, Constant.AD_SOURCE_YLH, extraId, curCoin));
if (ylhVedioAdListener != null) {
ylhVedioAdListener.ylhVedioAdSuccess();
......
......@@ -115,6 +115,7 @@ object Constant {
const val CARRIER_SMALLHOMEVEDIO = "SMALLHOMEVEDIO" //首页红包
const val CARRIER_SMALLHOMEVEDIO_DOUBLE = "SMALLHOMEVEDIO_DOUBLE" //首页红包翻倍
const val CARRIER_MORNING_CLOCK = "MORNING_CLOCK" //早上打卡
const val CARRIER_DRAWCASH = "DRAWCASH" //提现
const val CHALLENGE_SHAREFRIEND = "CHALLENGE_SHAREFRIEND" //邀请好友
......
......@@ -54,4 +54,13 @@ public class TrackManager {
trackPresenter.addCallImp(adSource, eventType, errorcode, errormsg);
}
}
/**
* 提现看视频
*/
public void drawcashVideo() {
if (trackPresenter != null) {
trackPresenter.drawcashVideo();
}
}
}
......@@ -10,86 +10,82 @@ public class DrawcashBean implements Serializable {
private String drawcashRule;
private String drawcashHint;
private int coin;
private int vedioComplete;
private String remark;
private List<CashOutMoneyArrBean> cashOutMoneyArr;
private VedioRules vedioRules;
public String getOpenid() {
return openid;
public int getVedioComplete() {
return vedioComplete;
}
public void setOpenid(String openid) {
this.openid = openid;
public String getOpenid() {
return openid;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getDrawcashRule() {
return drawcashRule;
}
public void setDrawcashRule(String drawcashRule) {
this.drawcashRule = drawcashRule;
}
public String getDrawcashHint() {
return drawcashHint;
}
public void setDrawcashHint(String drawcashHint) {
this.drawcashHint = drawcashHint;
}
public int getCoin() {
return coin;
}
public void setCoin(int coin) {
this.coin = coin;
public String getRemark() {
return remark;
}
public List<CashOutMoneyArrBean> getCashOutMoneyArr() {
return cashOutMoneyArr;
}
public void setCashOutMoneyArr(List<CashOutMoneyArrBean> cashOutMoneyArr) {
this.cashOutMoneyArr = cashOutMoneyArr;
public VedioRules getVedioRules() {
return vedioRules;
}
public String getRemark() {
return remark;
}
public class VedioRules implements Serializable {
private int SDHZ_VEDIO;
private int CSJ_VEDIO;
private int YLH_VEDIO;
public int getSDHZ_VEDIO() {
return SDHZ_VEDIO;
}
public int getCSJ_VEDIO() {
return CSJ_VEDIO;
}
public void setRemark(String remark) {
this.remark = remark;
public int getYLH_VEDIO() {
return YLH_VEDIO;
}
}
public class CashOutMoneyArrBean implements Serializable {
private int vedio;
private double money;
private boolean canCashOut;
public int getVedio() {
return vedio;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public boolean isCanCashOut() {
return canCashOut;
}
public void setCanCashOut(boolean canCashOut) {
this.canCashOut = canCashOut;
}
}
}
......@@ -60,4 +60,24 @@ public class TrackPresenter extends BaseTrackPresenter {
}
});
}
public void drawcashVideo() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.drawcashVideo(),
new BaseSubscriber<BaseResponse<Object>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
}
});
}
}
......@@ -428,6 +428,13 @@ public interface LoanService {
@POST("api/toKeepAccount")
Observable<BaseResponse<UserBean>> toKeepAccount(@Body Map<String, Object> vo);
/**
* 提现看视频
*
* @return
*/
@POST("api/addCashoutVedio")
Observable<BaseResponse<Object>> drawcashVideo();
/**
* 默认http工厂
......
......@@ -7,17 +7,25 @@ import androidx.recyclerview.widget.GridLayoutManager
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.video.VedioAdingManager
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.login.LoginApi
import com.mints.goodmoney.login.OnLoginListener
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.mvp.model.DrawcashBean
import com.mints.goodmoney.mvp.model.UserTaskMsgBean
import com.mints.goodmoney.mvp.model.VedioRulesBean
import com.mints.goodmoney.mvp.model.WXInfo
import com.mints.goodmoney.mvp.presenters.DrawcashPresenter
import com.mints.goodmoney.mvp.views.DrawcashView
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.adapter.DrawcashAdapter
import com.mints.goodmoney.ui.adapter.listener.OnItemClickListener
import com.mints.goodmoney.ui.fragment.MyFragment
import com.mints.goodmoney.ui.widgets.BindWxDialog
import com.mints.goodmoney.ui.widgets.DrawcashVideoDialog
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.SpanUtils
import com.mints.library.utils.CommonUtils
import com.mints.library.utils.json.JsonUtil
......@@ -35,6 +43,8 @@ import java.util.*
class DrawcashActivity : BaseActivity(),
DrawcashView, View.OnClickListener, OnItemClickListener, OnLoginListener {
private val TAG = DrawcashActivity::class.java.simpleName
private val drawcashPresenter by lazy { DrawcashPresenter() }
private val userManager by lazy { UserManager.getInstance() }
private val loginApi by lazy { LoginApi() }
......@@ -43,8 +53,12 @@ class DrawcashActivity : BaseActivity(),
private var wxInfo: WXInfo? = null
private var userConfig: DrawcashBean? = null
private var drawcashVideoDialog: DrawcashVideoDialog? = null
private var isLoadRvItem: Boolean = true //是否首次加载rv item
private lateinit var vedioAdingManager: VedioAdingManager
override fun getContentViewLayoutID() = R.layout.activity_drawcash
override fun isApplyKitKatTranslucency() = false
......@@ -57,9 +71,8 @@ class DrawcashActivity : BaseActivity(),
tv_right_subtitle.text = "提现记录"
view_title.text = "提现规则"
vedioAdingManager = VedioAdingManager.getInstance(this)
drawcashPresenter.attachView(this)
// initText()
initListener()
}
......@@ -90,9 +103,6 @@ class DrawcashActivity : BaseActivity(),
readyGo(DrawcashRecordActivity::class.java)
}
R.id.rl_coin -> {
// readyGo(CoinRecordActivity::class.java)
}
R.id.tvDrawcashWx -> {
// 是否登录
if (!userManager.userIsLogin()) {
......@@ -140,7 +150,13 @@ class DrawcashActivity : BaseActivity(),
return
}
drawcashPresenter.saveTerminalInfo(priceList!![drawcashAdapter?.getPosition()].money)
val curCount = userConfig?.vedioComplete!!
val sumCount = priceList!![drawcashAdapter.getPosition()].vedio
if (curCount >= sumCount) {
drawcashPresenter.saveTerminalInfo(priceList!![drawcashAdapter?.getPosition()].money)
} else {
drawcashVideoDialog(curCount, sumCount)
}
}
}
}
......@@ -167,6 +183,17 @@ class DrawcashActivity : BaseActivity(),
val rateBig = BigDecimal("10000")
val cashStr: String = allcoinBig.divide(rateBig).setScale(2, BigDecimal.ROUND_DOWN).toString()
tvDrawcashGoldabout.setText("约" + cashStr + "元")
initAdWeight(data.vedioRules)
if (drawcashVideoDialog != null && drawcashVideoDialog!!.isShowing) {
drawcashVideoDialog?.setContent("观看视频并下载后立即提现(${data.vedioComplete}/${data.cashOutMoneyArr[drawcashAdapter.getPosition()].vedio})")
if (data.vedioComplete >= data.cashOutMoneyArr[drawcashAdapter.getPosition()].vedio) {
drawcashVideoDialog?.setBtnText("去提现")
} else {
drawcashVideoDialog?.setBtnText("去观看")
}
}
}
override fun editUserMsgSuc() {
......@@ -198,7 +225,7 @@ class DrawcashActivity : BaseActivity(),
}
if (!isFinishing) {
drawcashPresenter.editUserMsg(res["openid"].toString(),JsonUtil.toJson(wxInfo))
drawcashPresenter.editUserMsg(res["openid"].toString(), JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
......@@ -240,7 +267,6 @@ class DrawcashActivity : BaseActivity(),
private fun initListener() {
iv_left_icon.setOnClickListener(this)
tv_right_subtitle.setOnClickListener(this)
rl_coin.setOnClickListener(this)
tvDrawcashWx.setOnClickListener(this)
tvDrawcashNext.setOnClickListener(this)
}
......@@ -249,4 +275,39 @@ class DrawcashActivity : BaseActivity(),
drawcashAdapter.setPosition(position)
drawcashAdapter.notifyDataSetChanged()
}
/**
* 设置视频权重
*/
private fun initAdWeight(data: DrawcashBean.VedioRules) {
vedioAdingManager?.initAdWeight(data.csJ_VEDIO, data.ylH_VEDIO, data.sdhZ_VEDIO)
LogUtil.d(TAG, "提现权重值:csjWeight:${data.csJ_VEDIO} ylhWeight:${data.ylH_VEDIO} sdhzWeight:${data.sdhZ_VEDIO}")
// 广告视频数
AppConfig.csjVedioAdCount = 10
AppConfig.ylhAdCount = 10
AppConfig.wnVedioAdCount = 10
}
/**
* 提现看视频
*/
private fun drawcashVideoDialog(curCount: Int, sumCount: Int) {
if (drawcashVideoDialog == null) {
drawcashVideoDialog = DrawcashVideoDialog(this)
}
if (sumCount == 1) {
drawcashVideoDialog?.setContent("观看视频并下载后可立即提现")
} else {
drawcashVideoDialog?.setContent("观看视频并下载后可立即提现(${curCount}/${sumCount})")
}
drawcashVideoDialog?.setOnClickListener(object : DrawcashVideoDialog.OnClickListener {
override fun onClick() {
if (priceList != null && priceList!!.size > 0) {
drawcashPresenter.saveTerminalInfo(priceList!![drawcashAdapter?.getPosition()].money)
}
}
})
drawcashVideoDialog?.show()
}
}
\ No newline at end of file
......@@ -59,32 +59,47 @@ class DrawcashAdapter(val priceList: MutableList<DrawcashBean.CashOutMoneyArrBea
holder.tvDrawItemGold.text = "约${String.format("%.0f", priceBean.money * 10000)}金币"
holder.llDrawItem.setOnClickListener {
if (priceBean.isCanCashOut) {
holder.llDrawItem.setEnabled(true)
mOnItemClickListener.onItemClick(holder.llDrawItem, position)
notifyDataSetChanged()
} else {
holder.llDrawItem.setEnabled(false)
}
// if (priceBean.isCanCashOut) {
// holder.llDrawItem.setEnabled(true)
// mOnItemClickListener.onItemClick(holder.llDrawItem, position)
// notifyDataSetChanged()
// } else {
// holder.llDrawItem.setEnabled(false)
// }
mOnItemClickListener.onItemClick(holder.llDrawItem, position)
notifyDataSetChanged()
}
if (!priceBean.isCanCashOut) {
holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.color_ccc))
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.color_ccc))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
// if (!priceBean.isCanCashOut) {
// holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.black))
// holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.gray))
// holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.gray))
// holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
// } else {
// //当前选中
// if (getPosition() == position) {
// holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.white))
// holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.white))
// holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.white))
// holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter_none)
// } else {
// holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.black))
// holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.gray))
// holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.gray))
// holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
// }
// }
if (getPosition() == position) {
holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter_none)
} else {
//当前选中
if (getPosition() == position) {
holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.white))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter_none)
} else {
holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.black))
holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.gray))
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.gray))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
}
holder.tvDrawItemCash.setTextColor(ContextCompat.getColor(context, R.color.black))
holder.tvDrawItemHint.setTextColor(ContextCompat.getColor(context, R.color.gray))
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.gray))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
}
......
......@@ -206,6 +206,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
return
}
// 更新权重
initAdWeight(data)
// 新人福利
......
......@@ -2,43 +2,37 @@ package com.mints.goodmoney.ui.widgets
import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.video.VedioAdingManager
import com.mints.goodmoney.ad.video.WnVedioAdManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.login.LoginApi
import com.mints.goodmoney.login.OnLoginListener
import com.mints.goodmoney.mvp.model.DrawcashBean
import com.mints.goodmoney.mvp.model.WXInfo
import com.mints.goodmoney.mvp.presenters.SettingsPresenter
import com.mints.goodmoney.mvp.views.SettingsView
import com.mints.goodmoney.ui.activitys.AccountMergeActivity
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.mvp.model.VedioAdingBean
import com.mints.goodmoney.utils.ToastUtil
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import java.util.*
/**
* 微信授权弹窗
* 提现弹窗
*/
class DrawcashVideoDialog(context: Activity) :
Dialog(context, R.style.dialog), OnLoginListener, SettingsView, View.OnClickListener {
class DrawcashVideoDialog(activity: Activity) :
Dialog(activity, R.style.dialog), View.OnClickListener {
private var loginApi: LoginApi? = null
private var settingsPresenter: SettingsPresenter? = null
private var wxInfo: WXInfo? = null
private var onClickListener: OnClickListener? = null
private var vedioAdingManager: VedioAdingManager? = null
private var loadVedioFailCount = 0
private var tvContent: TextView
private var tvNext: TextView
private var activity: Activity? = null
init {
setContentView(R.layout.dialog_bindwx)
setContentView(R.layout.dialog_drawcash)
// 设置window属性
val lp = window!!.attributes
lp.gravity = Gravity.CENTER
......@@ -46,105 +40,106 @@ class DrawcashVideoDialog(context: Activity) :
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
findViewById<View>(R.id.btn_dialogper_next).setOnClickListener(this)
vedioAdingManager = VedioAdingManager.getInstance(activity)
loginApi = LoginApi()
settingsPresenter = SettingsPresenter()
settingsPresenter?.attachView(this)
findViewById<View>(R.id.btn_dialog_drawcash_back).setOnClickListener(this)
tvContent = findViewById<View>(R.id.btn_dialog_drawcash_content) as TextView
tvNext = findViewById<View>(R.id.btn_dialog_drawcash_next) as TextView
tvNext.setOnClickListener(this)
this.activity = activity
}
override fun dismiss() {
super.dismiss()
loginApi?.setOnLoginListener(null)
settingsPresenter?.detachView()
vedioAdingManager?.setVedioAdingListener(null)
vedioAdingManager?.onDestory()
activity = null
}
override fun onClick(v: View) {
if (AntiShake.check(v?.id)) return
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.btn_dialogper_next -> {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
return
R.id.btn_dialog_drawcash_next -> {
if (TextUtils.equals(tvNext.text.toString(), "去提现")) {
onClickListener?.onClick()
dismiss()
} else {
awardVedio()
}
loginApi?.let {
it.setOnLoginListener(this)
it.setPlatform(Wechat.NAME)
it.login(context)
}
}
}
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.setUnionid(res["unionid"].toString() + "")
it.setOpenid(res["openid"].toString() + "")
it.setProvince(res["province"].toString() + "")
it.setCity(res["city"].toString() + "")
it.setCountry(res["country"].toString() + "")
it.setHeadimgurl(res["headimgurl"].toString() + "")
it.setNickname(res["nickname"].toString() + "")
it.setSex((res["sex"].toString() + "").toInt())
R.id.btn_dialog_drawcash_back -> {
dismiss()
}
settingsPresenter?.editUserMsg(res["openid"].toString(), JsonUtil.toJson(wxInfo))
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
fun setContent(content: String) {
tvContent.text = content
}
protected fun readyGo(clazz: Class<*>?, bundle: Bundle?) {
val intent = Intent(context, clazz)
if (null != bundle) {
intent.putExtras(bundle)
}
context.startActivity(intent)
fun setBtnText(text: String) {
tvNext.text = text
}
override fun editUserMsgSuc() {
ToastUtil.show(context, "微信绑定成功")
dismiss()
}
/**
* 获取激励视频
*/
private fun awardVedio() {
if (activity == null) return
override fun getUserTaskMsgSuc(data: DrawcashBean) {
loadVedioFailCount = 0
ToastUtil.show(activity, "加载中...")
val bean = VedioAdingBean()
bean.carrierType = Constant.CARRIER_DRAWCASH
vedioAdingManager?.let { loadVedio(it, bean, true) }
}
override fun showLoading(msg: String?) {
/**
* 加载激励视频
*/
private fun loadVedio(vedioAdingManager: VedioAdingManager?, bean: VedioAdingBean, isFirstLoad: Boolean) {
if (activity == null) return
vedioAdingManager?.let {
it.setVedioAdingListener(object : VedioAdingManager.VedioAdingListener {
override fun vedioAdingListenerError(adType: String) {
ToastUtil.show(activity, "加载超时,请休息一下")
}
}
override fun vedioAdingListenerFail(adType: String) {
loadVedioFailCount++
if (loadVedioFailCount >= 2) {
ToastUtil.show(activity, "加载超时,请休息一下")
} else {
loadVedio(vedioAdingManager, bean, false)
}
}
override fun showToast(msg: String?) {
ToastUtil.showLong(context, msg)
override fun vedioAdingListenerSuccess(adType: String) {
if (it.isVedioAdDownload) {
TrackManager.getInstance().drawcashVideo()
}
}
})
if (isFirstLoad) {
// 首页按权重加载
it.loadAding(activity, bean)
} else {
// 失败按优先级加载
it.loadFailAding(activity, bean)
}
}
}
override fun hideLoading() {
interface OnClickListener {
fun onClick()
}
override fun getBaseApplication(): MintsApplication {
return MintsApplication.getContext() as MintsApplication
fun setOnClickListener(onClickListener: OnClickListener) {
this.onClickListener = onClickListener
}
}
\ No newline at end of file
......@@ -12,15 +12,27 @@
android:background="@drawable/shape_bg_write"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="温馨提示"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="温馨提示"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_dialog_drawcash_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@mipmap/ic_activity_quit"></ImageView>
</RelativeLayout>
<View
......@@ -31,33 +43,26 @@
android:background="#E1E1E1" />
<TextView
android:id="@+id/btn_dialog_drawcash_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="为了保证您的账户安全\n请先绑定微信"
android:textColor="@color/gray"
android:textSize="14sp" />
<ImageView
android:layout_width="50dp"
android:src="@mipmap/ic_share_wx"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:layout_height="50dp"/>
<TextView
android:id="@+id/btn_dialogper_next"
android:id="@+id/btn_dialog_drawcash_next"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:gravity="center"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_green"
android:text="去绑定"
android:layout_marginTop="30dp"
android:background="@drawable/shape_main"
android:text="去观看"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
......
......@@ -38,8 +38,9 @@
<FrameLayout
android:id="@+id/fl_my_banner"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
......
......@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginTop="10dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="16dp"
android:columnWidth="80dp"
android:divider="@null"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment