Commit 13e303fd authored by mengcuiguang's avatar mengcuiguang

首页展示推荐剧

parent cfb783b7
......@@ -156,6 +156,11 @@
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.activitys.RecommendActivity"
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.activitys.NineKnowActivity"
android:exported="false"
......
......@@ -12,6 +12,8 @@ import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.mints.helivideo.BuildConfig;
import com.mints.helivideo.ad.AdManager;
import com.mints.helivideo.ad.AdStatusListener;
import com.mints.helivideo.common.Constant;
import com.mints.helivideo.utils.AppPreferencesManager;
import com.mints.helivideo.utils.LogUtil;
import com.mints.helivideo.utils.TimeRender;
......@@ -209,6 +211,11 @@ public class InMoneyVideo {
public void onAdClose() {
LogUtil.d(TAG, "gromore预加载 激励视频广告-->onAdClose");
int adCount = AppPreferencesManager.INSTANCE.get().getInt(Constant.VEDIO_AD_COUNT, 0);
if (adCount < 50) {
AppPreferencesManager.INSTANCE.get().put(Constant.VEDIO_AD_COUNT, adCount++);
}
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", nowAdcode);
vo.put("ecpm", nowEcpm);
......
......@@ -12,6 +12,8 @@ import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.mints.helivideo.BuildConfig;
import com.mints.helivideo.ad.AdManager;
import com.mints.helivideo.ad.AdStatusListener;
import com.mints.helivideo.common.Constant;
import com.mints.helivideo.utils.AppPreferencesManager;
import com.mints.helivideo.utils.LogUtil;
import java.lang.ref.WeakReference;
......@@ -148,6 +150,11 @@ public class InMoneyVideoNoPre {
public void onAdClose() {
LogUtil.d(TAG, "gromore实时加载 激励视频广告-->onAdClose nowAdcode=" + nowAdcode);
int adCount = AppPreferencesManager.INSTANCE.get().getInt(Constant.VEDIO_AD_COUNT, 0);
if (adCount < 50) {
AppPreferencesManager.INSTANCE.get().put(Constant.VEDIO_AD_COUNT, adCount++);
}
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", nowAdcode);
vo.put("ecpm", nowEcpm);
......
......@@ -19,4 +19,7 @@ public class AppConfig {
// 退出登录首页刷新
public static boolean exitLoginMainRefresh = false;
// 进入过支付界面
public static boolean enterVipAct = false;
}
......@@ -25,6 +25,9 @@ object Constant {
const val LUCKY_COMPLETE = "LUCKY_COMPLETE"
const val LUCKY_NEED = "LUCKY_NEED"
const val LUCKY_MY_FIRST = "LUCKY_MY_FIRST"
const val MAIN_FIRST_RECOMMEND = "MAIN_FIRST_RECOMMEND"
const val MAIN_TWO_RECOMMEND = "MAIN_TWO_RECOMMEND"
const val VEDIO_AD_COUNT = "VEDIO_AD_COUNT"
const val CARRIERTYPE_CSJ_VEDIO = "1"
......
......@@ -11,6 +11,7 @@ import com.mints.helivideo.ad.express.ExpressManager
import com.mints.library.utils.json.JsonUtil
import com.mints.helivideo.common.Constant
import com.mints.helivideo.mvp.model.VedioBean
import com.mints.helivideo.ui.activitys.RecommendActivity
import com.mints.helivideo.utils.AppPreferencesManager
import com.mints.helivideo.utils.ToastUtil
import com.mints.helivideo.video.DramaApiDetailActivity
......@@ -53,13 +54,22 @@ object LocalVedioManager {
* true-有
*/
fun isCacheVedio(): Boolean {
if (vedioCache != null) {
// 有缓存 且 不是推荐剧
if (vedioCache != null && !vedioCache!!.isRecommendVedio) {
return true
}
val localVedio = AppPreferencesManager.get().getString(Constant.LOCAL_VEDIO, "")
if (!TextUtils.isEmpty(localVedio)) {
return true
try {
val bean = JsonUtil.parseJson(localVedio, VedioBean::class.java)
if (bean != null && !bean.isRecommendVedio) {
return true
}
} catch (e: Exception) {
e.printStackTrace()
return false
}
}
return false
}
......@@ -95,7 +105,8 @@ object LocalVedioManager {
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext)
bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId)
readyGo(activity, TxVideoActivity::class.java, bundle)
// readyGo(activity, TxVideoActivity::class.java, bundle)
readyGo(activity, RecommendActivity::class.java, bundle)
} else {
requestDrama(activity, data)
}
......
......@@ -31,6 +31,7 @@ public class VedioBean implements Serializable {
private int recommendIndex;// 推荐视频第几集
private long seeUpdateTime;// 时间戳
private boolean checked;// 选中
private boolean isRecommendVedio;// 是否推荐剧
private int tipMaxIndex;// 倒计时弹框
public String getShowNum() {
......@@ -252,4 +253,12 @@ public class VedioBean implements Serializable {
public void setFreeIndex(int freeIndex) {
this.freeIndex = freeIndex;
}
public boolean isRecommendVedio() {
return isRecommendVedio;
}
public void setRecommendVedio(boolean recommendVedio) {
isRecommendVedio = recommendVedio;
}
}
......@@ -251,4 +251,31 @@ class HomePresenter : BasePresenter<HomeView>() {
}
})
}
fun getRecommendVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getRecommendVedio(),
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.getRecommendVedioSuc(baseResponse.data)
}
}
}
})
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ interface HomeView : BaseView {
fun topTabsSuc(data: BannerList?)
fun ordersSuc(data: BannerList?)
fun getSoltVedioSuc(data: IndexList?)
fun getRecommendVedioSuc(data: IndexList?)
fun showTurnSuc(data: NineShowBean)
}
......@@ -277,6 +277,12 @@ public interface LoanService {
@POST("api/vedio/firstVedio")
Observable<BaseResponse<IndexList>> getSoltVedio();
/**
* 匹配推荐
*/
@POST("api/vedio/firstVedio")
Observable<BaseResponse<IndexList>> getRecommendVedio();
/**
* 9宫格信息
*/
......
package com.mints.helivideo.ui.activitys
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import com.google.gson.Gson
import com.mints.helivideo.R
import com.mints.helivideo.common.Constant
import com.mints.helivideo.mvp.model.VedioBean
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_recommend.*
/**
* 描述:推荐弹窗
* 作者:孟崔广
*/
class RecommendActivity : BaseActivity(), View.OnClickListener {
private var mVedioBean: VedioBean? = null
override fun getContentViewLayoutID() = R.layout.activity_recommend
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
val json = extras.getString(Constant.VEDIO_BEAN)
mVedioBean = Gson().fromJson(json, VedioBean::class.java)
}
}
override fun initViewsAndEvents() {
initView()
initListener()
}
private fun initView() {
}
private fun initListener() {
ic_recommend_quit.setOnClickListener(this)
}
override fun finish() {
super.finish()
overridePendingTransition(0, R.anim.scale_out)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(
keyCode,
event
)
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.ic_recommend_quit -> {
finish()
}
}
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ import com.jobo.wxpay.WXPay
import com.jobo.wxpay.WXPayInfoImpl
import com.mints.helivideo.BuildConfig
import com.mints.helivideo.R
import com.mints.helivideo.common.AppConfig
import com.mints.helivideo.common.Constant
import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.VipBean
......@@ -47,6 +48,8 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
companion object {
const val IS_GUIDE = "IS_GUIDE"//是否从引导页进入
const val IS_MAIN = "IS_MAIN"//是否从首页进入
const val IS_RECOMMEND = "IS_RECOMMEND"//是否从推荐页进入
const val wxAppId = BuildConfig.WEIXIN_APP_PAY_ID
const val WEIXIN_PAY = "WEIXIN_PAY"
const val ALIPAY = "ALIPAY"
......@@ -64,6 +67,8 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
private var vipList: MutableList<VipBean.ListBean>? = null
private var isCheckAgreeFlag: Boolean = true
private var isGuide: Boolean = false// 从启动页进入vip界面,返回时要回到首页
private var isMain: Boolean = false
private var isRecommend: Boolean = false
private var payType = ALIPAY// 支付类型
private var vedioId = ""
private var thirdId = ""
......@@ -81,6 +86,8 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
super.getBundleExtras(extras)
extras?.let {
isGuide = it.getBoolean(IS_GUIDE, false)
isMain = it.getBoolean(IS_MAIN, false)
isRecommend = it.getBoolean(IS_RECOMMEND, false)
thirdId = it.getString(THIRD_ID, "")
vedioId = it.getString(VEDIO_ID, "")
}
......@@ -94,6 +101,8 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
vipPresenter.userLogin(isAliPayInstalled())
}
AppConfig.enterVipAct = true
initListener()
}
......@@ -106,6 +115,9 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
override fun onDestroy() {
super.onDestroy()
if (!isMain) {
AppConfig.enterVipAct = false
}
breathAnim?.stop()
vipPresenter.detachView()
}
......@@ -192,12 +204,17 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
if (isPay) {
showToast("支付成功")
if (!UserManager.getInstance().userIsLogin()) {
val b = Bundle()
b.putString(MobileLoginActivity.TYPE, "vip")
readyGoThenKill(MobileLoginActivity::class.java, b)
if (isRecommend) {
finish()
} else {
readyGoThenKill(MainActivity::class.java)
if (!UserManager.getInstance().userIsLogin()) {
val b = Bundle()
b.putString(MobileLoginActivity.TYPE, "vip")
readyGoThenKill(MobileLoginActivity::class.java, b)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
}
}
......
package com.mints.helivideo.ui.fragment
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
......@@ -26,6 +27,8 @@ import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.presenters.HomePresenter
import com.mints.helivideo.mvp.views.HomeView
import com.mints.helivideo.ui.activitys.NineActivity
import com.mints.helivideo.ui.activitys.NinePayActivity
import com.mints.helivideo.ui.activitys.RecommendActivity
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter
import com.mints.helivideo.ui.adapter.ImageTitleAdapter
......@@ -34,6 +37,7 @@ 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.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.fragment_main.*
import java.lang.reflect.Field
......@@ -56,6 +60,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
private val topList = mutableListOf<VedioBean>()
private var vpAdapter: HomeVideoPageAdapter? = null
private var topAdapter: TopAdapter? = null
private var recommendVedioBean: VedioBean? = null
private val homePresenter by lazy { HomePresenter() }
private val userManager by lazy { UserManager.getInstance() }
......@@ -87,7 +93,11 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
val firstVedio = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VEDIO, false)
if (firstVedio) {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
readyGo(VipActivity::class.java)
homePresenter.getRecommendVedio()
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
}
} else {
homePresenter.getSoltVedio()
......@@ -121,6 +131,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
homePresenter.topTabs()
homePresenter.orders()
TrackManager.getInstance().getMyInfo()
showRecommendAct(recommendVedioBean)
}
}
}
......@@ -312,11 +323,20 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), data.vedioMsg)
} else {
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
readyGo(VipActivity::class.java)
homePresenter.getRecommendVedio()
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
}
}
}
override fun getRecommendVedioSuc(data: IndexList?) {
this.recommendVedioBean = data?.vedioMsg
}
override fun showTurnSuc(data: NineShowBean) {
AppPreferencesManager.get().put(Constant.LUCKY_FLAG, data.isShow)
......@@ -353,7 +373,47 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
}
fun ViewPager2.desensitization(){
/**
* 展示推荐弹窗
*/
private fun showRecommendAct(data: VedioBean?) {
if (data == 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.VEDIO_BEAN, JsonUtil.toJson(data))
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 > 10) {
AppPreferencesManager.get().put(Constant.MAIN_TWO_RECOMMEND, true)
Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
readyGo(RecommendActivity::class.java, bundle)
}, 300)
}
}
}
}
fun ViewPager2.desensitization() {
//动态设置ViewPager2 灵敏度
try {
val recyclerViewField: Field = ViewPager2::class.java.getDeclaredField("mRecyclerView")
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#90000000"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="30dp"
android:background="#0f0"
android:layout_marginTop="40dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="40dp">
<ImageView
android:id="@+id/ic_recommend_quit"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginTop="2dp"
android:layout_marginRight="10dp"
android:padding="10dp"
android:scaleType="centerCrop"
android:src="@mipmap/ic_quit_yuan" />
</RelativeLayout>
</RelativeLayout>
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