Commit 6a62afe4 authored by mengcuiguang's avatar mengcuiguang

代码优化

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