Commit 6a62afe4 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4a50785f
...@@ -231,13 +231,11 @@ dependencies { ...@@ -231,13 +231,11 @@ dependencies {
implementation 'com.liulishuo.filedownloader:library:1.7.7' implementation 'com.liulishuo.filedownloader:library:1.7.7'
implementation "org.greenrobot:eventbus:3.1.0-RC" implementation "org.greenrobot:eventbus:3.1.0-RC"
// 掌阅书城 // 掌阅书城
implementation(name: 'iReader-release-1.0.1', ext: 'aar') // implementation(name: 'iReader-release-1.0.1', ext: 'aar')
implementation 'com.alibaba:fastjson:1.2.11' // implementation 'com.alibaba:fastjson:1.2.11'
implementation 'androidx.annotation:annotation:1.0.0' // implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.core:core:1.0.0' // implementation 'androidx.core:core:1.0.0'
implementation 'androidx.fragment:fragment:1.0.0' // implementation 'androidx.fragment:fragment:1.0.0'
// 变现猫
implementation(name: 'bxmsdk-release-3.3.1', ext: 'aar')
// 闪电盒子 // 闪电盒子
implementation(name: 'wannuosili_ad_2.2.0', ext: 'aar') implementation(name: 'wannuosili_ad_2.2.0', ext: 'aar')
// 瑞狮新闻 // 瑞狮新闻
......
...@@ -8,7 +8,6 @@ import cn.jpush.android.api.BasicPushNotificationBuilder ...@@ -8,7 +8,6 @@ import cn.jpush.android.api.BasicPushNotificationBuilder
import cn.jpush.android.api.JPushInterface import cn.jpush.android.api.JPushInterface
import com.downloader.PRDownloader import com.downloader.PRDownloader
import com.downloader.PRDownloaderConfig import com.downloader.PRDownloaderConfig
import com.wenshu.youyou.manager.BxmManager.initBxm
import com.mob.MobSDK import com.mob.MobSDK
/** /**
...@@ -59,9 +58,6 @@ class InitAppService : IntentService("InitializeService") { ...@@ -59,9 +58,6 @@ class InitAppService : IntentService("InitializeService") {
// 极光推送 // 极光推送
initJpush() initJpush()
// 变现猫
// initBxm(this.application)
// PR下载附件 // PR下载附件
initPRDownloader() initPRDownloader()
......
package com.wenshu.youyou.manager //package com.wenshu.youyou.manager
//
import android.app.Activity //import android.app.Activity
import android.app.Application //import android.app.Application
import android.view.ViewGroup //import android.view.ViewGroup
import com.dhcw.sdk.BDAdvanceButtonAd //import com.dhcw.sdk.BDAdvanceButtonAd
import com.dhcw.sdk.BDAdvanceButtonListener //import com.dhcw.sdk.BDAdvanceButtonListener
import com.dhcw.sdk.BDAppNativeOnClickListener //import com.dhcw.sdk.BDAppNativeOnClickListener
import com.dhcw.sdk.manager.BDAdvanceConfig //import com.dhcw.sdk.manager.BDAdvanceConfig
import com.dhcw.sdk.manager.BDManager //import com.dhcw.sdk.manager.BDManager
import com.wenshu.youyou.BuildConfig //import com.wenshu.youyou.BuildConfig
import com.wenshu.youyou.MintsApplication //import com.wenshu.youyou.MintsApplication
import com.wenshu.youyou.common.Constant //import com.wenshu.youyou.common.Constant
//
/** ///**
* 描述:变现猫 // * 描述:变现猫
* 作者:孟崔广 // * 作者:孟崔广
*/ // */
object BxmManager { //object BxmManager {
//
private const val APP_ID = "" // private const val APP_ID = ""
private const val BUTTON_AD_SPOT_ID = "" // private const val BUTTON_AD_SPOT_ID = ""
//
private var bdAdvanceButtonAd: BDAdvanceButtonAd? = null // private var bdAdvanceButtonAd: BDAdvanceButtonAd? = null
//
/** // /**
* 初始化 // * 初始化
*/ // */
fun initBxm(application: Application) { // fun initBxm(application: Application) {
BDAdvanceConfig.getInstance() // BDAdvanceConfig.getInstance()
.setAppName(Constant.MINTS_APP_NAME) // .setAppName(Constant.MINTS_APP_NAME)
.setDebug(BuildConfig.DEBUG) // .setDebug(BuildConfig.DEBUG)
.enableAudit(false) // .enableAudit(false)
//
BDManager.getStance() // BDManager.getStance()
.init(application, APP_ID) // .init(application, APP_ID)
} // }
//
/** // /**
* 获取Button广告 // * 获取Button广告
*/ // */
fun loadButtonAd(activity: Activity?, viewGroup: ViewGroup) { // fun loadButtonAd(activity: Activity?, viewGroup: ViewGroup) {
if (activity == null) return // if (activity == null) return
//
try { // try {
if (bdAdvanceButtonAd != null) { // if (bdAdvanceButtonAd != null) {
bdAdvanceButtonAd!!.setBdAdvanceButtonListener(null) // bdAdvanceButtonAd!!.setBdAdvanceButtonListener(null)
bdAdvanceButtonAd!!.setBdAppNativeOnClickListener(null) // bdAdvanceButtonAd!!.setBdAppNativeOnClickListener(null)
bdAdvanceButtonAd = null // bdAdvanceButtonAd = null
} // }
bdAdvanceButtonAd = BDAdvanceButtonAd(activity, viewGroup, BUTTON_AD_SPOT_ID) // bdAdvanceButtonAd = BDAdvanceButtonAd(activity, viewGroup, BUTTON_AD_SPOT_ID)
bdAdvanceButtonAd?.setBdAdvanceButtonListener(object : BDAdvanceButtonListener { // bdAdvanceButtonAd?.setBdAdvanceButtonListener(object : BDAdvanceButtonListener {
override fun onActivityClosed() { // override fun onActivityClosed() {
// Toast.makeText(activity, "活动页关闭 ", Toast.LENGTH_LONG).show() //// Toast.makeText(activity, "活动页关闭 ", Toast.LENGTH_LONG).show()
} // }
//
override fun onAdShow() { // override fun onAdShow() {
// Toast.makeText(activity, "广告展示 ", Toast.LENGTH_LONG).show() //// Toast.makeText(activity, "广告展示 ", Toast.LENGTH_LONG).show()
} // }
//
override fun onAdFailed() { // override fun onAdFailed() {
// Toast.makeText(activity, "广告加载失败 ", Toast.LENGTH_LONG).show() //// Toast.makeText(activity, "广告加载失败 ", Toast.LENGTH_LONG).show()
} // }
//
override fun onAdClicked() { // override fun onAdClicked() {
// Toast.makeText(activity, "广告点击 ", Toast.LENGTH_LONG).show() //// Toast.makeText(activity, "广告点击 ", Toast.LENGTH_LONG).show()
} // }
}) // })
bdAdvanceButtonAd?.setBdAppNativeOnClickListener(object : BDAppNativeOnClickListener { // bdAdvanceButtonAd?.setBdAppNativeOnClickListener(object : BDAppNativeOnClickListener {
override fun onActivityClosed() { // override fun onActivityClosed() {
// Toast.makeText(activity, "float onActivityClosed ", Toast.LENGTH_SHORT).show() //// Toast.makeText(activity, "float onActivityClosed ", Toast.LENGTH_SHORT).show()
} // }
//
override fun onClick(type: Int, adid: String) { // override fun onClick(type: Int, adid: String) {
// Toast.makeText(activity, "float onClick:$type", Toast.LENGTH_SHORT).show() //// Toast.makeText(activity, "float onClick:$type", Toast.LENGTH_SHORT).show()
//type=1 加载视频 type=2 播放视频 // //type=1 加载视频 type=2 播放视频
if (type == 1) { // if (type == 1) {
//bdAdvanceFloatIconAd 绑定激励视频回调 // //bdAdvanceFloatIconAd 绑定激励视频回调
BxmPlayVideo.getInstance().load(bdAdvanceButtonAd) // BxmPlayVideo.getInstance().load(bdAdvanceButtonAd)
} else if (type == 2) { // } else if (type == 2) {
BxmPlayVideo.getInstance().play(activity) // BxmPlayVideo.getInstance().play(activity)
} // }
} // }
}) // })
bdAdvanceButtonAd?.loadAd() // bdAdvanceButtonAd?.loadAd()
} catch (e: Exception) { // } catch (e: Exception) {
e.printStackTrace() // e.printStackTrace()
} // }
} // }
//
/** // /**
* 登录后绑定用户信息 // * 登录后绑定用户信息
*/ // */
fun bindUserData() { // fun bindUserData() {
try { // try {
BDManager.getStance().bindUserData(MintsApplication.getContext(), APP_ID, "cuid=${UserManager.getInstance().userID}") // BDManager.getStance().bindUserData(MintsApplication.getContext(), APP_ID, "cuid=${UserManager.getInstance().userID}")
} catch (e: Exception) { // } catch (e: Exception) {
e.printStackTrace() // e.printStackTrace()
} // }
} // }
//
fun onDestory() { // fun onDestory() {
bdAdvanceButtonAd = null // bdAdvanceButtonAd = null
} // }
} //}
\ No newline at end of file \ No newline at end of file
package com.wenshu.youyou.manager; //package com.wenshu.youyou.manager;
//
import android.app.Activity; //import android.app.Activity;
//
import com.bytedance.sdk.openadsdk.AdSlot; //import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant; //import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative; //import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd; //import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.dhcw.sdk.BDAdvanceBaseAppNative; //import com.dhcw.sdk.BDAdvanceBaseAppNative;
//
public class BxmPlayVideo { //public class BxmPlayVideo {
static BxmPlayVideo instance = new BxmPlayVideo(); // static BxmPlayVideo instance = new BxmPlayVideo();
//
public static BxmPlayVideo getInstance() { // public static BxmPlayVideo getInstance() {
return instance; // return instance;
} // }
//
//一、加载穿山甲激励视频 // //一、加载穿山甲激励视频
//BDAdvanceBaseAppNative 绑定激励视频回调 // //BDAdvanceBaseAppNative 绑定激励视频回调
public void load(final BDAdvanceBaseAppNative appNative) { // public void load(final BDAdvanceBaseAppNative appNative) {
try { // try {
TTNativeExpressManager ttNativeExpressManager = null; // TTNativeExpressManager ttNativeExpressManager = null;
TTAdNative adNative = null; // TTAdNative adNative = null;
if (ttNativeExpressManager == null) { // if (ttNativeExpressManager == null) {
ttNativeExpressManager = new TTNativeExpressManager(); // ttNativeExpressManager = new TTNativeExpressManager();
adNative = ttNativeExpressManager.initTTAd(false); // adNative = ttNativeExpressManager.initTTAd(false);
} // }
//
//模版渲染请求AdSlot // //模版渲染请求AdSlot
AdSlot adSlot = new AdSlot.Builder() // AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_VEDIO_BIANXIANMAO) // .setCodeId(TtCsjAdManager.TT_AD_VEDIO_BIANXIANMAO)
.setSupportDeepLink(true) // .setSupportDeepLink(true)
.setAdCount(1) // .setAdCount(1)
.setExpressViewAcceptedSize(500, 500)//个性化模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可。仅模板广告需要设置此参数 // .setExpressViewAcceptedSize(500, 500)//个性化模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可。仅模板广告需要设置此参数
.setImageAcceptedSize(1080, 1920) // .setImageAcceptedSize(1080, 1920)
.setOrientation(TTAdConstant.VERTICAL) // .setOrientation(TTAdConstant.VERTICAL)
.setMediaExtra("media_extra") // .setMediaExtra("media_extra")
.setUserID(UserManager.getInstance().getUserID()) // .setUserID(UserManager.getInstance().getUserID())
.build(); // .build();
//
//加载激励视频广告 // //加载激励视频广告
adNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() { // adNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override // @Override
public void onError(int i, String s) { // public void onError(int i, String s) {
appNative.onError(i); // appNative.onError(i);
} // }
//
@Override // @Override
public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) { // public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) {
if (ttRewardVideoAd == null) { // if (ttRewardVideoAd == null) {
appNative.onError(0); // appNative.onError(0);
} else { // } else {
bindRewardListener(ttRewardVideoAd, appNative); // bindRewardListener(ttRewardVideoAd, appNative);
appNative.onADLoad(); // appNative.onADLoad();
} // }
} // }
//
@Override // @Override
public void onRewardVideoCached() { // public void onRewardVideoCached() {
//
} // }
}); // });
} catch (Throwable e) { // } catch (Throwable e) {
appNative.onError(0); // appNative.onError(0);
} // }
} // }
//
//
//二、绑定穿山甲激励视频回调 // //二、绑定穿山甲激励视频回调
//BDAdvanceBaseAppNative 绑定激励视频回调 // //BDAdvanceBaseAppNative 绑定激励视频回调
TTRewardVideoAd mttRewardVideoAd; // TTRewardVideoAd mttRewardVideoAd;
//
private void bindRewardListener(TTRewardVideoAd ttRewardVideoAd, final BDAdvanceBaseAppNative appNative) { // private void bindRewardListener(TTRewardVideoAd ttRewardVideoAd, final BDAdvanceBaseAppNative appNative) {
mttRewardVideoAd = ttRewardVideoAd; // mttRewardVideoAd = ttRewardVideoAd;
mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() { // mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
@Override // @Override
public void onAdShow() { // public void onAdShow() {
appNative.onADShow(); // appNative.onADShow();
} // }
//
@Override // @Override
public void onAdVideoBarClick() { // public void onAdVideoBarClick() {
appNative.onADClick(); // appNative.onADClick();
} // }
//
@Override // @Override
public void onAdClose() { // public void onAdClose() {
appNative.onADClose(); // appNative.onADClose();
} // }
//
@Override // @Override
public void onVideoComplete() { // public void onVideoComplete() {
appNative.onVideoComplete(); // appNative.onVideoComplete();
} // }
//
@Override // @Override
public void onVideoError() { // public void onVideoError() {
appNative.onError(0); // appNative.onError(0);
} // }
//
@Override // @Override
public void onRewardVerify(boolean b, int i, String s, int i1, String s1) { // public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
appNative.onReward(); // appNative.onReward();
} // }
//
@Override // @Override
public void onSkippedVideo() { // public void onSkippedVideo() {
appNative.onSkipped(); // appNative.onSkipped();
} // }
}); // });
//
} // }
//
//三、播放穿山甲激励视频 // //三、播放穿山甲激励视频
public void play(Activity activity) { // public void play(Activity activity) {
if (mttRewardVideoAd != null) { // if (mttRewardVideoAd != null) {
mttRewardVideoAd.showRewardVideoAd(activity); // mttRewardVideoAd.showRewardVideoAd(activity);
} // }
} // }
} //}
package com.wenshu.youyou.manager //package com.wenshu.youyou.manager
//
import android.app.Application //import android.app.Application
import com.ireader.ireadersdk.IreaderApi //import com.ireader.ireadersdk.IreaderApi
import java.lang.Exception //import java.lang.Exception
//
/** ///**
* 描述:掌阅书城 // * 描述:掌阅书城
* 作者:孟崔广 // * 作者:孟崔广
*/ // */
object ZhangyueManager { //object ZhangyueManager {
//
private const val APPID = "" // private const val APPID = ""
//
fun onCreateIreader(application: Application) { // fun onCreateIreader(application: Application) {
try { // try {
IreaderApi.attachBaseContext(application) // IreaderApi.attachBaseContext(application)
IreaderApi.onCreate(application, APPID) // IreaderApi.onCreate(application, APPID)
} catch (e: Exception) { // } catch (e: Exception) {
e.printStackTrace() // e.printStackTrace()
} // }
} // }
} //}
\ No newline at end of file \ No newline at end of file
...@@ -6,7 +6,6 @@ import android.view.View ...@@ -6,7 +6,6 @@ import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.wenshu.youyou.R import com.wenshu.youyou.R
import com.wenshu.youyou.common.Constant import com.wenshu.youyou.common.Constant
import com.wenshu.youyou.manager.BxmManager
import com.wenshu.youyou.manager.RsNewsManager import com.wenshu.youyou.manager.RsNewsManager
import com.wenshu.youyou.manager.SceneManager import com.wenshu.youyou.manager.SceneManager
import com.wenshu.youyou.mvp.model.AccountMsgBean import com.wenshu.youyou.mvp.model.AccountMsgBean
...@@ -148,7 +147,6 @@ class AccountMergeActivity : BaseActivity(), View.OnClickListener, AccountMergeV ...@@ -148,7 +147,6 @@ class AccountMergeActivity : BaseActivity(), View.OnClickListener, AccountMergeV
SceneManager.signIn(this) SceneManager.signIn(this)
RsNewsManager.init(baseApplication) RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
readyGoThenKill(MainActivity::class.java) readyGoThenKill(MainActivity::class.java)
......
...@@ -8,7 +8,6 @@ import android.view.View ...@@ -8,7 +8,6 @@ import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import com.ireader.ireadersdk.IreaderApi
import com.wenshu.youyou.R import com.wenshu.youyou.R
import com.wenshu.youyou.ad.video.VideoAdingManager import com.wenshu.youyou.ad.video.VideoAdingManager
import com.wenshu.youyou.common.AppConfig import com.wenshu.youyou.common.AppConfig
...@@ -86,7 +85,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener { ...@@ -86,7 +85,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun isApplyKitKatTranslucency() = false override fun isApplyKitKatTranslucency() = false
public override fun onDestroy() { public override fun onDestroy() {
IreaderApi.onAppExit()
super.onDestroy() super.onDestroy()
......
...@@ -101,7 +101,6 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener { ...@@ -101,7 +101,6 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener {
SceneManager.signIn(this) SceneManager.signIn(this)
RsNewsManager.init(baseApplication) RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
// false-登录 true-绑定手机号 // false-登录 true-绑定手机号
showToast("登录成功") showToast("登录成功")
......
...@@ -51,10 +51,10 @@ class WrapperActivity : BaseActivity(), View.OnClickListener { ...@@ -51,10 +51,10 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
tv_title.text = "新闻" tv_title.text = "新闻"
currentFragment = RsNewsFragment() currentFragment = RsNewsFragment()
} }
Constant.WRAPPER_TYPE_BOOK -> { // Constant.WRAPPER_TYPE_BOOK -> {
tv_title.text = "书城" // tv_title.text = "书城"
currentFragment = MyZhangyueFragment() // currentFragment = MyZhangyueFragment()
} // }
Constant.WRAPPER_TYPE_FRIENDS -> { Constant.WRAPPER_TYPE_FRIENDS -> {
tv_title.text = "瓜分百万现金福利" tv_title.text = "瓜分百万现金福利"
currentFragment = FriendsFragment(true) currentFragment = FriendsFragment(true)
......
...@@ -14,7 +14,6 @@ import com.wenshu.youyou.R ...@@ -14,7 +14,6 @@ import com.wenshu.youyou.R
import com.wenshu.youyou.common.Constant import com.wenshu.youyou.common.Constant
import com.wenshu.youyou.login.LoginApi import com.wenshu.youyou.login.LoginApi
import com.wenshu.youyou.login.OnLoginListener import com.wenshu.youyou.login.OnLoginListener
import com.wenshu.youyou.manager.BxmManager
import com.wenshu.youyou.manager.RsNewsManager import com.wenshu.youyou.manager.RsNewsManager
import com.wenshu.youyou.manager.SceneManager import com.wenshu.youyou.manager.SceneManager
import com.wenshu.youyou.manager.TrackManager import com.wenshu.youyou.manager.TrackManager
...@@ -128,7 +127,6 @@ class WxLoginActivity : BaseActivity() ...@@ -128,7 +127,6 @@ class WxLoginActivity : BaseActivity()
SceneManager.signIn(this) SceneManager.signIn(this)
RsNewsManager.init(baseApplication) RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
showToast("登录成功") showToast("登录成功")
progressDialog?.dismiss() progressDialog?.dismiss()
......
...@@ -14,7 +14,6 @@ import android.widget.TextView; ...@@ -14,7 +14,6 @@ import android.widget.TextView;
import com.wenshu.youyou.R; import com.wenshu.youyou.R;
import com.wenshu.youyou.common.Constant; import com.wenshu.youyou.common.Constant;
import com.wenshu.youyou.manager.BxmManager;
import com.wenshu.youyou.manager.UserManager; import com.wenshu.youyou.manager.UserManager;
import com.wenshu.youyou.mvp.model.BannerBean; import com.wenshu.youyou.mvp.model.BannerBean;
import com.wenshu.library.utils.GlideUtils; import com.wenshu.library.utils.GlideUtils;
...@@ -91,9 +90,9 @@ public class GvMyAdapter extends BaseAdapter { ...@@ -91,9 +90,9 @@ public class GvMyAdapter extends BaseAdapter {
GlideUtils.loadImageView(activity, data.getImgUrl(), viewHolder.ic_my_icon); GlideUtils.loadImageView(activity, data.getImgUrl(), viewHolder.ic_my_icon);
viewHolder.tv_my_title.setText(data.getTitle()); viewHolder.tv_my_title.setText(data.getTitle());
if (TextUtils.equals(data.getToUrl(), Constant.HOT_ACTIVITY_BXM) && UserManager.getInstance().userIsLogin()) { // if (TextUtils.equals(data.getToUrl(), Constant.HOT_ACTIVITY_BXM) && UserManager.getInstance().userIsLogin()) {
BxmManager.INSTANCE.loadButtonAd(activity, viewHolder.fl_my_icon); // BxmManager.INSTANCE.loadButtonAd(activity, viewHolder.fl_my_icon);
} // }
} }
return convertView; return convertView;
} }
......
...@@ -155,12 +155,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener { ...@@ -155,12 +155,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
fun selectBook() { fun selectBook() {
// vpFragmentMoney.currentItem = 1 // vpFragmentMoney.currentItem = 1
xtFragmentMoney.getTabAt(1)?.select() // xtFragmentMoney.getTabAt(1)?.select()
if (bookStoreFragment == null) { // if (bookStoreFragment == null) {
bookStoreFragment = ZhangyueFragment() // bookStoreFragment = ZhangyueFragment()
} // }
//
addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE) // addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
} }
fun selectXmly() { fun selectXmly() {
......
...@@ -190,7 +190,6 @@ class MyFragment : BaseFragment(), ...@@ -190,7 +190,6 @@ class MyFragment : BaseFragment(),
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
fl_my_banner?.removeAllViews() fl_my_banner?.removeAllViews()
BxmManager.onDestory()
BannerManager.onDestroy() BannerManager.onDestroy()
myPresenter.detachView() myPresenter.detachView()
......
package com.wenshu.youyou.ui.fragment //package com.wenshu.youyou.ui.fragment
//
import android.os.Bundle //import android.os.Bundle
import android.view.View //import android.view.View
import androidx.fragment.app.Fragment //import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction //import androidx.fragment.app.FragmentTransaction
import com.ireader.ireadersdk.IreaderApi //import com.ireader.ireadersdk.IreaderApi
import com.wenshu.youyou.R //import com.wenshu.youyou.R
import com.wenshu.youyou.common.AppConfig //import com.wenshu.youyou.common.AppConfig
import com.wenshu.youyou.common.Constant //import com.wenshu.youyou.common.Constant
import com.wenshu.youyou.mvp.presenters.BookPresenter //import com.wenshu.youyou.mvp.presenters.BookPresenter
import com.wenshu.youyou.mvp.views.BookView //import com.wenshu.youyou.mvp.views.BookView
import com.wenshu.youyou.ui.activitys.AwardActivity //import com.wenshu.youyou.ui.activitys.AwardActivity
import com.wenshu.youyou.ui.fragment.base.LazyLoadBaseFragment //import com.wenshu.youyou.ui.fragment.base.LazyLoadBaseFragment
import com.wenshu.youyou.utils.SpanUtils //import com.wenshu.youyou.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_zy.* //import kotlinx.android.synthetic.main.fragment_main_zy.*
//
/** ///**
* 描述:我的-掌阅书城 // * 描述:我的-掌阅书城
* 作者:孟崔广 // * 作者:孟崔广
*/ // */
class MyZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener { //class MyZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener {
//
private val bookPresenter by lazy { BookPresenter() } // private val bookPresenter by lazy { BookPresenter() }
private var bookFragment: Fragment? = null // private var bookFragment: Fragment? = null
//
override fun getContentViewLayoutID() = R.layout.fragment_main_zy // override fun getContentViewLayoutID() = R.layout.fragment_main_zy
//
override fun initViewsAndEvents() { // override fun initViewsAndEvents() {
bookPresenter.attachView(this) // bookPresenter.attachView(this)
//
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() // val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
if (bookFragment == null) { // if (bookFragment == null) {
// bookFragment = IreaderApi.getNovelBookStoreFragment() //// bookFragment = IreaderApi.getNovelBookStoreFragment()
bookFragment = IreaderApi.getNovelChannelFragment() // bookFragment = IreaderApi.getNovelChannelFragment()
transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName) // transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName)
IreaderApi.setReadChangeListener(this) // IreaderApi.setReadChangeListener(this)
} else { // } else {
transaction.show(bookFragment!!) // transaction.show(bookFragment!!)
} // }
transaction.commitAllowingStateLoss() // transaction.commitAllowingStateLoss()
} // }
//
override fun onFragmentFirstVisible() { // override fun onFragmentFirstVisible() {
//
} // }
//
override fun onFragmentResume() { // override fun onFragmentResume() {
super.onFragmentResume() // super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) { // if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
bookPresenter.getReadInfo() // bookPresenter.getReadInfo()
} // }
} // }
//
override fun onDestroy() { // override fun onDestroy() {
super.onDestroy() // super.onDestroy()
//
IreaderApi.setReadChangeListener(null) // IreaderApi.setReadChangeListener(null)
bookPresenter.detachView() // bookPresenter.detachView()
} // }
//
override fun onReadStart() { // override fun onReadStart() {
} // }
//
override fun onReadEnd(time: Long) { // override fun onReadEnd(time: Long) {
// LogUtil.d(TAG, "onReadEnd time:" + time) //// LogUtil.d(TAG, "onReadEnd time:" + time)
// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt()) //// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt())
//
val seconds = (time / 1000).toInt() // val seconds = (time / 1000).toInt()
// 阅读5秒以上 保存时长 // // 阅读5秒以上 保存时长
if (seconds > 5) { // if (seconds > 5) {
bookPresenter.addReadSeconds(seconds) // bookPresenter.addReadSeconds(seconds)
} // }
} // }
//
override fun onReadPage(time: Long) { // override fun onReadPage(time: Long) {
} // }
//
override fun readSecondsSuc(coin: Int) { // override fun readSecondsSuc(coin: Int) {
if (coin > 0) { // if (coin > 0) {
val bundle = Bundle() // val bundle = Bundle()
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE) // bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE)
bundle.putInt(Constant.MAIN_CUR_COIN, coin) // bundle.putInt(Constant.MAIN_CUR_COIN, coin)
readyGo(AwardActivity::class.java, bundle) // readyGo(AwardActivity::class.java, bundle)
} // }
} // }
//
override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) { // override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) {
//阅读{10}分钟,奖励{xx}金币,已读{x}分钟 // //阅读{10}分钟,奖励{xx}金币,已读{x}分钟
tvZhangContent.visibility = View.VISIBLE // tvZhangContent.visibility = View.VISIBLE
if (readTime >= sumTime) { // if (readTime >= sumTime) {
tvZhangContent.text = "今日阅读任务已完成" // tvZhangContent.text = "今日阅读任务已完成"
} else { // } else {
tvZhangContent.text = SpanUtils() // tvZhangContent.text = SpanUtils()
.append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ") // .append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
.append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ") // .append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ")
.append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟") // .append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
.create() // .create()
} // }
} // }
} //}
\ No newline at end of file \ No newline at end of file
package com.wenshu.youyou.ui.fragment //package com.wenshu.youyou.ui.fragment
//
import android.os.Bundle //import android.os.Bundle
import android.view.View //import android.view.View
import androidx.fragment.app.Fragment //import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction //import androidx.fragment.app.FragmentTransaction
import com.ireader.ireadersdk.IreaderApi //import com.ireader.ireadersdk.IreaderApi
import com.wenshu.youyou.R //import com.wenshu.youyou.R
import com.wenshu.youyou.common.AppConfig //import com.wenshu.youyou.common.AppConfig
import com.wenshu.youyou.common.Constant //import com.wenshu.youyou.common.Constant
import com.wenshu.youyou.mvp.presenters.BookPresenter //import com.wenshu.youyou.mvp.presenters.BookPresenter
import com.wenshu.youyou.mvp.views.BookView //import com.wenshu.youyou.mvp.views.BookView
import com.wenshu.youyou.ui.activitys.AwardActivity //import com.wenshu.youyou.ui.activitys.AwardActivity
import com.wenshu.youyou.ui.fragment.base.LazyLoadBaseFragment //import com.wenshu.youyou.ui.fragment.base.LazyLoadBaseFragment
import com.wenshu.youyou.utils.SpanUtils //import com.wenshu.youyou.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_zy.* //import kotlinx.android.synthetic.main.fragment_main_zy.*
//
/** ///**
* 描述:掌阅书城 // * 描述:掌阅书城
* 作者:孟崔广 // * 作者:孟崔广
*/ // */
class ZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener { //class ZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener {
//
private val bookPresenter by lazy { BookPresenter() } // private val bookPresenter by lazy { BookPresenter() }
private var bookFragment: Fragment? = null // private var bookFragment: Fragment? = null
//
override fun getContentViewLayoutID() = R.layout.fragment_main_zy // override fun getContentViewLayoutID() = R.layout.fragment_main_zy
//
override fun initViewsAndEvents() { // override fun initViewsAndEvents() {
//
} // }
//
override fun onFragmentFirstVisible() { // override fun onFragmentFirstVisible() {
bookPresenter.attachView(this) // bookPresenter.attachView(this)
//
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() // val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
if (bookFragment == null) { // if (bookFragment == null) {
bookFragment = IreaderApi.getNovelBookStoreFragment() // bookFragment = IreaderApi.getNovelBookStoreFragment()
transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName) // transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName)
IreaderApi.setReadChangeListener(this) // IreaderApi.setReadChangeListener(this)
} else { // } else {
transaction.show(bookFragment!!) // transaction.show(bookFragment!!)
} // }
transaction.commitAllowingStateLoss() // transaction.commitAllowingStateLoss()
} // }
//
override fun onFragmentResume() { // override fun onFragmentResume() {
super.onFragmentResume() // super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) { // if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
bookPresenter.getReadInfo() // bookPresenter.getReadInfo()
} // }
} // }
//
override fun onDestroy() { // override fun onDestroy() {
super.onDestroy() // super.onDestroy()
//
IreaderApi.setReadChangeListener(null) // IreaderApi.setReadChangeListener(null)
bookPresenter.detachView() // bookPresenter.detachView()
} // }
//
override fun onReadStart() { // override fun onReadStart() {
} // }
//
override fun onReadEnd(time: Long) { // override fun onReadEnd(time: Long) {
// LogUtil.d(TAG, "onReadEnd time:" + time) //// LogUtil.d(TAG, "onReadEnd time:" + time)
// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt()) //// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt())
//
val seconds = (time / 1000).toInt() // val seconds = (time / 1000).toInt()
// 阅读5秒以上 保存时长 // // 阅读5秒以上 保存时长
if (seconds > 5) { // if (seconds > 5) {
bookPresenter.addReadSeconds(seconds) // bookPresenter.addReadSeconds(seconds)
} // }
} // }
//
override fun onReadPage(time: Long) { // override fun onReadPage(time: Long) {
} // }
//
override fun readSecondsSuc(coin: Int) { // override fun readSecondsSuc(coin: Int) {
if (coin > 0) { // if (coin > 0) {
val bundle = Bundle() // val bundle = Bundle()
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE) // bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE)
bundle.putInt(Constant.MAIN_CUR_COIN, coin) // bundle.putInt(Constant.MAIN_CUR_COIN, coin)
readyGo(AwardActivity::class.java, bundle) // readyGo(AwardActivity::class.java, bundle)
} // }
} // }
//
override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) { // override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) {
//阅读{10}分钟,奖励{xx}金币,已读{x}分钟 // //阅读{10}分钟,奖励{xx}金币,已读{x}分钟
tvZhangContent.visibility = View.VISIBLE // tvZhangContent.visibility = View.VISIBLE
if (readTime >= sumTime) { // if (readTime >= sumTime) {
tvZhangContent.text = "今日阅读任务已完成" // tvZhangContent.text = "今日阅读任务已完成"
} else { // } else {
tvZhangContent.text = SpanUtils() // tvZhangContent.text = SpanUtils()
.append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ") // .append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
.append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ") // .append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ")
.append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟") // .append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
.create() // .create()
} // }
} // }
} //}
\ No newline at end of file \ No newline at end of file
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
<item android:id="@android:id/background"> <item android:id="@android:id/background">
<shape> <shape>
<stroke <stroke
android:width="@dimen/dp_1" android:width="1dp"
android:color="#E5E5E5" /> android:color="#E5E5E5" />
<corners android:radius="@dimen/dp_5" /> <corners android:radius="5dp" />
<solid android:color="#FAFAFA" /> <solid android:color="#FAFAFA" />
<gradient <gradient
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<clip> <clip>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#E9DDB6" /> <solid android:color="#E9DDB6" />
<corners android:radius="@dimen/dp_5" /> <corners android:radius="5dp" />
</shape> </shape>
</clip> </clip>
</item> </item>
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
<clip> <clip>
<shape> <shape>
<stroke <stroke
android:width="@dimen/dp_1" android:width="1dp"
android:color="#E5E5E5" /> android:color="#E5E5E5" />
<corners android:radius="@dimen/dp_5" /> <corners android:radius="5dp" />
<gradient <gradient
android:angle="0" android:angle="0"
android:centerColor="#FB560C" android:centerColor="#FB560C"
......
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