Commit cb20f0ca authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 284e3ca2
...@@ -16,6 +16,7 @@ import com.mints.goodmoney.manager.KsManager; ...@@ -16,6 +16,7 @@ import com.mints.goodmoney.manager.KsManager;
import com.mints.goodmoney.manager.LiebaoManager; import com.mints.goodmoney.manager.LiebaoManager;
import com.mints.goodmoney.manager.MhManager; import com.mints.goodmoney.manager.MhManager;
import com.mints.goodmoney.manager.MiitHelper; import com.mints.goodmoney.manager.MiitHelper;
import com.mints.goodmoney.manager.ReaderManager;
import com.mints.goodmoney.manager.RsNewsManager; import com.mints.goodmoney.manager.RsNewsManager;
import com.mints.goodmoney.manager.TtCsjAdManager; import com.mints.goodmoney.manager.TtCsjAdManager;
import com.mints.goodmoney.manager.TzManager; import com.mints.goodmoney.manager.TzManager;
...@@ -148,6 +149,8 @@ public class MintsApplication extends MultiDexApplication { ...@@ -148,6 +149,8 @@ public class MintsApplication extends MultiDexApplication {
// 自定义logger // 自定义logger
bindLogger(); bindLogger();
ReaderManager.init(this);
// 子线程初始化三方SDK // 子线程初始化三方SDK
String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid()); String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid());
......
...@@ -28,42 +28,26 @@ import kotlin.jvm.functions.Function0; ...@@ -28,42 +28,26 @@ import kotlin.jvm.functions.Function0;
public class ReaderManager { public class ReaderManager {
public static void init(Application applicationContext) { public static void init(Application applicationContext) {
ChineseAllReaderApplication.Companion.install(applicationContext, "1209", "asdf!@", "6", "0", new AdProvider() { ToutiaoAD ad = new ToutiaoAD();
ChineseAllReaderApplication.Companion.install(applicationContext, "1242", "hzq@1242", "32", "0", new AdProvider() {
@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( if (NetworkUtil.isNetworkAvailable(applicationContext) && !NetworkUtil.INSTANCE.isWifiConnected(
applicationContext applicationContext
) )
) { ) {
// 网络可用&&wifi没有连接 kotlin 写法
// AlertDialog.Builder(ActivityStackManager.getInstance().getTopActivity())
// .setTitle("温馨提示")
// .setMessage("当前处于移动网络,播放视频会消耗流量,确定播放?")
// .setPositiveButton("观看视频") { d, _ ->
// d.dismiss()
// ad.showVideo(ActivityStackManager.getInstance().getTopActivity()) {
// block()
// }
// }
// .setNegativeButton("取消") { d, _ ->
// d.dismiss()
// }.create().show()
// return
new AlertDialog.Builder(ActivityStackManager.getInstance().getTopActivity()) new AlertDialog.Builder(ActivityStackManager.getInstance().getTopActivity())
.setTitle("温馨提示") .setTitle("温馨提示")
.setMessage("当前处于移动网络,播放视频会消耗流量,确定播放?") .setMessage("当前处于移动网络,播放视频会消耗流量,确定播放?")
.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() { ad.showVideo(ActivityStackManager.getInstance().getTopActivity(), new ToutiaoAD.OnVideoCloseCallBack() {
// @Override @Override
// public void onClose() { public void onClose() {
// function0.invoke(); function0.invoke();
// } }
// }); });
} }
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override @Override
...@@ -80,40 +64,40 @@ public class ReaderManager { ...@@ -80,40 +64,40 @@ public class ReaderManager {
@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() { ad.loadAD(applicationContext, receiver, 320, 260, new ToutiaoAD.OnClickListener() {
// @Override @Override
// public void onClick() { public void onClick() {
// dialog.dismiss(); dialog.dismiss();
// } }
// }); });
} }
@Override @Override
public void getReaderPageAd(@NotNull OnAdViewReceiver receiver) { public void getReaderPageAd(@NotNull OnAdViewReceiver receiver) {
// ad.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); ad.loadVideoAd(ActivityStackManager.getInstance().getTopActivity(), receiver);
} }
}); });
ChineseAllReaderApplication.Companion.setOnReadCallBack(new OnReadCallBack() { // ChineseAllReaderApplication.Companion.setOnReadCallBack(new OnReadCallBack() {
/** // /**
* "time" : 阅读总时长 // * "time" : 阅读总时长
* "bookName" : 书名 // * "bookName" : 书名
* "chapterName" : 当前章节名 // * "chapterName" : 当前章节名
* "pageInChapter" : 当前章节内阅读页码 // * "pageInChapter" : 当前章节内阅读页码
* "chapterTotalPages" : 当前章节总页数 // * "chapterTotalPages" : 当前章节总页数
*/ // */
@Override // @Override
public void onReceive(@NotNull Map<String, ?> map) { // public void onReceive(@NotNull Map<String, ?> map) {
Object time = map.get("time"); // Object time = map.get("time");
ToastUtil.toast(time + ""); //// ToastUtil.toast(time + "");
//
} // }
}, 30 * 1000);//间隔30秒 回调一次 间隔任意设置 // }, 30 * 1000);//间隔30秒 回调一次 间隔任意设置
} }
} }
...@@ -3,12 +3,15 @@ package com.mints.goodmoney.ui.activitys ...@@ -3,12 +3,15 @@ package com.mints.goodmoney.ui.activitys
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 com.fly.scenemodule.fragment.IdiomFragment import androidx.fragment.app.FragmentTransaction
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment
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.* import com.mints.goodmoney.ui.fragment.FriendsFragment
import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils import com.mints.goodmoney.ui.fragment.KuYinYueFragment
import com.mints.goodmoney.ui.fragment.WzFragment
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_wrapper.* import kotlinx.android.synthetic.main.activity_wrapper.*
import kotlinx.android.synthetic.main.header_layout.* import kotlinx.android.synthetic.main.header_layout.*
...@@ -17,6 +20,7 @@ import kotlinx.android.synthetic.main.header_layout.* ...@@ -17,6 +20,7 @@ import kotlinx.android.synthetic.main.header_layout.*
* 作者:孟崔广 * 作者:孟崔广
* 时间:2020/12/10 12:39 * 时间:2020/12/10 12:39
*/ */
@AndroidEntryPoint
class WrapperActivity : BaseActivity(), View.OnClickListener { class WrapperActivity : BaseActivity(), View.OnClickListener {
private var wrapperType = Constant.WRAPPER_TYPE_NEWS private var wrapperType = Constant.WRAPPER_TYPE_NEWS
...@@ -50,11 +54,28 @@ class WrapperActivity : BaseActivity(), View.OnClickListener { ...@@ -50,11 +54,28 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
var currentFragment: Fragment? var currentFragment: Fragment?
when (wrapperType) { when (wrapperType) {
Constant.WRAPPER_TYPE_NEWS -> { Constant.WRAPPER_TYPE_NEWS -> {
layoutWrapper.visibility = View.INVISIBLE // layoutWrapper.visibility = View.INVISIBLE
val layoutParams = layoutWrapper.layoutParams // val layoutParams = layoutWrapper.layoutParams
layoutParams.height = BubbleUtils.dp2px(30) // layoutParams.height = BubbleUtils.dp2px(30)
tv_title.text = "新闻" // tv_title.text = "新闻"
currentFragment = RsNewsFragment() // currentFragment = RsNewsFragment()
// val wellChosenFragment = WellChosenFragment("home")
// val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
// transaction.add(R.id.flWrapper, wellChosenFragment, WellChosenFragment::class.java.simpleName)
// transaction.show(wellChosenFragment)
// transaction.commitAllowingStateLoss()
// ViewPager viewPager = findViewById(R.id.view_pager);
// TabLayout tabLayout = findViewById(R.id.tabs);
//
// viewPager.setAdapter(new MyViewPageAdapter(getSupportFragmentManager()));
// tabLayout.setupWithViewPager(viewPager);
val wellChosenFragment = WellChosenFragment("home")
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.flWrapper, wellChosenFragment, WellChosenFragment::class.java.toString())
transaction.show(wellChosenFragment)
transaction.commitAllowingStateLoss()
} }
Constant.WRAPPER_TYPE_FRIENDS -> { Constant.WRAPPER_TYPE_FRIENDS -> {
tv_title.text = "瓜分百万现金福利" tv_title.text = "瓜分百万现金福利"
...@@ -74,11 +95,11 @@ class WrapperActivity : BaseActivity(), View.OnClickListener { ...@@ -74,11 +95,11 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
} }
} }
if (!currentFragment.isAdded) { // if (!currentFragment.isAdded) {
// 提交事务 // // 提交事务
supportFragmentManager.beginTransaction() // supportFragmentManager.beginTransaction()
.add(R.id.flWrapper, currentFragment).commitAllowingStateLoss() // .add(R.id.flWrapper, currentFragment,currentFragment.tag).commitAllowingStateLoss()
} // }
} }
private fun initListener() { private fun initListener() {
......
package com.mints.goodmoney.ui.fragment
import androidx.fragment.app.FragmentTransaction
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment
import com.mints.goodmoney.R
import com.mints.goodmoney.mvp.presenters.RsNewsPresenter
import com.mints.goodmoney.mvp.views.RsNewsView
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
/**
* 描述:听读
* 作者:孟崔广
* 时间:2020/12/9 10:55
*/
class ReaderFragment : LazyLoadBaseFragment(), RsNewsView {
private val wellChosenFragment by lazy { WellChosenFragment("home") }
private val rsNewsPresenter by lazy { RsNewsPresenter() }
override fun getContentViewLayoutID() = R.layout.fragment_main_zy
override fun initViewsAndEvents() {}
override fun onFragmentFirstVisible() {
rsNewsPresenter.attachView(this)
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fragment, wellChosenFragment, ReaderFragment::class.java.simpleName)
transaction.show(wellChosenFragment)
transaction.commitAllowingStateLoss()
}
override fun onDestroy() {
super.onDestroy()
rsNewsPresenter.detachView()
}
override fun readSecondsSuc(coin: Int, video: Int, supr: Int) {
}
}
\ No newline at end of file
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