Commit 552b120c authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 3b1813b5
...@@ -34,8 +34,14 @@ import kotlin.jvm.functions.Function0; ...@@ -34,8 +34,14 @@ import kotlin.jvm.functions.Function0;
public class ReaderManager { public class ReaderManager {
public static void init(Application applicationContext) { public static void init(Application applicationContext) {
ToutiaoAD ad = new ToutiaoAD(); ToutiaoAD csjAd = new ToutiaoAD();
ChineseAllReaderApplication.Companion.install(applicationContext, "1242", "hzq@1242", "32", "0", new AdProvider() { ChineseAllReaderApplication.Companion.install(applicationContext, "1242", "hzq@1242", "32", "0", new AdProvider() {
/**
* 阅读⻚弹窗广告确认按钮的点击回调-激励视频
* @param dialog
* @param block 对话框关闭回调,必须调用,否则计时每次切换章节都会出现弹窗
*/
@Override @Override
public void onAdDialogPositiveClick(@Nullable Dialog dialog, @NotNull Function0<Unit> function0) { public void onAdDialogPositiveClick(@Nullable Dialog dialog, @NotNull Function0<Unit> function0) {
if (NetworkUtil.isNetworkAvailable(applicationContext) && !NetworkUtil.INSTANCE.isWifiConnected(applicationContext)) { if (NetworkUtil.isNetworkAvailable(applicationContext) && !NetworkUtil.INSTANCE.isWifiConnected(applicationContext)) {
...@@ -45,7 +51,7 @@ public class ReaderManager { ...@@ -45,7 +51,7 @@ public class ReaderManager {
.setPositiveButton("观看视频", new DialogInterface.OnClickListener() { .setPositiveButton("观看视频", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
ad.showVideo(ActivityStackManager.getInstance().getTopActivity(), new ToutiaoAD.OnVideoCloseCallBack() { csjAd.showVideo(ActivityStackManager.getInstance().getTopActivity(), new ToutiaoAD.OnVideoCloseCallBack() {
@Override @Override
public void onClose() { public void onClose() {
function0.invoke(); function0.invoke();
...@@ -59,14 +65,24 @@ public class ReaderManager { ...@@ -59,14 +65,24 @@ public class ReaderManager {
} }
}).create().show(); }).create().show();
return; return;
}else{
csjAd.showVideo(ActivityStackManager.getInstance().getTopActivity(), new ToutiaoAD.OnVideoCloseCallBack() {
@Override
public void onClose() {
function0.invoke();
}
});
} }
} }
/**
* 阅读⻚首次打开 弹框广告(信息流) 广告宽度 320 高度 260 * @param adViewContainer 广告view的容器
*/
@Override @Override
public void getReaderScreenAd(@NotNull View view, @NotNull OnAdViewReceiver receiver, public void getReaderScreenAd(@NotNull View view, @NotNull OnAdViewReceiver receiver,
@Nullable Dialog dialog) { @Nullable Dialog dialog) {
ad.loadAD(applicationContext, receiver, 320, 260, new ToutiaoAD.OnClickListener() { csjAd.loadAD(applicationContext, receiver, 320, 260, new ToutiaoAD.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
dialog.dismiss(); dialog.dismiss();
...@@ -74,16 +90,20 @@ public class ReaderManager { ...@@ -74,16 +90,20 @@ public class ReaderManager {
}); });
} }
/**
* 阅读⻚翻⻚广告(信息流) 广告宽度 320 高度 260 */
@Override @Override
public void getReaderPageAd(@NotNull OnAdViewReceiver receiver) { public void getReaderPageAd(@NotNull OnAdViewReceiver receiver) {
//加载阅读内容⻚广告 建议每次调用,更换不同的广告id csjAd.loadAD(applicationContext, receiver, DensityUtil.px2dip(applicationContext, ScreenUtils.getScreenWidth(applicationContext) - DensityUtil.dip2px(applicationContext, 30f)), DensityUtil.px2dip(applicationContext, 854f), null);
ad.loadAD(applicationContext, receiver, DensityUtil.px2dip(applicationContext, ScreenUtils.getScreenWidth(applicationContext) - DensityUtil.dip2px(applicationContext, 30f)), DensityUtil.px2dip(applicationContext, 854f), null);
} }
/**
* 阅读⻚定时弹窗广告 (激励视频)
*/
@Override @Override
public void getReaderDialogAd(@NotNull View view, @NotNull OnAdViewReceiver receiver, @Nullable Dialog dialog) { public void getReaderDialogAd(@NotNull View view, @NotNull OnAdViewReceiver receiver, @Nullable Dialog dialog) {
ad.loadVideoAd(ActivityStackManager.getInstance().getTopActivity(), receiver); csjAd.loadVideoAd(ActivityStackManager.getInstance().getTopActivity(), receiver);
} }
}); });
......
...@@ -19,6 +19,7 @@ import com.chineseall.reader17ksdk.ChineseAllReaderApplication; ...@@ -19,6 +19,7 @@ import com.chineseall.reader17ksdk.ChineseAllReaderApplication;
import com.chineseall.reader17ksdk.aop.AspectTest; import com.chineseall.reader17ksdk.aop.AspectTest;
import com.chineseall.reader17ksdk.utils.LogUtils; import com.chineseall.reader17ksdk.utils.LogUtils;
import com.chineseall.reader17ksdk.utils.book.ScreenUtils; import com.chineseall.reader17ksdk.utils.book.ScreenUtils;
import com.mints.library.utils.json.JsonUtil;
import java.util.List; import java.util.List;
...@@ -102,7 +103,7 @@ public class ToutiaoAD { ...@@ -102,7 +103,7 @@ public class ToutiaoAD {
LogUtils.d(tag, "load ad"); LogUtils.d(tag, "load ad");
if (mTTAdNative == null) { if (mTTAdNative == null) {
mTTAdNative = TTAdSdk.getAdManager().createAdNative(context); mTTAdNative = TtCsjAdManager.get().createAdNative(context);
} }
// if (ADConfig.TYPE_NATIVE.equals(adParamers.type)){ // if (ADConfig.TYPE_NATIVE.equals(adParamers.type)){
//信息流 //信息流
...@@ -125,7 +126,7 @@ public class ToutiaoAD { ...@@ -125,7 +126,7 @@ public class ToutiaoAD {
this.context = context; this.context = context;
if (mTTAdNative == null) { if (mTTAdNative == null) {
mTTAdNative = TTAdSdk.getAdManager().createAdNative(context); mTTAdNative = TtCsjAdManager.get().createAdNative(context);
} }
initVedioAD(context, receiver); initVedioAD(context, receiver);
} }
...@@ -252,19 +253,15 @@ public class ToutiaoAD { ...@@ -252,19 +253,15 @@ public class ToutiaoAD {
private void initVedioAD(final Context context, OnAdViewReceiver receiver) { private void initVedioAD(final Context context, OnAdViewReceiver receiver) {
// SharedPreferencesUtil.getInstance().putBoolean(StringConstants.VIDEO_TASK_FINISH, false); // SharedPreferencesUtil.getInstance().putBoolean(StringConstants.VIDEO_TASK_FINISH, false);
AdSlot adSlot = new AdSlot.Builder() AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_VEDIO_MOREDIALOG) .setCodeId(TtCsjAdManager.TT_AD_VEDIO_READ)
.setSupportDeepLink(true) .setSupportDeepLink(true)
.setAdCount(1) //个性化模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可。仅模板广告需要设置此参数
.setImageAcceptedSize(ScreenUtils.getScreenWidth(ChineseAllReaderApplication.globalContext) / 4, ScreenUtils.getScreenHeight(ChineseAllReaderApplication.globalContext) / 4) .setExpressViewAcceptedSize(500, 500)
.setRewardName("金币") //奖励的名称 .setImageAcceptedSize(1080, 1920)
.setRewardAmount(3) //奖励的数量 .setUserID(UserManager.getInstance().getUserID())//用户id,必传参数
//必传参数,表来标识应用侧唯一用户;若非服务器回调模式或不需sdk透传 .setMediaExtra("media_extra")
//可设置为空字符串 .setOrientation(TTAdConstant.VERTICAL)
.setUserID("")
.setOrientation(TTAdConstant.VERTICAL) //设置期望视频播放的方向,为TTAdConstant.HORIZONTAL或TTAdConstant.VERTICAL
.setMediaExtra("media_extra") //用户透传的信息,可不传
.build(); .build();
mTTAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() { mTTAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override @Override
......
...@@ -43,6 +43,7 @@ public class TtCsjAdManager { ...@@ -43,6 +43,7 @@ public class TtCsjAdManager {
public static String TT_AD_VEDIO_HOMEVEDIO = "945744137";// 首页视频翻倍 public static String TT_AD_VEDIO_HOMEVEDIO = "945744137";// 首页视频翻倍
public static String TT_AD_VEDIO_SMALLHOMEVEDIO = "945744186";// 短视频翻倍 public static String TT_AD_VEDIO_SMALLHOMEVEDIO = "945744186";// 短视频翻倍
public static String TT_AD_VEDIO_KYLVEDIO = "945791766";// 来电秀视频 public static String TT_AD_VEDIO_KYLVEDIO = "945791766";// 来电秀视频
public static String TT_AD_VEDIO_READ = "945997554";// 听读
/*全屏视频*/ /*全屏视频*/
public static String TT_AD_FULLVEDIO_ALL = "945752969";// 通用 public static String TT_AD_FULLVEDIO_ALL = "945752969";// 通用
/*信息流*/ /*信息流*/
......
...@@ -28,10 +28,10 @@ class BookPresenter : BasePresenter<BookView>() { ...@@ -28,10 +28,10 @@ class BookPresenter : BasePresenter<BookView>() {
val data = baseResponse.data val data = baseResponse.data
when (code) { when (code) {
200 -> { 200 -> {
if (data != null) { // if (data != null) {
val coin = data["coin"].asInt // val coin = data["coin"].asInt
view.readSecondsSuc(coin) // view.readSecondsSuc(coin)
} // }
} }
else -> view.showToast(baseResponse.getMessage()) else -> view.showToast(baseResponse.getMessage())
} }
......
...@@ -8,10 +8,7 @@ import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFr ...@@ -8,10 +8,7 @@ import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFr
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ui.activitys.base.BaseActivity import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.fragment.FriendsFragment import com.mints.goodmoney.ui.fragment.*
import com.mints.goodmoney.ui.fragment.KuYinYueFragment
import com.mints.goodmoney.ui.fragment.RsNewsFragment
import com.mints.goodmoney.ui.fragment.WzFragment
import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_wrapper.* import kotlinx.android.synthetic.main.activity_wrapper.*
...@@ -66,6 +63,10 @@ class WrapperActivity : BaseActivity(), View.OnClickListener { ...@@ -66,6 +63,10 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
// transaction.show(wellChosenFragment) // transaction.show(wellChosenFragment)
// transaction.commitAllowingStateLoss() // transaction.commitAllowingStateLoss()
} }
Constant.WRAPPER_TYPE_BOOK -> {
tv_title.text = "书城"
currentFragment = ReaderFragment()
}
Constant.WRAPPER_TYPE_FRIENDS -> { Constant.WRAPPER_TYPE_FRIENDS -> {
tv_title.text = "瓜分百万现金福利" tv_title.text = "瓜分百万现金福利"
currentFragment = FriendsFragment(true) currentFragment = FriendsFragment(true)
......
...@@ -16,9 +16,6 @@ import android.widget.GridView ...@@ -16,9 +16,6 @@ import android.widget.GridView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.launcher.ARouter
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenActionType
import com.chineseall.reader17ksdk.utils.RouterPath
import com.component.dly.xzzq_ywsdk.YwSDK_WebActivity.Companion.open import com.component.dly.xzzq_ywsdk.YwSDK_WebActivity.Companion.open
import com.fly.scenemodule.SceneUtil import com.fly.scenemodule.SceneUtil
import com.mints.goodmoney.BuildConfig import com.mints.goodmoney.BuildConfig
......
package com.mints.goodmoney.ui.fragment package com.mints.goodmoney.ui.fragment
import android.view.View
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import com.chineseall.reader17ksdk.ChineseAllReaderApplication import com.chineseall.reader17ksdk.ChineseAllReaderApplication
import com.chineseall.reader17ksdk.callbacks.OnReadCallBack import com.chineseall.reader17ksdk.callbacks.OnReadCallBack
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.mvp.presenters.RsNewsPresenter import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.mvp.views.RsNewsView import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.presenters.BookPresenter
import com.mints.goodmoney.mvp.views.BookView
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_zy.*
/** /**
* 描述:听读 * 描述:听读
* 作者:孟崔广 * 作者:孟崔广
* 时间:2021/04/08 10:55 * 时间:2021/04/08 10:55
*/ */
class ReaderFragment : LazyLoadBaseFragment(), RsNewsView, OnReadCallBack { class ReaderFragment : LazyLoadBaseFragment(), BookView, OnReadCallBack {
private val wellChosenFragment by lazy { WellChosenFragment("home") } private val wellChosenFragment by lazy { WellChosenFragment("home") }
private val rsNewsPresenter by lazy { RsNewsPresenter() } private val bookPresenter by lazy { BookPresenter() }
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() {
rsNewsPresenter.attachView(this) bookPresenter.attachView(this)
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fragment, wellChosenFragment, ReaderFragment::class.java.simpleName) transaction.add(R.id.fragment, wellChosenFragment, ReaderFragment::class.java.simpleName)
...@@ -36,20 +41,44 @@ class ReaderFragment : LazyLoadBaseFragment(), RsNewsView, OnReadCallBack { ...@@ -36,20 +41,44 @@ class ReaderFragment : LazyLoadBaseFragment(), RsNewsView, OnReadCallBack {
ChineseAllReaderApplication.setOnReadCallBack(this, 30 * 1000) ChineseAllReaderApplication.setOnReadCallBack(this, 30 * 1000)
} }
override fun onFragmentResume() {
super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
bookPresenter.getReadInfo()
}
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
ChineseAllReaderApplication.destory() ChineseAllReaderApplication.destory()
rsNewsPresenter.detachView() bookPresenter.detachView()
} }
override fun readSecondsSuc(coin: Int, video: Int, supr: Int) { override fun readSecondsSuc(coin: Int) {
}
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()
}
} }
override fun onReceive(map: Map<String, Any>) { override fun onReceive(map: Map<String, Any>) {
val time = map.get("time").toString() val time = map.get("time").toString().toInt()
rsNewsPresenter.addNewsSeconds(time.toInt()) val seconds = (time / 1000)
// 阅读5秒以上 保存时长
if (seconds > 5) {
bookPresenter.addReadSeconds(seconds)
}
LogUtil.d("ReaderFragment", "time:-->${time}") LogUtil.d("ReaderFragment", "time:-->${time}")
} }
......
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