Commit 31bda680 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4894fee6
......@@ -113,9 +113,9 @@ public class AppConfig {
public static boolean needReportClickAdEvent = false;
/**
* 首页是显示微转
* 首页显示状态 mainFriendsStatus 0-平台分红 1-微转 2-猜成语
*/
public static boolean isMainShowWz = false;
public static int mainFriendsStatus = 0;
/**
* 显示cpd任务下载
......
......@@ -113,8 +113,6 @@ object Constant {
const val CARRIER_RUISHINEWS = "RuiShiNews" //瑞狮新闻
const val CARRIER_RUISHINEWS_DOUBLE = "RuiShiNews_DOUBLE" //瑞狮新闻翻倍
const val CARRIER_RUISHINEWS_CHALLANGE = "RuiShiNews_CHALLANGE" //瑞狮新闻每日挑战
const val CARRIER_RUISHINEWS_SHARE = "RuiShiNews_SHARE" //瑞狮新闻分享
const val CARRIER_RUISHINEWS_SHARE_DOUBLE = "RuiShiNews_SHARE_DOUBLE" //瑞狮新闻分享翻倍
const val CARRIER_CHALLENGE_SHAREFRIEND_DOUBLE = "CHALLENGE_SHAREFRIEND_DOUBLE" //邀请好友翻倍
const val CARRIER_HOMEVEDIO = "HOMEVEDIO" //首页红包
const val CARRIER_HOMEVEDIO_DOUBLE = "HOMEVEDIO_DOUBLE" //首页红包翻倍
......
package com.mints.goodmoney.manager
import android.app.Application
import com.mints.goodmoney.BuildConfig
import com.tencent.smtt.sdk.QbSdk
import com.xr.xrsdk.XRNewsManager
......@@ -11,7 +12,7 @@ import com.xr.xrsdk.XRNewsManager
object RsNewsManager {
private const val APP_ID = "19e575538d2947ad9323e6c2a70d9a7f"
// private const val APP_ID = "wx99a2f75faabecd8c"
private const val APP_ID_TEST = "hzqtest"
private const val WX_APP_ID = "wxc8ac2985f6a805e2"
/**
......@@ -19,6 +20,10 @@ object RsNewsManager {
*/
fun init(application: Application) {
QbSdk.initX5Environment(application, null)
XRNewsManager.getInstance().init(application, APP_ID,WX_APP_ID)
if (BuildConfig.DEBUG) {
XRNewsManager.getInstance().init(application, APP_ID_TEST, WX_APP_ID)
} else {
XRNewsManager.getInstance().init(application, APP_ID, WX_APP_ID)
}
}
}
......@@ -78,6 +78,7 @@ class HomePresenter : BasePresenter<HomeView>() {
if (isLinkView) return
view.hideLoading()
view.showToast(e.message)
view.getHallBaseMsgFail()
}
override fun onNext(baseResponse: BaseResponse<UserTaskMsgBean>) {
......
......@@ -20,6 +20,7 @@ class HorizChannelPresenter : BasePresenter<HorizChannelView>() {
override fun onError(e: Throwable) {
if (isLinkView) return
view.getHomeVedioMsgFail()
}
override fun onNext(baseResponse: BaseResponse<MainVideoMsgBean>) {
......
......@@ -29,10 +29,10 @@ class RsNewsPresenter : BasePresenter<RsNewsView>() {
val data = baseResponse.data
when (code) {
200 -> {
if (data != null) {
val msg = data.getAsJsonObject("msg")
view.readSecondsSuc(msg["xinwenCoin"].asInt, msg["xinwenDoubleCoin"].asInt, msg["xinwenSupr"].asInt)
}
// if (data != null) {
// val msg = data.getAsJsonObject("msg")
// view.readSecondsSuc(msg["xinwenCoin"].asInt, msg["xinwenDoubleCoin"].asInt, msg["xinwenSupr"].asInt)
// }
}
else -> view.showToast(baseResponse.getMessage())
}
......
......@@ -213,7 +213,9 @@ public class TrackPresenter extends BaseTrackPresenter {
if (baseResponse.getStatus() == 200) {
JsonObject data = baseResponse.getData();
if (data != null) {
AppConfig.isMainShowWz = data.get("showCallShow").getAsBoolean();
if (data.get("mainFriendsStatus") != null) {
AppConfig.mainFriendsStatus = data.get("mainFriendsStatus").getAsInt();
}
AppConfig.useAppCpdModelShow = data.get("useAppCpdModelShow").getAsBoolean();
}
}
......
......@@ -6,5 +6,6 @@ import com.mints.goodmoney.mvp.model.UserTaskMsgBean
interface HomeView : BaseView {
fun getHallBaseMsgSuc(data: UserTaskMsgBean)
fun getHallBaseMsgFail()
fun getHomeVedioMsgSuc(data: MainVideoMsgBean)
}
......@@ -4,6 +4,7 @@ import com.mints.goodmoney.mvp.model.MainVideoMsgBean
interface HorizChannelView : BaseView {
fun getHomeVedioMsgFail()
fun getHomeVedioMsgSuc(data: MainVideoMsgBean)
}
\ No newline at end of file
......@@ -43,16 +43,16 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private var channelFragment: Fragment? = null
private var kuYinyueFragment: Fragment? = null
private var idiomFragment: Fragment? = null
private var wzFragment: Fragment? = null
private var currentFragment: Fragment? = null
private var isMainShowWz: Boolean = false// 是否显示来电秀,防止线程不一样
private var mainFriendsStatus: Int = 0// 0-平台分红 1-微转 2-猜成语,防止线程不一样
override fun getContentViewLayoutID() = R.layout.activity_main
override fun initViewsAndEvents() {
ZhangyueManager.onCreateIreader(baseApplication)
// MokuManager.init(this)
showShortVedioLayout()
......@@ -68,15 +68,24 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
// 记录当前Fragment
currentFragment = moneyFragment
}
if (AppConfig.isMainShowWz) {
tab_iv_four.setImageResource(R.drawable.tab_wz_share_btn)
tab_tv_four.text = "猜成语"
isMainShowWz = true
} else {
tab_iv_four.setImageResource(R.drawable.tab_friends_btn)
tab_tv_four.text = "平台分红"
isMainShowWz = false
mainFriendsStatus=AppConfig.mainFriendsStatus
// 0-平台分红 1-微转 2-猜成语,防止线程不一样
when (mainFriendsStatus) {
0 -> {
tab_iv_four.setImageResource(R.drawable.tab_friends_btn)
tab_tv_four.text = "平台分红"
mainFriendsStatus = 0
}
1 -> {
tab_iv_four.setImageResource(R.drawable.tab_friends_btn)
tab_tv_four.text = "分享"
mainFriendsStatus = 1
}
2 -> {
tab_iv_four.setImageResource(R.drawable.tab_wz_share_btn)
tab_tv_four.text = "猜成语"
mainFriendsStatus = 2
}
}
tab_iv_one.isSelected = true
......@@ -214,49 +223,45 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
* 点击第四个tab
*/
fun clickTab4Layout() {
// 是否显示微转
if (isMainShowWz) {
if (!AppConfig.scene_flag) {
SceneManager.signIn(this)
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_FOUR
// 0-平台分红 1-微转 2-猜成语,防止线程不一样
when (mainFriendsStatus) {
0 -> {
if (friendsFragment == null) {
friendsFragment = FriendsFragment()
}
addOrShowFragment(supportFragmentManager, friendsFragment!!, Constant.FRAGMENT_TAG_FOUR)
}
if (TextUtils.isEmpty(UserManager.getInstance().userID)) {
showToast("请先登录账号")
return
1 -> {
if (wzFragment == null) {
wzFragment = WzFragment()
}
addOrShowFragment(supportFragmentManager, wzFragment!!, Constant.FRAGMENT_TAG_FOUR)
}
2 -> {
if (!AppConfig.scene_flag) {
SceneManager.signIn(this)
}
// 猜成语
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_FOUR
if (idiomFragment == null) {
idiomFragment = SceneIdiomFragment()
}
addOrShowFragment(supportFragmentManager, idiomFragment!!, Constant.FRAGMENT_TAG_FOUR)
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
tab_iv_four.isSelected = true
tab_tv_four.isSelected = true
tab_iv_five.isSelected = false
tab_tv_five.isSelected = false
} else {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_FOUR
if (friendsFragment == null) {
friendsFragment = FriendsFragment()
if (TextUtils.isEmpty(UserManager.getInstance().userID)) {
showToast("请先登录账号")
return
}
// 猜成语
if (idiomFragment == null) {
idiomFragment = SceneIdiomFragment()
}
addOrShowFragment(supportFragmentManager, idiomFragment!!, Constant.FRAGMENT_TAG_FOUR)
}
addOrShowFragment(supportFragmentManager, friendsFragment!!, Constant.FRAGMENT_TAG_FOUR)
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
tab_iv_four.isSelected = true
tab_tv_four.isSelected = true
tab_iv_five.isSelected = false
tab_tv_five.isSelected = false
}
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
tab_iv_four.isSelected = true
tab_tv_four.isSelected = true
tab_iv_five.isSelected = false
tab_tv_five.isSelected = false
}
/**
......
......@@ -8,6 +8,7 @@ import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.fragment.*
import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import kotlinx.android.synthetic.main.activity_wrapper.*
import kotlinx.android.synthetic.main.header_layout.*
......@@ -49,6 +50,9 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
var currentFragment: Fragment?
when (wrapperType) {
Constant.WRAPPER_TYPE_NEWS -> {
layoutWrapper.visibility = View.INVISIBLE
val layoutParams = layoutWrapper.layoutParams
layoutParams.height=BubbleUtils.dp2px(30)
tv_title.text = "新闻"
currentFragment = RsNewsFragment()
}
......
......@@ -165,6 +165,11 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis
}
}
override fun getHomeVedioMsgFail() {
tv_fragment_main_redbox.text = "--:--"
rl_fragment_main_redbox.isClickable = false
}
override fun getHomeVedioMsgSuc(data: MainVideoMsgBean) {
if (activity == null || requireActivity().isFinishing) {
return
......
......@@ -260,6 +260,10 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
}
override fun getHallBaseMsgFail() {
tv_fragment_main_redbox.text = "--:--"
rl_fragment_main_redbox.isClickable = false
}
override fun getHomeVedioMsgSuc(data: MainVideoMsgBean) {
if (activity == null || requireActivity().isFinishing) {
......
......@@ -47,7 +47,6 @@ class RsNewsFragment : LazyLoadBaseFragment(), RsNewsView, FinishReadNewsCallBac
}
override fun finishRead(id: String, seconds: Int) {
LogUtil.d("RsNewsFragment","id:${id}")
// rsNewsPresenter.addNewsSeconds(seconds)
rsNewsPresenter.addNewsSeconds(seconds)
}
}
\ 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