Commit 304daf1f authored by jyx's avatar jyx

代码优化

parent bff94e60
package com.xinfu.helivideo.video
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
......@@ -14,7 +13,6 @@ import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.bytedance.sdk.dp.*
import com.google.gson.Gson
import com.xinfu.helivideo.MintsApplication
import com.xinfu.helivideo.R
import com.xinfu.helivideo.ad.AdManager
import com.xinfu.helivideo.ad.AdStatusListener
......@@ -33,9 +31,6 @@ import com.xinfu.helivideo.ui.widgets.VideoEpisodeDialog
import com.xinfu.helivideo.ui.widgets.VipCountDialog
import com.xinfu.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.drama_activity_api_detail.*
import kotlinx.android.synthetic.main.drama_activity_api_detail.episode_tv
import kotlinx.android.synthetic.main.drama_activity_api_detail.fm_bottom
import org.json.JSONObject
/**
* @author Assen
......@@ -46,20 +41,13 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
VideoView, View.OnClickListener {
companion object {
const val KEY_DRAMA_HISTORY = "drama_history"
private const val TAG = "DramaApiDetailActivity"
const val IS_FROM_CARD = "is_from_card"
const val FROM_GID = "from_gid"
var outerDrama: DPDrama? = null
}
private val videoPresenter by lazy { VideoPresenter() }
private var sp =
MintsApplication.getContext().getSharedPreferences("pangrowth", Context.MODE_PRIVATE)
private var dpWidget: IDPWidget? = null
private var isInited = false
private var drama: DPDrama? = null
......@@ -98,6 +86,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private var mVedioBean: VedioBean? = null
private var mCurrentIndex = 0
override fun getBundleExtras(extras: Bundle?) {
val json = extras?.getString(Constant.VEDIO_BEAN)
isThirdId = extras?.getBoolean(Constant.VEDIO_THIRD, false) == true
......@@ -138,6 +128,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
drama = outerDrama
drama?.let {
it.index = mVedioBean!!.seeIndex
mCurrentIndex = mVedioBean!!.seeIndex
mInitUnlockIndex = mVedioBean!!.unlockIndex
mUnlockIndexMap[it.id] = mInitUnlockIndex
mHasUnlockIndexMap[it.id] = arrayListOf(mInitUnlockIndex)
......@@ -151,10 +142,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
unlock.text = String.format("看广告解锁%d集", lockSet)
if (mVedioBean!!.collect == 0) {
setCollectImage(zan_iv)
// zan_iv.setImageResource(R.mipmap.home_collect_img_0)
} else {
setCancelCollectImage(zan_iv)
// zan_iv.setImageResource(R.mipmap.home_collect_img_1)
}
zan_num_tv.text = mVedioBean!!.hot
}
......@@ -216,24 +205,12 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
}
override fun onDestroy() {
super.onDestroy()
dpWidget?.destroy()
super.onDestroy()
}
override fun onPause() {
super.onPause()
drama?.let {
val json = JSONObject()
json.put("id", drama?.id)
json.put("status", drama?.status)
json.put("total", drama?.total)
json.put("title", drama?.title)
json.put("cover_image", drama?.coverImage)
json.put("index", lastIndex)
json.put("class", drama?.type)
json.put("desc", drama?.desc)
sp.edit().putString(KEY_DRAMA_HISTORY, json.toString()).apply()
}
}
private val dramaAdListener: IDPAdListener = object : IDPAdListener() {
......@@ -356,18 +333,21 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
)
info_tv.text = String.format("第%d集", index)
dialog?.setCurrentIndex(index)
if (mUnlockIndexMap[drama.id]!! > index) {
blockView?.visibility = View.GONE
}
// if (mUnlockIndexMap[drama.id]!! > index) {
// blockView?.visibility = View.GONE
// }
mCurrentIndex = index
showVipCountDialog(index - 1)
val needBlock = index > unlockIndex && hasUnlockList.contains(index).not()
if (!needBlock) {
blockView?.visibility = View.GONE
// 上送视频信息,若未解锁不上送
mVedioBean!!.seeIndex = index
mVedioBean!!.orderTags = orderTagsList
LocalVedioManager.commitVedio(mVedioBean!!)
showVipCountDialog(index - 1)
if (mCurrentIndex <= mVedioBean!!.unlockIndex) {
mVedioBean!!.seeIndex = index
mVedioBean!!.orderTags = orderTagsList
LocalVedioManager.commitVedio(mVedioBean!!)
}
}
return needBlock
......@@ -514,7 +494,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
}
})
dialog?.setOnEpisodeClickListener(this)
dialog?.setCurrentIndex(mVedioBean!!.seeIndex - 1)
dialog?.setCurrentIndex(mCurrentIndex - 1)
dialog?.show()
}
......@@ -616,9 +596,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
if (position == 0 || mVedioBean!!.tipMaxIndex == 0 || mVedioBean!!.tipMaxIndex - 1 < position) return
VipCountDialog(this, mVedioBean!!, tipList)
.setOnDialogDismiss(object : VipCountDialog.OnDialogDismiss {
override fun onDialogDismiss() {
}
override fun onDialogDismiss() {}
})
.show()
}
......
......@@ -13,7 +13,6 @@ import com.xinfu.helivideo.R
import com.xinfu.helivideo.common.AppConfig
import com.xinfu.helivideo.common.Constant
import com.xinfu.helivideo.manager.LocalVedioManager
import com.xinfu.helivideo.manager.UserManager
import com.xinfu.helivideo.mvp.model.IndexList
import com.xinfu.helivideo.mvp.presenters.VideoPresenter
import com.xinfu.helivideo.mvp.views.VideoView
......@@ -204,6 +203,8 @@ class DramaTabFragment : BaseFragment(), VideoView {
override fun onDPVideoCompletion(map: Map<String, Any>) {
Log.d(TAG, "onDPVideoCompletion: $map")
// dpWidget?.fragment?.onPause()
// videoPresenter.getIndexList("" + map["drama_id"], true)
}
override fun onDPVideoOver(map: Map<String, Any>) {
......
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