Commit 7e4d8377 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 7c416055
...@@ -16,6 +16,7 @@ public class AppConfig { ...@@ -16,6 +16,7 @@ public class AppConfig {
* app应用首页 0-主页 1-position 2-我 * app应用首页 0-主页 1-position 2-我
*/ */
public static int fragmentClickFlag = 0; public static int fragmentClickFlag = 0;
public static int vedioId = 0;
// 退出登录首页刷新 // 退出登录首页刷新
public static boolean exitLoginMainRefresh = false; public static boolean exitLoginMainRefresh = false;
......
...@@ -9,6 +9,7 @@ import com.bytedance.sdk.dp.DPSdk ...@@ -9,6 +9,7 @@ import com.bytedance.sdk.dp.DPSdk
import com.bytedance.sdk.dp.IDPWidgetFactory import com.bytedance.sdk.dp.IDPWidgetFactory
import com.duben.speedplaylet.ad.express.ExpressManager import com.duben.speedplaylet.ad.express.ExpressManager
import com.duben.library.utils.json.JsonUtil import com.duben.library.utils.json.JsonUtil
import com.duben.speedplaylet.common.AppConfig
import com.duben.speedplaylet.common.Constant import com.duben.speedplaylet.common.Constant
import com.duben.speedplaylet.mvp.model.VedioBean import com.duben.speedplaylet.mvp.model.VedioBean
import com.duben.speedplaylet.utils.AppPreferencesManager import com.duben.speedplaylet.utils.AppPreferencesManager
...@@ -28,6 +29,7 @@ object LocalVedioManager { ...@@ -28,6 +29,7 @@ object LocalVedioManager {
* 提交当前视频数据 * 提交当前视频数据
*/ */
fun commitVedio(data: VedioBean) { fun commitVedio(data: VedioBean) {
AppConfig.vedioId = data.vedioId
cacheVedio(data) cacheVedio(data)
TrackManager.getInstance().commitVedio(data) TrackManager.getInstance().commitVedio(data)
} }
...@@ -106,13 +108,13 @@ object LocalVedioManager { ...@@ -106,13 +108,13 @@ object LocalVedioManager {
bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext) bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext)
bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId) bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId)
readyGo(activity, TxVideoActivity::class.java, bundle) readyGo(activity, TxVideoActivity::class.java, bundle)
} else if (data?.createType == 3) { } else if (data?.createType == 2) {
requestDrama(activity, data)
} else {
//推荐短剧 //推荐短剧
val bundle = Bundle() val bundle = Bundle()
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data)) bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
readyGo(activity, NewTxVideoActivity::class.java, bundle) readyGo(activity, NewTxVideoActivity::class.java, bundle)
} else {
requestDrama(activity, data)
} }
if (!UserManager.getInstance().vipFlag) { if (!UserManager.getInstance().vipFlag) {
......
...@@ -41,6 +41,12 @@ public class TrackManager { ...@@ -41,6 +41,12 @@ public class TrackManager {
} }
} }
public void firstShowVedio() {
if (trackPresenter != null) {
trackPresenter.firstShowVedio();
}
}
public void commitVedio(VedioBean data) { public void commitVedio(VedioBean data) {
if (trackPresenter != null) { if (trackPresenter != null) {
HashMap<String, Object> vo = new HashMap<>(); HashMap<String, Object> vo = new HashMap<>();
......
package com.duben.speedplaylet.mvp.model;
import java.io.Serializable;
import java.util.List;
public class RecommendBannerList implements Serializable {
private List<VedioBean> vedio4;
public List<VedioBean> getList() {
return vedio4;
}
public void setList(List<VedioBean> list) {
this.vedio4 = list;
}
}
...@@ -2,17 +2,22 @@ package com.duben.speedplaylet.mvp.presenters ...@@ -2,17 +2,22 @@ package com.duben.speedplaylet.mvp.presenters
import com.duben.library.net.neterror.BaseSubscriber import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable import com.duben.library.net.neterror.Throwable
import com.duben.speedplaylet.common.AppConfig
import com.duben.speedplaylet.manager.AppHttpManager import com.duben.speedplaylet.manager.AppHttpManager
import com.duben.speedplaylet.mvp.model.BannerList import com.duben.speedplaylet.mvp.model.BannerList
import com.duben.speedplaylet.mvp.model.BaseResponse import com.duben.speedplaylet.mvp.model.BaseResponse
import com.duben.speedplaylet.mvp.model.RecommendBannerList
import com.duben.speedplaylet.mvp.views.RecommendBannerView import com.duben.speedplaylet.mvp.views.RecommendBannerView
import java.util.HashMap
class RecommendBannerPresenter : BasePresenter<RecommendBannerView>() { class RecommendBannerPresenter : BasePresenter<RecommendBannerView>() {
fun orders() { fun orders() {
val vo = HashMap<String, Any>()
vo["vedioId"] = AppConfig.vedioId
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.orders(), .call(loanService.vedio4Msg(vo),
object : BaseSubscriber<BaseResponse<BannerList>>() { object : BaseSubscriber<BaseResponse<RecommendBannerList>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
} }
...@@ -21,7 +26,7 @@ class RecommendBannerPresenter : BasePresenter<RecommendBannerView>() { ...@@ -21,7 +26,7 @@ class RecommendBannerPresenter : BasePresenter<RecommendBannerView>() {
if (isLinkView) return if (isLinkView) return
} }
override fun onNext(baseResponse: BaseResponse<BannerList>) { override fun onNext(baseResponse: BaseResponse<RecommendBannerList>) {
if (isLinkView) return if (isLinkView) return
val code = baseResponse.status val code = baseResponse.status
......
package com.duben.speedplaylet.mvp.presenters; package com.duben.speedplaylet.mvp.presenters;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.google.gson.JsonObject;
import com.duben.speedplaylet.common.Constant;
import com.duben.speedplaylet.manager.LocalVedioManager;
import com.duben.speedplaylet.mvp.model.IndexList;
import com.duben.speedplaylet.mvp.model.VedioBean;
import com.duben.speedplaylet.utils.AppPreferencesManager;
import com.duben.library.net.neterror.BaseSubscriber; import com.duben.library.net.neterror.BaseSubscriber;
import com.duben.library.net.neterror.Throwable; import com.duben.library.net.neterror.Throwable;
import com.duben.speedplaylet.MintsApplication; import com.duben.speedplaylet.MintsApplication;
import com.duben.speedplaylet.common.AppConfig;
import com.duben.speedplaylet.common.DeviceInfo; import com.duben.speedplaylet.common.DeviceInfo;
import com.duben.speedplaylet.manager.AppHttpManager; import com.duben.speedplaylet.manager.AppHttpManager;
import com.duben.speedplaylet.manager.UserManager; import com.duben.speedplaylet.manager.UserManager;
import com.duben.speedplaylet.mvp.model.BaseResponse; import com.duben.speedplaylet.mvp.model.BaseResponse;
import com.duben.speedplaylet.mvp.model.UserBean; import com.duben.speedplaylet.mvp.model.UserBean;
import com.duben.speedplaylet.utils.DeviceUuidFactory; import com.duben.speedplaylet.utils.DeviceUuidFactory;
import com.google.gson.JsonObject;
import java.util.HashMap; import java.util.HashMap;
...@@ -48,7 +42,7 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -48,7 +42,7 @@ public class TrackPresenter extends BaseTrackPresenter {
case 200: { case 200: {
UserManager.getInstance().saveUserInfo(baseResponse.getData()); UserManager.getInstance().saveUserInfo(baseResponse.getData());
getMyInfo(); firstShowVedio();
saveTerminalInfo(); saveTerminalInfo();
} }
...@@ -227,4 +221,33 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -227,4 +221,33 @@ public class TrackPresenter extends BaseTrackPresenter {
}); });
} }
public void firstShowVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.firstShowVedio(),
new BaseSubscriber<BaseResponse<JsonObject>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<JsonObject> baseResponse) {
switch (baseResponse.getStatus()) {
case 200: {
try {
JsonObject data = baseResponse.getData();
AppConfig.showVipVedio = data.get("canShowVedio4").getAsBoolean();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
});
}
} }
package com.duben.speedplaylet.mvp.views package com.duben.speedplaylet.mvp.views
import com.duben.speedplaylet.mvp.model.BannerList import com.duben.speedplaylet.mvp.model.*
import com.duben.speedplaylet.mvp.model.UserBean
import com.duben.speedplaylet.mvp.model.VipBean
import com.duben.speedplaylet.mvp.model.WxPayParamBean
interface RecommendBannerView : BaseView { interface RecommendBannerView : BaseView {
fun ordersSuc(data: BannerList?) fun ordersSuc(data: RecommendBannerList?)
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.duben.speedplaylet.net; ...@@ -3,6 +3,7 @@ package com.duben.speedplaylet.net;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import com.duben.speedplaylet.mvp.model.RecommendBannerList;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.duben.speedplaylet.BuildConfig; import com.duben.speedplaylet.BuildConfig;
import com.duben.speedplaylet.mvp.model.BannerList; import com.duben.speedplaylet.mvp.model.BannerList;
...@@ -310,6 +311,19 @@ public interface LoanService { ...@@ -310,6 +311,19 @@ public interface LoanService {
@POST("api/vedio/showTurn") @POST("api/vedio/showTurn")
Observable<BaseResponse<NineShowBean>> showTurn(); Observable<BaseResponse<NineShowBean>> showTurn();
/**
* 获取推荐状态
*/
@POST("api/vedio/showVedio4")
Observable<BaseResponse<JsonObject>> firstShowVedio();
/**
* 推荐banner
*/
@POST("api/vedio/vedio4Msg")
Observable<BaseResponse<RecommendBannerList>> vedio4Msg(@Body Map<String, Object> vo);
/** /**
* 默认http工厂 * 默认http工厂
*/ */
......
...@@ -9,6 +9,7 @@ import com.duben.library.utils.nodoubleclick.AntiShake ...@@ -9,6 +9,7 @@ import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.speedplaylet.R import com.duben.speedplaylet.R
import com.duben.speedplaylet.manager.LocalVedioManager import com.duben.speedplaylet.manager.LocalVedioManager
import com.duben.speedplaylet.mvp.model.BannerList import com.duben.speedplaylet.mvp.model.BannerList
import com.duben.speedplaylet.mvp.model.RecommendBannerList
import com.duben.speedplaylet.mvp.model.VedioBean import com.duben.speedplaylet.mvp.model.VedioBean
import com.duben.speedplaylet.mvp.presenters.RecommendBannerPresenter import com.duben.speedplaylet.mvp.presenters.RecommendBannerPresenter
import com.duben.speedplaylet.mvp.views.RecommendBannerView import com.duben.speedplaylet.mvp.views.RecommendBannerView
...@@ -58,7 +59,7 @@ class RecommendBannerActivity : BaseActivity(),RecommendBannerView, View.OnClick ...@@ -58,7 +59,7 @@ class RecommendBannerActivity : BaseActivity(),RecommendBannerView, View.OnClick
recommendBannerPresenter.detachView() recommendBannerPresenter.detachView()
} }
override fun ordersSuc(data: BannerList?) { override fun ordersSuc(data: RecommendBannerList?) {
data?.let { data?.let {
setBanner(it.list) setBanner(it.list)
} }
......
...@@ -71,7 +71,7 @@ class SplashActivity : BaseActivity() { ...@@ -71,7 +71,7 @@ class SplashActivity : BaseActivity() {
private fun initData() { private fun initData() {
if(!TextUtils.isEmpty(UserManager.getInstance().userID)){ if(!TextUtils.isEmpty(UserManager.getInstance().userID)){
TrackManager.getInstance().getMyInfo() TrackManager.getInstance().firstShowVedio()
} }
val firstSplash = get().getBoolean(Constant.FIRST_SPLASH, true) val firstSplash = get().getBoolean(Constant.FIRST_SPLASH, true)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
android:scaleType="fitXY" /> android:scaleType="fitXY" />
<TextView <TextView
android:visibility="gone"
android:id="@+id/bannerTitle" android:id="@+id/bannerTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="24dp"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp" android:layout_marginTop="14dp"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" android:textSize="18sp"
tools:text="包年会员" /> tools:text="包年会员" />
......
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