Commit 3dd5e131 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent e983a04d
......@@ -102,7 +102,6 @@ object Constant {
const val CHALLENGE_SHAREFRIEND = "CHALLENGE_SHAREFRIEND" //邀请好友
const val AD_SOURCE_CSJ = "CSJ"
const val AD_SOURCE_YLH = "YLH"
......@@ -134,12 +133,13 @@ object Constant {
const val HOT_ACTIVITY_WATER = "water"
const val HOT_ACTIVITY_WALK = "walk"
const val HOT_ACTIVITY_CARD = "card"
// 打开激活
const val FIRST_DEVICE_FLAG = "first_device_flag"
// share
const val SHARE_TITLE = "当下流行的赚钱模式,边看边玩边赚钱"
var SHARE_CONTENT = "邀请码【${UserManager.getInstance().codeID}】,共享新模式,快来加入跟我一起赚钱吧"
var SHARE_URL: String = BuildConfig.MainIp+ "share/shareFriend.html?channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
var SHARE_URL: String = BuildConfig.MainIp + "share/shareFriend.html?ruid=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
}
\ No newline at end of file
......@@ -130,6 +130,10 @@ class HomePresenter : BasePresenter<HomeView>() {
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code = baseResponse.getStatus()
when (code) {
200 -> getHomeVedioMsg()
}
}
})
}
......
......@@ -64,7 +64,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
startTime()
when (carrierType) {
Constant.CARRIER_HOMEVEDIO_SMALL -> {
Constant.CARRIER_HOMEVEDIO_SMALL,Constant.CHALLENGE_SHAREFRIEND -> {
val vo = HashMap<String, Any>()
vo["carrierType"] = carrierType
awardPresenter.reportAddCoinMsg(vo)
......
......@@ -68,8 +68,8 @@ class DrawcashAdapter(val priceList: MutableList<DrawcashBean.CashOutMoneyArrBea
holder.tvDrawItemGold.setTextColor(ContextCompat.getColor(context, R.color.grayc))
holder.llDrawItem.setBackgroundResource(R.drawable.shape_vip_adapter)
} else {
//当前选中
if (getPosition() == position) {
//当前选中
holder.tvDrawItemCash.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)
......
......@@ -96,7 +96,7 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
littleVideoFragment?.onResume()
if (!TextUtils.isEmpty(vedioId)) {
startDownloadTime(vedioId)
resumeDownloadTime(vedioId)
}
}
}
......@@ -152,20 +152,24 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
}
override fun getHomeVedioMsgSuc(data: MainVedioMsgBean) {
if (activity == null || activity!!.isFinishing) {
return
}
smallRewardCoin = data.smallRewardCoin
bigRewardCoin = data.bigRewardCoin
ivMainBox.visibility = if (bigRewardCoin > 0) View.VISIBLE else View.GONE
// ivMainBox.visibility = if (bigRewardCoin > 0) View.VISIBLE else View.GONE
if (data.isToCreateReward) {
// 防止界面切换 重置倒计时
if (!cdvvYilanTime.isPlaying) {
// 第一次能过 isFirstLoadVedio 判断好兔先加载视频
if (!isFirstLoadVedio && !cdvvYilanTime.isPlaying) {
cdvvYilanTime?.reset()
cdvvYilanTime?.start()
}
} else {
// 暂停
isClickStop = true
cdvvYilanTime?.stop()
stopDownloadTime()
}
}
......@@ -191,14 +195,14 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
override fun onVideoAdPaused(entity: AdEntity?) {
LogUtil.d(TAG, "override onVideoAdPaused")
// stopDownloadTime()
// pauseDownloadTime()
}
override fun onVideoAdComplete(entity: AdEntity?) {
LogUtil.d(TAG, "override onVideoAdComplete")
// addVedioIdList(entity?.reqId!!)
// stopDownloadTime()
// pauseDownloadTime()
}
override fun onVideoAdStartPlay(entity: AdEntity?) {
......@@ -209,7 +213,7 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
LogUtil.d(TAG, "override onVideoError")
LogUtil.d("MainFragment", "code:${code} entity:${entity?.toString()}")
// stopDownloadTime()
// pauseDownloadTime()
}
override fun onVideoAdContinuePlay(entity: AdEntity?) {
......@@ -254,24 +258,24 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
com.yilan.sdk.player.utils.Constant.STATE_ERROR -> {
LogUtil.d(TAG, "type STATE_ERROR")
stopDownloadTime()
pauseDownloadTime()
}
com.yilan.sdk.player.utils.Constant.STATE_PLAYING -> {
LogUtil.d(TAG, "type STATE_PLAYING")
startDownloadTime(data.videoId)
resumeDownloadTime(data.videoId)
}
com.yilan.sdk.player.utils.Constant.STATE_COMPLETE -> {
LogUtil.d(TAG, "type STATE_COMPLETE")
addVedioIdList(data.videoId)
stopDownloadTime()
pauseDownloadTime()
}
com.yilan.sdk.player.utils.Constant.STATE_PAUSED -> {
LogUtil.d(TAG, "type STATE_PAUSED")
stopDownloadTime()
pauseDownloadTime()
}
}
false
......@@ -301,7 +305,7 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
/**
* 倒计时红包暂停
*/
private fun stopDownloadTime() {
private fun pauseDownloadTime() {
isClickStop = true
cdvvYilanTime?.pause()
}
......@@ -309,10 +313,10 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
/**
*用户主动暂时或网络异常结束后 重新加载倒计时红包
*/
private fun startDownloadTime(id: String) {
private fun resumeDownloadTime(id: String) {
if (!TextUtils.isEmpty(id)) {
LogUtil.d(TAG, "startDownloadTime cur id:" + id)
LogUtil.d(TAG, "startDownloadTime ListItem:" + JsonUtil.toJson(vedioIdList))
LogUtil.d(TAG, "resumeDownloadTime cur id:" + id)
LogUtil.d(TAG, "resumeDownloadTime ListItem:" + JsonUtil.toJson(vedioIdList))
if (vedioIdList.contains(id)) {
cdvvYilanTime?.pause()
return
......@@ -325,6 +329,15 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
}
}
/**
* 停止转动
*/
private fun stopDownloadTime() {
// 暂停
isClickStop = true
cdvvYilanTime?.stop()
}
/**
* 红包倒计时初始化
*/
......@@ -332,7 +345,8 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
cdvvYilanTime.setCountDownVedioListener(object : CountDownVedioView.CountDownVedioListener {
override fun finish() {
cdvvYilanTime?.showRedbox()
cdvvYilanTime?.stopStatus()
stopDownloadTime()
homePresenter.requestAddHomeVedioReward()
}
})
......
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