Commit 68056377 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 94b36144
......@@ -7,6 +7,7 @@ object Constant {
const val VEDIO_BEAN = "VEDIO_BEAN"
const val VEDIO_NEXT = "VEDIO_NEXT"
const val VEDIO_THIRD = "VEDIO_THIRD"
const val VEDIO_SPLASH = "VEDIO_SPLASH"
/**
* 首次弹出权限声明
......
......@@ -86,7 +86,8 @@ object LocalVedioManager {
activity: Activity,
data: VedioBean?,
isPlayNext: Boolean = false,
isThirdId: Boolean = false
isThirdId: Boolean = false,
isSplash: Boolean = false
) {
if (data?.createType == 1) {
//自有短剧
......@@ -94,15 +95,18 @@ object LocalVedioManager {
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext)
bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId)
if (isSplash) {
bundle.putBoolean(Constant.VEDIO_SPLASH, true)
}
// readyGo(activity, VideoActivity::class.java, bundle)
readyGo(activity, TxVideoActivity::class.java, bundle)
} else {
requestDrama(activity, data)
requestDrama(activity, data, isSplash)
}
}
// 请求穿山甲数据
private fun requestDrama(activity: Activity, data: VedioBean?) {
private fun requestDrama(activity: Activity, data: VedioBean?, isSplash: Boolean) {
if (DPSdk.isStartSuccess() && data != null) {
DPSdk.factory().requestDrama(
arrayListOf(data.thirdId.toLong()), object : IDPWidgetFactory.DramaCallback {
......@@ -119,6 +123,9 @@ object LocalVedioManager {
//穿山甲短剧
val bundle = Bundle()
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
if (isSplash) {
bundle.putBoolean(Constant.VEDIO_SPLASH, true)
}
readyGo(activity, DramaApiDetailActivity::class.java, bundle)
}
......
......@@ -152,7 +152,7 @@ class SplashActivity : BaseActivity() {
AppPreferencesManager.get().put(Constant.IS_FIRST_VEDIO, false)
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio)
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio, isSplash = true)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
......
......@@ -105,7 +105,7 @@ class SplashAdActivity : BaseActivity() {
AppPreferencesManager.get().put(Constant.IS_FIRST_VEDIO, false)
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio)
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio, isSplash = true)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
......
......@@ -3,6 +3,7 @@ package com.xinfu.helivideo.video
import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.view.KeyEvent
import android.view.View
import android.widget.Button
import android.widget.ImageView
......@@ -23,6 +24,7 @@ import com.xinfu.helivideo.mvp.model.IndexList
import com.xinfu.helivideo.mvp.model.VedioBean
import com.xinfu.helivideo.mvp.presenters.VideoPresenter
import com.xinfu.helivideo.mvp.views.VideoView
import com.xinfu.helivideo.ui.activitys.MainActivity
import com.xinfu.helivideo.ui.activitys.VipActivity
import com.xinfu.helivideo.ui.activitys.base.BaseActivity
import com.xinfu.helivideo.ui.adapter.VideoEpisodeAdapter
......@@ -81,6 +83,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private var isThirdId = false
private var isPlayNext = false
private var isSplashEnter = false
private var mode = DPDramaDetailConfig.SPECIFIC_DETAIL
......@@ -92,6 +96,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
val json = extras?.getString(Constant.VEDIO_BEAN)
isThirdId = extras?.getBoolean(Constant.VEDIO_THIRD, false) == true
isPlayNext = extras?.getBoolean(Constant.VEDIO_NEXT, false) == true
isSplashEnter = extras?.getBoolean(Constant.VEDIO_SPLASH, false) == true
mVedioBean = Gson().fromJson(json, VedioBean::class.java)
orderTagsList = mVedioBean?.orderTags
......@@ -167,7 +173,11 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
.commit()
leaveBtn?.setOnClickListener {
finish()
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
vipBtn?.setOnClickListener {
val bundle = Bundle()
......@@ -180,6 +190,19 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
isInited = true
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
}
return true
}
private fun initWidget() {
drama?.let { drama ->
dpWidget = DPSdk.factory().createDramaDetail(
......
......@@ -4,6 +4,7 @@ import android.app.Dialog
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.KeyEvent
import android.view.View
import com.google.gson.Gson
import com.xinfu.helivideo.R
......@@ -12,12 +13,14 @@ import com.xinfu.helivideo.ad.AdStatusListener
import com.xinfu.helivideo.ad.NoPreAdManager
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.model.IndexList.VedioEpisodeBean
import com.xinfu.helivideo.mvp.model.VedioBean
import com.xinfu.helivideo.mvp.model.VideoMultiItemEntity
import com.xinfu.helivideo.mvp.presenters.VideoPresenter
import com.xinfu.helivideo.mvp.views.VideoView
import com.xinfu.helivideo.ui.activitys.MainActivity
import com.xinfu.helivideo.ui.activitys.VipActivity
import com.xinfu.helivideo.ui.activitys.base.BaseActivity
import com.xinfu.helivideo.ui.adapter.VideoEpisodeAdapter
......@@ -27,6 +30,7 @@ import com.xinfu.helivideo.ui.widgets.VipCountDialog
import com.xinfu.helivideo.video.tx.adapter.TxVideoAdapter
import com.xinfu.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_tx_video.*
import kotlinx.android.synthetic.main.activity_vip.*
class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
VideoEpisodeAdapter.OnEpisodeClickListener, TxVideoAdapter.OnCustomChildClickListener {
......@@ -43,6 +47,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
private var orderTagsList: ArrayList<String>? = null
private var isPlayNext = false
private var isSplashEnter = false
private var playIndex = 1
override fun getContentViewLayoutID() = R.layout.activity_tx_video
......@@ -56,6 +61,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
override fun getBundleExtras(extras: Bundle?) {
val json = extras?.getString(Constant.VEDIO_BEAN)
isPlayNext = extras?.getBoolean(Constant.VEDIO_NEXT, false) == true
isSplashEnter = extras?.getBoolean(Constant.VEDIO_SPLASH, false) == true
mVedioBean = Gson().fromJson(json, VedioBean::class.java)
orderTagsList = mVedioBean?.orderTags
super.getBundleExtras(extras)
......@@ -94,7 +100,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
// VIdeoindex -> seeIndex
if (videos.size > it) {
mVedioBean!!.seeIndex = videos[it].vedioIndex
mVedioBean!!.orderTags=orderTagsList
mVedioBean!!.orderTags = orderTagsList
LocalVedioManager.commitVedio(mVedioBean!!)
}
}
......@@ -103,11 +109,28 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
close_iv.setOnClickListener(this)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
}
return true
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.close_iv -> {
finish()
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
R.id.fm_bottom -> {
showEpisodeDialog()
......
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