Commit e5afc4d7 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 7b01b929
...@@ -186,7 +186,7 @@ public interface LoanService { ...@@ -186,7 +186,7 @@ public interface LoanService {
* *
* @return * @return
*/ */
@POST("api/vedio/topTabs") @POST("api/vedio/topTabs/v0821")
Observable<BaseResponse<BannerList>> topTabs(); Observable<BaseResponse<BannerList>> topTabs();
/** /**
......
package com.duben.happyplaylet.ui.activitys package com.duben.happyplaylet.ui.activitys
import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
...@@ -17,12 +18,16 @@ import com.duben.happyplaylet.mvp.model.NineShowBean ...@@ -17,12 +18,16 @@ import com.duben.happyplaylet.mvp.model.NineShowBean
import com.duben.happyplaylet.mvp.presenters.NinePresenter import com.duben.happyplaylet.mvp.presenters.NinePresenter
import com.duben.happyplaylet.mvp.views.NineView import com.duben.happyplaylet.mvp.views.NineView
import com.duben.happyplaylet.ui.activitys.base.BaseActivity import com.duben.happyplaylet.ui.activitys.base.BaseActivity
import com.duben.happyplaylet.ui.widgets.DialogListener
import com.duben.happyplaylet.ui.widgets.NineContinueDialog
import com.duben.happyplaylet.utils.AppPreferencesManager import com.duben.happyplaylet.utils.AppPreferencesManager
import com.duben.happyplaylet.utils.SplitArrayUtils import com.duben.happyplaylet.utils.SplitArrayUtils
import com.duben.happyplaylet.utils.rxutil.CommonRxTask import com.duben.happyplaylet.utils.rxutil.CommonRxTask
import com.duben.happyplaylet.utils.rxutil.RxjavaUtil import com.duben.happyplaylet.utils.rxutil.RxjavaUtil
import com.duben.library.utils.nodoubleclick.AntiShake import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_nine.* import kotlinx.android.synthetic.main.activity_nine.*
import kotlinx.android.synthetic.main.activity_nine.btn_action
import kotlinx.android.synthetic.main.activity_nine.tv_nine_count
/** /**
* 描述:9宫格手机 * 描述:9宫格手机
...@@ -30,11 +35,16 @@ import kotlinx.android.synthetic.main.activity_nine.* ...@@ -30,11 +35,16 @@ import kotlinx.android.synthetic.main.activity_nine.*
*/ */
class NineActivity : BaseActivity(), View.OnClickListener, NineView { class NineActivity : BaseActivity(), View.OnClickListener, NineView {
companion object {
val IS_AD_SHOW = "IS_AD_SHOW"
}
private val ninePresenter by lazy { NinePresenter() } private val ninePresenter by lazy { NinePresenter() }
private var yoyo: YoYo.YoYoString? = null private var yoyo: YoYo.YoYoString? = null
val luckyIndexMap: MutableMap<Int, String> = HashMap() val luckyIndexMap: MutableMap<Int, String> = HashMap()
private var nineShowBean: NineShowBean? = null private var nineShowBean: NineShowBean? = null
var carrierType = Constant.CARRIERTYPE_NINE var carrierType = Constant.CARRIERTYPE_NINE
var isAdShow = false
override fun getContentViewLayoutID() = R.layout.activity_nine override fun getContentViewLayoutID() = R.layout.activity_nine
...@@ -44,6 +54,13 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -44,6 +54,13 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
isAdShow = it.getBoolean(IS_AD_SHOW, false)
}
}
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
ninePresenter.attachView(this) ninePresenter.attachView(this)
ninePresenter.getTurnIphoneMsg() ninePresenter.getTurnIphoneMsg()
...@@ -71,6 +88,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -71,6 +88,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
private fun initListener() { private fun initListener() {
btn_action.setOnClickListener(this) btn_action.setOnClickListener(this)
rl_lucky.setOnClickListener(this)
iv_nine_back.setOnClickListener(this) iv_nine_back.setOnClickListener(this)
} }
...@@ -86,20 +104,24 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -86,20 +104,24 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
R.id.iv_nine_back -> { R.id.iv_nine_back -> {
finish() finish()
} }
R.id.btn_action -> { R.id.btn_action, R.id.rl_lucky -> {
if (luckyIndexMap.size == 0) { if (luckyIndexMap.size == 0) {
showToast("界面初始异常,请重新进入") showToast("界面初始异常,请重新进入")
return return
} }
if (nineShowBean != null) { if (isAdShow) {
if (nineShowBean!!.complete >= nineShowBean!!.need) { luckyAward()
luckyAward() } else {
} else { if (nineShowBean != null) {
val bundle = Bundle() if (nineShowBean!!.complete >= nineShowBean!!.need) {
bundle.putInt(NineKnowActivity.COMPLETE,nineShowBean!!.complete) luckyAward()
bundle.putInt(NineKnowActivity.NEED, nineShowBean!!.need) } else {
readyGoThenKill(NineKnowActivity::class.java, bundle) val bundle = Bundle()
bundle.putInt(NineKnowActivity.COMPLETE, nineShowBean!!.complete)
bundle.putInt(NineKnowActivity.NEED, nineShowBean!!.need)
readyGoThenKill(NineKnowActivity::class.java, bundle)
}
} }
} }
} }
...@@ -108,6 +130,14 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -108,6 +130,14 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
override fun unlockSuc() { override fun unlockSuc() {
ninePresenter.showTurn() ninePresenter.showTurn()
if (isAdShow) {
if (nineShowBean != null) {
if (nineShowBean!!.complete < nineShowBean!!.need) {
showContinueDialog()
}
}
}
} }
override fun getTurnIphoneMsgSuc(data: NineListBean) { override fun getTurnIphoneMsgSuc(data: NineListBean) {
...@@ -148,7 +178,14 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -148,7 +178,14 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
ninePresenter.toTurn() ninePresenter.toTurn()
} }
// 展示 5/20 // 展示 5/20
tv_nine_count.text = "${data.complete}/${data.need}次" if (isAdShow) {
tv_nine_count.visibility = View.VISIBLE
tv_nine_count.text = "${data.complete}/${data.need}次"
btn_action.setBackgroundResource(R.mipmap.ic_luckly_btn)
} else {
btn_action.setBackgroundResource(R.mipmap.ic_lucky_vedio)
tv_nine_count.visibility = View.GONE
}
} }
private fun luckyAward() { private fun luckyAward() {
...@@ -260,4 +297,20 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -260,4 +297,20 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
messages.add("恭喜用户151******64抽中 +14天会员") messages.add("恭喜用户151******64抽中 +14天会员")
marqueeView.startWithList(SplitArrayUtils.getRandomList(messages) as List<Nothing>?) marqueeView.startWithList(SplitArrayUtils.getRandomList(messages) as List<Nothing>?)
} }
// 继续观看逻辑
private fun showContinueDialog() {
nineShowBean?.let {
NineContinueDialog(
this@NineActivity,
it.need - it.complete - 1,
object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
luckyAward()
}
}).show()
}
}
} }
\ No newline at end of file
...@@ -189,7 +189,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -189,7 +189,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (topList.size > 0) { if (topList.size > 0) {
LocalVedioManager.startVedioDetailActivityForType( LocalVedioManager.startVedioDetailActivityForType(
requireActivity(), requireActivity(),
topList.get(position) topList[position]
) )
} }
} }
...@@ -299,10 +299,19 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -299,10 +299,19 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
banner.addBannerLifecycleObserver(this) banner.addBannerLifecycleObserver(this)
.setAdapter(ImageTitleAdapter(bannerList)) .setAdapter(ImageTitleAdapter(bannerList))
.setOnBannerListener { data2, position -> .setOnBannerListener { data2, position ->
LocalVedioManager.startVedioDetailActivityForType( val banner = data.list.get(position)
requireActivity(), if (banner.createType == 4) {
data.list.get(position) // 九宫格
) val bundle = Bundle()
bundle.putBoolean(NineActivity.IS_AD_SHOW, true)
readyGo(NineActivity::class.java, bundle)
} else {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
banner
)
}
} }
} }
} }
...@@ -343,7 +352,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -343,7 +352,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
return return
} else { } else {
ll_lucky.visibility = View.VISIBLE ll_lucky.visibility = View.VISIBLE
context?.let { GlideUtils.loadRoundImageViewGif(it,R.drawable.ic_nine,iv_lucky_gif) } context?.let { GlideUtils.loadRoundImageViewGif(it, R.drawable.ic_nine, iv_lucky_gif) }
} }
val complete = data.complete val complete = data.complete
......
...@@ -221,7 +221,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -221,7 +221,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
myPresenter.showTurn() myPresenter.showTurn()
if (nineShowBean != null) { if (nineShowBean != null) {
if (nineShowBean!!.complete < nineShowBean!!.need) { if (nineShowBean!!.need - nineShowBean!!.complete-1>0) {
showContinueDialog() showContinueDialog()
} }
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/rl_lucky"
android:layout_width="315dp" android:layout_width="315dp"
android:layout_height="315dp" android:layout_height="315dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
......
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