Commit 31bda680 authored by mengcuiguang's avatar mengcuiguang

代码优化

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