Commit 2cb786fe authored by mengcuiguang's avatar mengcuiguang

代码优化

parent b589b02b
......@@ -177,6 +177,10 @@ public class HalfScreenManager {
vo.put("adType", Constant.GRO_MORE_ADTYPE3);
TrackManager.getInstance().reporGromeEcpm(vo);
}
if (weakActivity.get() != null) {
preLoadAd(weakActivity.get());
}
LogUtil.d(TAG, "gromore预加载 插全屏广告-半屏-->onAdShow");
}
......
package com.duben.dayplaylet.ad.half;
import android.app.Activity;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.duben.dayplaylet.BuildConfig;
import com.duben.dayplaylet.ad.AdStatusListener;
import com.duben.dayplaylet.common.Constant;
import com.duben.dayplaylet.manager.TrackManager;
import com.duben.dayplaylet.utils.LogUtil;
import java.lang.ref.WeakReference;
import java.util.HashMap;
/**
* 插全屏广告实时加载-半屏-半屏
*/
public class HalfScreenManagerNoPre {
private static final String TAG = HalfScreenManagerNoPre.class.getSimpleName();
private static HalfScreenManagerNoPre _inst;
public static HalfScreenManagerNoPre getInstance() {
if (_inst == null) {
_inst = new HalfScreenManagerNoPre();
}
return _inst;
}
private HalfScreenManagerNoPre() {
}
private TTFullScreenVideoAd mTtFullScreenVideoAd;
private WeakReference<Activity> weakActivity;
private boolean isPreLoad = false;//是否是预加载调用,需要躲避监听
private AdStatusListener adStatusListener;
public void showAd(Activity _activity, AdStatusListener adStatusListener) {
this.adStatusListener = adStatusListener;
this.weakActivity = new WeakReference(_activity);
TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(weakActivity.get());
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_HALF_CODE)
.setOrientation(TTAdConstant.ORIENTATION_VERTICAL)
.setMediationAdSlot(
new MediationAdSlot.Builder()
.setMuted(false)
.setVolume(0.7f)
.setBidNotify(true)
.build()
).build();
adNativeLoader.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
@Override
public void onError(int i, String s) {
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏--> 4、onError ");
if (adStatusListener != null) {
adStatusListener.adFail();
}
}
@Override
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) {
}
@Override
public void onFullScreenVideoCached() {
}
@Override
public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) {
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏--> 4、onRewardVideoCached ");
if (adStatusListener != null) {
adStatusListener.adSuccess();
}
mTtFullScreenVideoAd = ttFullScreenVideoAd;
mTtFullScreenVideoAd.showFullScreenVideoAd(weakActivity.get());
mTtFullScreenVideoAd.setFullScreenVideoAdInteractionListener(mTTFullScreenAdListener);
}
});
}
private final TTFullScreenVideoAd.FullScreenVideoAdInteractionListener mTTFullScreenAdListener = new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
@Override
public void onAdShow() {
if (mTtFullScreenVideoAd != null && mTtFullScreenVideoAd.getMediationManager().getShowEcpm() != null) {
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", mTtFullScreenVideoAd.getMediationManager().getShowEcpm().getSlotId());
vo.put("ecpm", mTtFullScreenVideoAd.getMediationManager().getShowEcpm().getEcpm());
vo.put("adSource", mTtFullScreenVideoAd.getMediationManager().getShowEcpm().getSdkName());
vo.put("adid", BuildConfig.GROMORE_HALF_CODE);
vo.put("adType", Constant.GRO_MORE_ADTYPE3);
TrackManager.getInstance().reporGromeEcpm(vo);
}
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏-->onAdShow");
}
@Override
public void onAdVideoBarClick() {
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏-->onAdVideoBarClick");
}
@Override
public void onAdClose() {
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏-->onAdClose");
//
if (adStatusListener != null) {
adStatusListener.adClose(null);
}
adStatusListener = null;
}
@Override
public void onVideoComplete() {
LogUtil.d(TAG, "gromore预加载 插全屏广告实时加载-半屏-->onVideoComplete");
}
@Override
public void onSkippedVideo() {
}
};
}
......@@ -9,6 +9,7 @@ import com.alipay.sdk.app.AuthTask
import com.duben.dayplaylet.MintsApplication
import com.duben.dayplaylet.mvp.model.AuthResult
import com.duben.dayplaylet.mvp.model.BaseResponse
import com.duben.dayplaylet.utils.ToastUtil
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import java.lang.ref.WeakReference
......@@ -36,6 +37,7 @@ object AlipayAuthManager {
) {
// 获取alipay_open_id,调支付时作为参数extern_token 的value
// 传入,则支付账户为该授权账户
UserManager.getInstance().alipaySet = true
authListener?.authSuccess()
} else {
// 其他状态值则为授权失败
......@@ -47,10 +49,12 @@ object AlipayAuthManager {
}
}
private fun getAuthData() {
private fun commitAlipayAutoInfo(info: String) {
val vo = HashMap<String, Any>()
vo.put("", info)
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.homeV1Types,
.call(baseApplication.loanService.cancelCollect(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onError(e: Throwable) {
......@@ -58,11 +62,6 @@ object AlipayAuthManager {
override fun onNext(t: BaseResponse<Any>) {
if (t.status == 200) {
} else {
}
}
})
}
......@@ -70,22 +69,39 @@ object AlipayAuthManager {
/**
* 支付宝账户授权业务示例
*/
fun authV2(authInfo: String, activity: Activity, listener: AuthListener?) {
fun authV2(activity: Activity, listener: AuthListener?) {
authListener = listener
val weakReference = WeakReference(activity)
val authRunnable = Runnable { // 构造AuthTask 对象
val authTask = AuthTask(weakReference.get())
// 调用授权接口,获取授权结果
val result = authTask.authV2(authInfo, true)
val msg = Message()
msg.what = SDK_AUTH_FLAG
msg.obj = result
mHandler.sendMessage(msg)
}
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.homeV1Types,
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onError(e: Throwable) {
}
// 必须异步调用
val authThread = Thread(authRunnable)
authThread.start()
override fun onNext(t: BaseResponse<Any>) {
if (t.status == 200) {
val authInfo = ""
val authRunnable = Runnable { // 构造AuthTask 对象
val authTask = AuthTask(weakReference.get())
// 调用授权接口,获取授权结果
val result = authTask.authV2(authInfo, true)
val msg = Message()
msg.what = SDK_AUTH_FLAG
msg.obj = result
mHandler.sendMessage(msg)
}
// 必须异步调用
val authThread = Thread(authRunnable)
authThread.start()
} else {
ToastUtil.show(MintsApplication.getContext(), t.message)
}
}
})
}
private var authListener: AuthListener? = null
......
......@@ -175,6 +175,13 @@ public class UserManager {
return ps.getBoolean(ALIPAYSET, false);
}
public void setAlipaySet(Boolean flag) {
if (ps == null) {
return;
}
ps.put(ALIPAYSET, flag);
}
/**
* 获取用户登陆状态
......@@ -222,7 +229,6 @@ public class UserManager {
}
public boolean getVipFlag() {
if (ps == null) {
return false;
......
......@@ -17,7 +17,6 @@ import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.ad.half.HalfScreenManagerNoPre
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.TrackManager
......
......@@ -24,9 +24,11 @@ import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.banner.BannerManager
import com.duben.dayplaylet.ad.express.MyExpressManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.AlipayAuthManager
import com.duben.dayplaylet.manager.LocalVedioManager
import com.duben.dayplaylet.manager.TrackManager
import com.duben.dayplaylet.manager.UserManager
......@@ -113,6 +115,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
BannerManager.loadAd(requireActivity(), fl_main_banner)
banner?.start()
MyExpressManager.instance.preLoadAd()
if (TextUtils.isEmpty(userManager?.userID)) {
//获取游客登录数据
homePresenter.userLogin()
......@@ -502,18 +506,36 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
dialog?.dismiss()
}
R.id.tv_sign_withdraw -> {
dialog?.dismiss()
userInfo?.let {
if (it.isAlipaySet) {
dialog?.dismiss()
val bundle = Bundle()
if (signMsg != null) {
val signWeekCashArr = signMsg!!.signWeekCashArr
val cash = signWeekCashArr[signMsg!!.signDay - 1]
bundle.putString(LoadingActivity.TEXT, "${cash}元现金马上到账")
val bundle = Bundle()
if (signMsg != null) {
val signWeekCashArr = signMsg!!.signWeekCashArr
val cash = signWeekCashArr[signMsg!!.signDay - 1]
bundle.putString(LoadingActivity.TEXT, "${cash}元现金马上到账")
}
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
showAd(Constant.CARRIERTYPE_SIGN)
}, 2500)
} else {
showToast("发起支付宝授权..")
AlipayAuthManager.authV2(requireActivity(),
object : AlipayAuthManager.AuthListener {
override fun authSuccess() {
showToast("支付宝授权成功")
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败" + resultStatus)
}
})
}
}
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
showAd(Constant.CARRIERTYPE_SIGN)
}, 2500)
}
}
......
......@@ -31,6 +31,7 @@ import com.duben.dayplaylet.R
import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.express.MyExpressManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
......@@ -113,6 +114,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
mIDPWidget?.fragment?.onResume()
mIDPWidget?.fragment?.userVisibleHint = true
MyExpressManager.instance.preLoadAd()
musicPresenter.rdSongMsg()
}
}
......
......@@ -9,7 +9,8 @@ import com.duben.dayplaylet.R
import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.half.HalfScreenManagerNoPre
import com.duben.dayplaylet.ad.express.MyExpressManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.UserManager
......@@ -91,7 +92,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible()
HalfScreenManagerNoPre.getInstance().showAd(requireActivity(), null)
HalfScreenManager.getInstance().showAd(requireActivity(), null)
}
override fun onDestroy() {
......@@ -105,6 +106,8 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_FOUR) {
if (AntiShake.check(tv_my_id?.id)) return
MyExpressManager.instance.preLoadAd()
if (!TextUtils.isEmpty(userManager?.userID)) {
myPresenter.getMyInfo()
myPresenter.rdUserHallList()
......
......@@ -182,7 +182,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
R.id.btn_draw -> {
//1、支付渠道
if (TextUtils.equals(payChannel, WEIXIN_PAY)) {
showToast("微信支付维护中")
// showToast("微信支付维护中")
return
}
......
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