Commit 447910b6 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4fe678f9
...@@ -103,7 +103,12 @@ ...@@ -103,7 +103,12 @@
android:exported="false" android:exported="false"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.WxLoginActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity <activity
android:name=".ui.activitys.MainActivity" android:name=".ui.activitys.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
......
...@@ -67,7 +67,6 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -67,7 +67,6 @@ class HomePresenter : BasePresenter<HomeView>() {
when (code) { when (code) {
200 -> { 200 -> {
view.topTabsSuc(baseResponse.data) view.topTabsSuc(baseResponse.data)
showTurn()
} }
else -> { else -> {
view.showToast(message) view.showToast(message)
...@@ -77,46 +76,9 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -77,46 +76,9 @@ class HomePresenter : BasePresenter<HomeView>() {
}) })
} }
private fun showTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.showTurn(),
object : BaseSubscriber<BaseResponse<NineShowBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<NineShowBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
val data = baseResponse.data
if (data != null) {
view.showTurnSuc(data)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_FLAG, data.isShow)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_COMPLETE, data.complete)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_NEED, data.need)
}
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
}
})
}
fun orders() { fun orders() {
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.orders(), .call(loanService.history(),
object : BaseSubscriber<BaseResponse<BannerList>>() { object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
...@@ -224,57 +186,4 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -224,57 +186,4 @@ 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)
}
}
}
})
}
fun getRecommendVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getRecommendVedio(),
object : BaseSubscriber<BaseResponse<RecoBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<RecoBean>) {
if (isLinkView) return
val code = baseResponse.status
when (code) {
200 -> {
view.getRecommendVedioSuc(baseResponse.data)
}
}
}
})
}
} }
\ No newline at end of file
...@@ -7,8 +7,4 @@ interface HomeView : BaseView { ...@@ -7,8 +7,4 @@ interface HomeView : BaseView {
fun getHomeV1MsgSuc(data: HotStyleTypesList) fun getHomeV1MsgSuc(data: HotStyleTypesList)
fun topTabsSuc(data: BannerList?) fun topTabsSuc(data: BannerList?)
fun ordersSuc(data: BannerList?) fun ordersSuc(data: BannerList?)
fun getSoltVedioSuc(data: IndexList?)
fun getRecommendVedioSuc(data: RecoBean?)
fun showTurnSuc(data: NineShowBean)
} }
package com.mints.helivideo.ui.activitys
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import androidx.core.content.ContextCompat
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.mints.helivideo.MintsApplication
import com.mints.helivideo.R
import com.mints.helivideo.common.Constant
import com.mints.helivideo.login.LoginApi
import com.mints.helivideo.login.OnLoginListener
import com.mints.helivideo.mvp.model.WXInfo
import com.mints.helivideo.mvp.presenters.LoginPresenter
import com.mints.helivideo.mvp.views.LoginView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.utils.CommonUtils
import com.mints.helivideo.utils.SpanUtils
import com.mints.helivideo.utils.ToastUtil
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_wx_login.*
/**
* 描述:微信登录
* 作者:孟崔广
* 时间:2020/12/2 13:50
*/
class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLoginListener {
private val loginPresenter by lazy { LoginPresenter() }
private val loginApi by lazy { LoginApi() }
private var wxInfo: WXInfo? = null
private var channel: String = ""
private var isCheckAgree = false
override fun getContentViewLayoutID() = R.layout.activity_wx_login
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.BOTTOM
override fun isApplyKitKatTranslucency() = false
override fun initViewsAndEvents() {
loginPresenter.attachView(this)
channel = CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
initView()
initListener()
}
override fun onDestroy() {
super.onDestroy()
loginApi.setOnLoginListener(null)
loginPresenter.detachView()
}
override fun finish() {
super.finish()
//关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out)
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.ivLoginBack -> {
finish()
}
R.id.tvLoginMobile -> {
readyGo(MobileLoginActivity::class.java)
}
R.id.rlLoginWx -> {
if (!isCheckAgree) {
ToastUtil.showLong(context,"请勾选同意后再进行登录")
llWxloginCheck.postDelayed({
YoYo.with(Techniques.Shake).duration(500).repeat(2).playOn(llWxloginCheck)
}, 200)
return
}
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
return
}
// RxPermissions(this)
// .request(Manifest.permission.READ_PHONE_STATE)
// .subscribe { granted: Boolean ->
// if (granted) {
// loginApi.setOnLoginListener(this@WxLoginActivity)
// loginApi.setPlatform(Wechat.NAME)
// loginApi.login(this@WxLoginActivity)
// } else {
// showMissingPermissionDialog("设备")
// }
// }
loginApi.setOnLoginListener(this@WxLoginActivity)
loginApi.setPlatform(Wechat.NAME)
loginApi.login(this@WxLoginActivity)
// readyGo(TestActivity::class.java)
}
}
}
override fun loginSuc() {
showToast("登录成功")
hideLoading()
Handler(Looper.getMainLooper()).postDelayed({
readyGoThenKill(MainActivity::class.java)
}, 1000)
}
override fun sendCodeSuc() {
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.unionid = res["unionid"].toString() + ""
it.openid = res["openid"].toString() + ""
it.province = res["province"].toString() + ""
it.city = res["city"].toString() + ""
it.country = res["country"].toString() + ""
it.headimgurl = res["headimgurl"].toString() + ""
it.nickname = res["nickname"].toString() + ""
it.sex = (res["sex"].toString() + "").toInt()
}
if (!isFinishing) {
loginPresenter.login(JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
private fun initView() {
SpanUtils.with(tvLoginAgreement)
.append("已阅读并同意")
.append("《用户注册协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.register_name))
bundle.putString(WebActivity.WEB_URL, Constant.REGISTER_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = ContextCompat.getColor(mContext, R.color.color_FF9837)
ds.isUnderlineText = false
}
})
.append("、")
.append("《用户隐私协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.privacy_name))
bundle.putString(WebActivity.WEB_URL, Constant.PRIVACY_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = ContextCompat.getColor(mContext, R.color.color_FF9837)
ds.isUnderlineText = false
}
})
.append("与您的利益切身相关。请您注册前务必仔细阅读!")
.create()
}
private fun initListener() {
ivLoginBack.setOnClickListener(this)
tvLoginMobile.setOnClickListener(this)
rlLoginWx.setOnClickListener(this)
wxloginCheck.setOnCheckedChangeListener { buttonView, isChecked ->
this.isCheckAgree = isChecked
}
}
}
...@@ -22,10 +22,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) : ...@@ -22,10 +22,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val rlTopItemRoot: LinearLayout = view.findViewById(R.id.rlTopItemRoot) val rlTopItemRoot: LinearLayout = view.findViewById(R.id.rlTopItemRoot)
val ivTopItem: ImageView = view.findViewById(R.id.ivTopItem) val ivTopItem: ImageView = view.findViewById(R.id.ivTopItem)
val tvTopItemLable: TextView = view.findViewById(R.id.tvTopItemLable)
val tvTopItemCount: TextView = view.findViewById(R.id.tvTopItemCount)
val tvTopItemTitle: TextView = view.findViewById(R.id.tvTopItemTitle) val tvTopItemTitle: TextView = view.findViewById(R.id.tvTopItemTitle)
val tvTopItemText: TextView = view.findViewById(R.id.tvTopItemText) val tvTopItemText: TextView = view.findViewById(R.id.tvTopItemText)
val tvTopCurText: TextView = view.findViewById(R.id.tvTopCurText)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
...@@ -38,17 +37,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) : ...@@ -38,17 +37,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val topBean = topList?.get(position) val topBean = topList?.get(position)
if (topBean != null) { if (topBean != null) {
holder.tvTopItemLable.text = "${position + 1}"
holder.tvTopItemCount.text = topBean.showNum
holder.tvTopItemTitle.text = "${topBean.title}" holder.tvTopItemTitle.text = "${topBean.title}"
if (topBean.orderTags != null && topBean.orderTags.size > 0) { holder.tvTopItemText.text = "共${topBean.freeIndex}集"
val sb = StringBuilder() holder.tvTopCurText.text = "观看至第${topBean.seeIndex}集"
for (i in 0 until topBean.orderTags.size) {
sb.append(topBean.orderTags.get(i) + " ")
}
holder.tvTopItemText.text = "${sb}"
}
GlideUtils.loadImageViewGifForCenterCrop( GlideUtils.loadImageViewGifForCenterCrop(
context, context,
topBean.coverImage, topBean.coverImage,
...@@ -56,21 +47,6 @@ class TopAdapter(val topList: MutableList<VedioBean>?) : ...@@ -56,21 +47,6 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
) )
} }
when (position) {
0 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y43)
}
1 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y42)
}
2 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y41)
}
else -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y4)
}
}
holder.rlTopItemRoot.setOnClickListener { holder.rlTopItemRoot.setOnClickListener {
mOnItemClickListener.onItemClick(position) mOnItemClickListener.onItemClick(position)
} }
......
package com.mints.helivideo.ui.fragment package com.mints.helivideo.ui.fragment
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
...@@ -13,8 +10,6 @@ import androidx.recyclerview.widget.RecyclerView ...@@ -13,8 +10,6 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.mints.helivideo.R import com.mints.helivideo.R
import com.mints.helivideo.ad.AdManager import com.mints.helivideo.ad.AdManager
import com.mints.helivideo.ad.banner.BannerManager import com.mints.helivideo.ad.banner.BannerManager
...@@ -26,16 +21,15 @@ import com.mints.helivideo.manager.UserManager ...@@ -26,16 +21,15 @@ import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.* import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.presenters.HomePresenter import com.mints.helivideo.mvp.presenters.HomePresenter
import com.mints.helivideo.mvp.views.HomeView import com.mints.helivideo.mvp.views.HomeView
import com.mints.helivideo.ui.activitys.RecommendActivity import com.mints.helivideo.ui.activitys.WatchRecordActivity
import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter
import com.mints.helivideo.ui.adapter.ImageTitleAdapter import com.mints.helivideo.ui.adapter.ImageTitleAdapter
import com.mints.helivideo.ui.adapter.TopAdapter import com.mints.helivideo.ui.adapter.TopAdapter
import com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment import com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import com.mints.helivideo.utils.AppPreferencesManager
import com.mints.helivideo.utils.SpanUtils
import com.mints.library.utils.GlideUtils import com.mints.library.utils.GlideUtils
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake import com.mints.library.utils.nodoubleclick.AntiShake
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.fragment_main.* import kotlinx.android.synthetic.main.fragment_main.*
import java.lang.reflect.Field import java.lang.reflect.Field
import java.util.* import java.util.*
...@@ -57,7 +51,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -57,7 +51,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
private val topList = mutableListOf<VedioBean>() private val topList = mutableListOf<VedioBean>()
private var vpAdapter: HomeVideoPageAdapter? = null private var vpAdapter: HomeVideoPageAdapter? = null
private var topAdapter: TopAdapter? = null private var topAdapter: TopAdapter? = null
private var recommendVedioBean: RecoBean? = null
private val homePresenter by lazy { HomePresenter() } private val homePresenter by lazy { HomePresenter() }
...@@ -77,26 +70,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -77,26 +70,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (!UserManager.getInstance().vipFlag) { if (!UserManager.getInstance().vipFlag) {
AdManager.instance.preLoadAd(requireActivity()) AdManager.instance.preLoadAd(requireActivity())
} }
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) {
homePresenter.getRecommendVedio()
}
} else {
homePresenter.getSoltVedio()
}
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
...@@ -106,10 +81,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -106,10 +81,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
override fun onFragmentResume() { override fun onFragmentResume() {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) { if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
if (AntiShake.check(banner?.id)) return if (AntiShake.check(banner?.id)) return
// if (!UserManager.getInstance().vipFlag) {
// BannerManager.loadAd(requireActivity(), fl_main_banner)
// }
BannerManager.loadAd(requireActivity(), fl_main_banner) BannerManager.loadAd(requireActivity(), fl_main_banner)
if (AppConfig.exitLoginMainRefresh) { if (AppConfig.exitLoginMainRefresh) {
...@@ -117,7 +88,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -117,7 +88,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
loadData() loadData()
} }
banner?.start() banner?.start()
setWatchingStatus() // setWatchingStatus()
if (TextUtils.isEmpty(userManager?.userID)) { if (TextUtils.isEmpty(userManager?.userID)) {
//获取游客登录数据 //获取游客登录数据
...@@ -126,7 +97,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -126,7 +97,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
homePresenter.topTabs() homePresenter.topTabs()
homePresenter.orders() homePresenter.orders()
TrackManager.getInstance().getMyInfo() TrackManager.getInstance().getMyInfo()
showRecommendAct(recommendVedioBean)
} }
} }
} }
...@@ -139,7 +109,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -139,7 +109,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
srlMainPage.setOnRefreshListener(this) srlMainPage.setOnRefreshListener(this)
iv_main_watching_close.setOnClickListener(this) iv_main_watching_close.setOnClickListener(this)
tv_main_watching_goto.setOnClickListener(this) tv_main_watching_goto.setOnClickListener(this)
ll_lucky.setOnClickListener(this) tv_main_watchmore.setOnClickListener(this)
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
...@@ -148,7 +118,10 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -148,7 +118,10 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
when (v?.id) { when (v?.id) {
R.id.iv_main_watching_close -> { R.id.iv_main_watching_close -> {
LocalVedioManager.closeCacheVedio() LocalVedioManager.closeCacheVedio()
ll_main_watching_root.visibility = View.GONE // ll_main_watching_root.visibility = View.GONE
}
R.id.tv_main_watchmore -> {
readyGo(WatchRecordActivity::class.java)
} }
R.id.tv_main_watching_goto -> { R.id.tv_main_watching_goto -> {
val cacheVedio = LocalVedioManager.getCacheVedio() val cacheVedio = LocalVedioManager.getCacheVedio()
...@@ -156,8 +129,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -156,8 +129,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), cacheVedio) LocalVedioManager.startVedioDetailActivityForType(requireActivity(), cacheVedio)
} }
} }
R.id.ll_lucky -> {
}
} }
} }
...@@ -249,8 +220,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -249,8 +220,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
fun setWatchingStatus() { fun setWatchingStatus() {
if (LocalVedioManager.isCacheVedio()) { if (LocalVedioManager.isCacheVedio()) {
ll_main_watching_root.visibility = View.VISIBLE // ll_main_watching_root.visibility = View.VISIBLE
ll_main_watching_root.setOnClickListener { } // ll_main_watching_root.setOnClickListener { }
val cacheVedio = LocalVedioManager.getCacheVedio() val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) { if (cacheVedio != null) {
GlideUtils.loadImageViewGifForCenterCrop( GlideUtils.loadImageViewGifForCenterCrop(
...@@ -269,7 +240,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -269,7 +240,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
} }
} }
} else { } else {
ll_main_watching_root.visibility = View.GONE // ll_main_watching_root.visibility = View.GONE
} }
} }
...@@ -316,51 +287,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -316,51 +287,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
topAdapter?.notifyDataSetChanged() topAdapter?.notifyDataSetChanged()
} }
override fun getSoltVedioSuc(data: IndexList?) {
AppPreferencesManager.get().put(Constant.IS_FIRST_VEDIO, true)
if (data != null && data.vedioMsg != null) {
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), data.vedioMsg)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
homePresenter.getRecommendVedio()
}
}
}
override fun getRecommendVedioSuc(data: RecoBean?) {
this.recommendVedioBean = data
}
override fun showTurnSuc(data: NineShowBean) {
AppPreferencesManager.get().put(Constant.LUCKY_FLAG, data.isShow)
if (!data.isShow || UserManager.getInstance().vipFlag) {
ll_lucky.visibility = View.GONE
return
} else {
ll_lucky.visibility = View.VISIBLE
context?.let { GlideUtils.loadRoundImageViewGif(it, R.drawable.ic_nine, iv_lucky_gif) }
}
val complete = data.complete
val need = data.need
if (complete >= need) {
tv_lucky_status.text = SpanUtils()
.append("可领取")
.setForegroundColor(resources.getColor(R.color.apk_uninstalled))
.create()
} else {
tv_lucky_status.text = SpanUtils()
.append(complete.toString())
.setForegroundColor(resources.getColor(R.color.red))
.append("/")
.append(need.toString())
.create()
}
}
override fun onHiddenChanged(hidden: Boolean) { override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden) super.onHiddenChanged(hidden)
if (isHidden) { if (isHidden) {
...@@ -370,46 +296,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -370,46 +296,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
} }
} }
/**
* 展示推荐弹窗
*/
private fun showRecommendAct(data: RecoBean?) {
if (data == null || data.vedio3 == null) return
if (AppConfig.enterVipAct) {
AppConfig.enterVipAct = false
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// 1、第一次打开app并关闭付费页进首页时出现一次
val mainFirstRecommend =
AppPreferencesManager.get().getBoolean(Constant.MAIN_FIRST_RECOMMEND, false)
if (!mainFirstRecommend) {
AppPreferencesManager.get().put(Constant.MAIN_FIRST_RECOMMEND, true)
Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(Constant.RECOMMEND_BEAN, JsonUtil.toJson(data.vedio3))
readyGo(RecommendActivity::class.java, bundle)
}, 300)
return
}
// 2、用户第一次打开app未签约付费,而是看了十次广告以上的,则在下一次打开app时关闭启动付费页面后弹出推荐弹框一次
val mainTwoRecommend =
AppPreferencesManager.get().getBoolean(Constant.MAIN_TWO_RECOMMEND, false)
val adCount = AppPreferencesManager.get().getInt(Constant.VEDIO_AD_COUNT, 0)
if (!mainTwoRecommend && adCount > data.vedio3.adShowCount) {
AppPreferencesManager.get().put(Constant.MAIN_TWO_RECOMMEND, true)
Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(Constant.RECOMMEND_BEAN, JsonUtil.toJson(data.vedio3))
readyGo(RecommendActivity::class.java, bundle)
}, 300)
}
}
}
}
fun ViewPager2.desensitization() { fun ViewPager2.desensitization() {
//动态设置ViewPager2 灵敏度 //动态设置ViewPager2 灵敏度
try { try {
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
android:orientation="vertical">
<ImageView
android:id="@+id/ivLoginBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingTop="40dp"
android:paddingRight="25dp"
android:paddingBottom="10dp"
android:scaleType="center"
android:src="@mipmap/ic_activity_quit" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:src="@mipmap/ic_launcher_main" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rlLoginWx"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="40dp"
android:layout_marginTop="230dp"
android:layout_marginRight="40dp"
android:background="@drawable/shape_green">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableLeft="@mipmap/ic_wx_white_login"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:text="微信登录"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="@+id/tvLoginMobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="24dp"
android:text="其他登录方式"
android:textColor="@color/gray"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/llWxloginCheck"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/wxloginCheck"
android:layout_width="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center"
android:checked="false"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"></CheckBox>
<TextView
android:id="@+id/tvLoginAgreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="30dp"
android:layout_marginLeft="2dp"
tools:text="123123123123123123123123123123123123123123123123123123123123123123"
android:textColor="#707A8D"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
...@@ -76,17 +76,37 @@ ...@@ -76,17 +76,37 @@
android:background="@drawable/shape_bg_write" android:background="@drawable/shape_bg_write"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="6dp" android:layout_marginLeft="6dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:text="排行榜" android:text="最近观看"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:id="@+id/tv_main_watchmore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginTop="14dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:text="查看更多"
android:textColor="@color/gray"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_main_list" android:id="@+id/rv_main_list"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -243,35 +263,4 @@ ...@@ -243,35 +263,4 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/ll_lucky"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginEnd="10dp"
android:layout_marginBottom="120dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:id="@+id/iv_lucky_gif"
android:layout_width="80dp"
android:layout_height="70dp"
android:src="@mipmap/ic_get_mobile" />
<TextView
android:id="@+id/tv_lucky_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:background="@drawable/shape_bg_black2"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="0/5"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
...@@ -3,73 +3,30 @@ ...@@ -3,73 +3,30 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlTopItemRoot" android:id="@+id/rlTopItemRoot"
android:layout_width="110dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginLeft="3dp"
android:layout_marginRight="3dp" android:layout_marginRight="3dp"
android:orientation="vertical"> android:orientation="horizontal">
<FrameLayout
android:layout_width="110dp"
android:layout_height="150dp">
<ImageView <ImageView
android:id="@+id/ivTopItem" android:id="@+id/ivTopItem"
android:layout_width="match_parent" android:layout_width="110dp"
android:layout_height="match_parent" android:layout_height="120dp"
android:scaleType="fitXY" /> android:scaleType="fitXY" />
<TextView
android:id="@+id/tvTopItemLable"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="10dp"
android:background="@mipmap/y4"
android:gravity="center"
android:paddingBottom="2dp"
android:text="1"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/bg_shape_twoban"
android:drawableLeft="@mipmap/ic_load"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:src="@mipmap/ic_load"></ImageView>
<TextView
android:id="@+id/tvTopItemCount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_marginLeft="8dp"
android:paddingLeft="6dp" android:layout_marginRight="20dp"
android:paddingTop="2dp" android:orientation="vertical">
android:paddingRight="8dp"
android:paddingBottom="2dp"
android:text="143.2万"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</FrameLayout>
<TextView <TextView
android:id="@+id/tvTopItemTitle" android:id="@+id/tvTopItemTitle"
android:layout_width="match_parent" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp" android:layout_marginTop="12dp"
android:singleLine="true" android:singleLine="true"
android:text="我去平行时空" android:text="我去平行时空"
android:textColor="@color/black" android:textColor="@color/black"
...@@ -79,8 +36,20 @@ ...@@ -79,8 +36,20 @@
android:id="@+id/tvTopItemText" android:id="@+id/tvTopItemText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="11sp" /> android:textSize="11sp" />
<TextView
android:id="@+id/tvTopCurText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:singleLine="true"
android:textColor="@color/red"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
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