Commit 6e0b7e23 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 7f9289e1
......@@ -86,8 +86,7 @@ object LocalVedioManager {
activity: Activity,
data: VedioBean?,
isPlayNext: Boolean = false,
isThirdId: Boolean = false,
isSplash: Boolean = false
isThirdId: Boolean = false
) {
if (data?.createType == 1) {
//自有短剧
......@@ -95,17 +94,14 @@ 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, TxVideoActivity::class.java, bundle)
} else {
requestDrama(activity, data, isSplash)
requestDrama(activity, data)
}
}
// 请求穿山甲数据
private fun requestDrama(activity: Activity, data: VedioBean?, isSplash: Boolean) {
private fun requestDrama(activity: Activity, data: VedioBean?) {
if (DPSdk.isStartSuccess() && data != null) {
DPSdk.factory().requestDrama(
arrayListOf(data.thirdId.toLong()), object : IDPWidgetFactory.DramaCallback {
......@@ -122,9 +118,6 @@ 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)
}
......
......@@ -184,4 +184,31 @@ class HomePresenter : BasePresenter<HomeView>() {
}
})
}
fun getSoltVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getSoltVedio(),
object : BaseSubscriber<BaseResponse<IndexList>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<IndexList>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.getSoltVedioSuc(baseResponse.data)
}
}
}
})
}
}
\ No newline at end of file
package com.xinfu.helivideo.mvp.presenters;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.google.gson.JsonObject;
......@@ -111,7 +113,6 @@ public class TrackPresenter extends BaseTrackPresenter {
switch (baseResponse.getStatus()) {
case 200: {
getMyInfo();
getSoltVedio();
}
}
}
......@@ -224,30 +225,4 @@ public class TrackPresenter extends BaseTrackPresenter {
});
}
public void getSoltVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getSoltVedio(),
new BaseSubscriber<BaseResponse<IndexList>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<IndexList> baseResponse) {
switch (baseResponse.getStatus()) {
case 200: {
IndexList data = baseResponse.getData();
if (data != null && data.getVedioMsg() != null) {
AppPreferencesManager.INSTANCE.get().put(Constant.IS_FIRST_VEDIO, true);
LocalVedioManager.INSTANCE.commitVedio(data.getVedioMsg());
}
}
}
}
});
}
}
......@@ -2,10 +2,12 @@ package com.xinfu.helivideo.mvp.views
import com.xinfu.helivideo.mvp.model.BannerList
import com.xinfu.helivideo.mvp.model.HotStyleTypesList
import com.xinfu.helivideo.mvp.model.IndexList
interface HomeView : BaseView {
fun getHomeV1MsgSuc(data: HotStyleTypesList)
fun topTabsSuc(data: BannerList?)
fun ordersSuc(data: BannerList?)
fun getSoltVedioSuc(data: IndexList?)
}
......@@ -143,38 +143,7 @@ class SplashActivity : BaseActivity() {
* 跳转到主页面
*/
private fun goToMainActivity() {
// val vipEnter = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VIP_BTN, false)
// if ((UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) || !vipEnter) {
val firstVedio = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VEDIO, false)
if (firstVedio) {
// 匹配用户 进来后直接播放剧
AppPreferencesManager.get().put(Constant.IS_FIRST_VEDIO, false)
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio, isSplash = true)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
// 匹配用户 且 不是vip
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
// 匹配用户 且 不是vip
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
readyGoThenKill(MainActivity::class.java)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
......
......@@ -96,38 +96,7 @@ class SplashAdActivity : BaseActivity() {
* 跳转到主页面
*/
private fun goToMainActivity() {
// val vipEnter = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VIP_BTN, false)
// if ((UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) || !vipEnter) {
val firstVedio = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VEDIO, false)
if (firstVedio) {
// 匹配用户 进来后直接播放剧
AppPreferencesManager.get().put(Constant.IS_FIRST_VEDIO, false)
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
LocalVedioManager.startVedioDetailActivityForType(this, cacheVedio, isSplash = true)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
// 匹配用户 且 不是vip
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// AppPreferencesManager.get().put(Constant.IS_FIRST_VIP_BTN, true)
// 匹配用户 且 不是vip
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
readyGoThenKill(MainActivity::class.java)
}
/**
......
......@@ -71,6 +71,10 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
override fun getContentViewLayoutID() = R.layout.activity_vip
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.BOTTOM
override fun isApplyKitKatTranslucency() = false
override fun getBundleExtras(extras: Bundle?) {
......@@ -93,6 +97,12 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
initListener()
}
override fun finish() {
super.finish()
//关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out)
}
override fun onDestroy() {
super.onDestroy()
......
package com.xinfu.helivideo.ui.fragment
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.xinfu.library.utils.GlideUtils
import com.xinfu.library.utils.nodoubleclick.AntiShake
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.xinfu.helivideo.R
import com.xinfu.helivideo.common.AppConfig
import com.xinfu.helivideo.common.Constant
......@@ -21,12 +22,15 @@ import com.xinfu.helivideo.manager.UserManager
import com.xinfu.helivideo.mvp.model.*
import com.xinfu.helivideo.mvp.presenters.HomePresenter
import com.xinfu.helivideo.mvp.views.HomeView
import com.xinfu.helivideo.ui.activitys.VipActivity
import com.xinfu.helivideo.ui.adapter.HomeVideoPageAdapter
import com.xinfu.helivideo.ui.adapter.ImageTitleAdapter
import com.xinfu.helivideo.ui.adapter.TopAdapter
import com.xinfu.helivideo.ui.fragment.base.LazyLoadBaseFragment
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.xinfu.helivideo.utils.AppPreferencesManager
import com.xinfu.helivideo.utils.AppPreferencesManager.get
import com.xinfu.library.utils.GlideUtils
import com.xinfu.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.fragment_main.*
import java.util.*
import kotlin.concurrent.schedule
......@@ -61,6 +65,24 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
initVp()
initListener()
loadData()
Handler(Looper.getMainLooper()).postDelayed({
goToMainActivity()
}, 300)
}
/**
* 跳转到主页面
*/
private fun goToMainActivity() {
val firstVedio = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VEDIO, false)
if (firstVedio) {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
readyGo(VipActivity::class.java)
}
} else {
homePresenter.getSoltVedio()
}
}
override fun onDestroy() {
......@@ -205,7 +227,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
fun setWatchingStatus() {
if (LocalVedioManager.isCacheVedio()) {
ll_main_watching_root.visibility = View.VISIBLE
ll_main_watching_root.setOnClickListener { }
ll_main_watching_root.setOnClickListener { }
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
GlideUtils.loadImageViewGifForCenterCrop(
......@@ -266,6 +288,13 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
topAdapter?.notifyDataSetChanged()
}
override fun getSoltVedioSuc(data: IndexList?) {
get().put(Constant.IS_FIRST_VEDIO, true)
if (data != null && data.vedioMsg != null) {
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), data.vedioMsg)
}
}
override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
if (isHidden) {
......
......@@ -83,7 +83,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private var isThirdId = false
private var isPlayNext = false
private var isSplashEnter = false
private var mode = DPDramaDetailConfig.SPECIFIC_DETAIL
......@@ -96,7 +95,6 @@ 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)
......@@ -174,11 +172,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
.commit()
leaveBtn?.setOnClickListener {
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
finish()
}
vipBtn?.setOnClickListener {
val bundle = Bundle()
......@@ -191,19 +185,6 @@ 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(
......
......@@ -46,7 +46,6 @@ 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
......@@ -60,7 +59,6 @@ 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
if (isPlayNext) {
......@@ -113,28 +111,12 @@ 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 -> {
if (isSplashEnter) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
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