Commit f180b56c authored by mengcuiguang's avatar mengcuiguang

代码优化

parent d052105b
...@@ -64,6 +64,8 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView { ...@@ -64,6 +64,8 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView {
private var currentFragment: Fragment? = null private var currentFragment: Fragment? = null
private var phoneDialog: PhoneDialog? = null private var phoneDialog: PhoneDialog? = null
private var isLoadFlag = false
override fun getContentViewLayoutID() = R.layout.activity_main override fun getContentViewLayoutID() = R.layout.activity_main
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
...@@ -77,35 +79,7 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView { ...@@ -77,35 +79,7 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView {
tab_rl_msg.setOnClickListener(this) tab_rl_msg.setOnClickListener(this)
tab_rl_my.setOnClickListener(this) tab_rl_my.setOnClickListener(this)
if (UserHelper.instance.isBpkg()) {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
if (squareFragment == null) {
squareFragment = SquareFragment()
}
if (!squareFragment!!.isAdded) {
// 提交事务
supportFragmentManager.beginTransaction()
.add(R.id.content_layout, squareFragment!!).commitAllowingStateLoss()
// 记录当前Fragment
currentFragment = squareFragment
}
tab_iv_square.isSelected = true
tab_tv_square.isSelected = true
} else {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_ONE
if (videoFragment == null) {
videoFragment = FirstFragment()
}
if (!videoFragment!!.isAdded) {
// 提交事务
supportFragmentManager.beginTransaction()
.add(R.id.content_layout, videoFragment!!).commitAllowingStateLoss()
// 记录当前Fragment
currentFragment = videoFragment
}
tab_iv_video.isSelected = true
tab_tv_video.isSelected = true
}
initUnreadCountReceiver() initUnreadCountReceiver()
} }
...@@ -221,11 +195,60 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView { ...@@ -221,11 +195,60 @@ class MainActivity : BaseActivity(), View.OnClickListener, MainActView {
tab_rl_square.visibility = View.VISIBLE tab_rl_square.visibility = View.VISIBLE
tab_rl_invite.visibility = View.VISIBLE tab_rl_invite.visibility = View.VISIBLE
tab_rl_msg.visibility = View.VISIBLE tab_rl_msg.visibility = View.VISIBLE
if (!isLoadFlag) {
if (UserHelper.instance.isBpkg()) {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
if (squareFragment == null) {
squareFragment = SquareFragment()
}
if (!squareFragment!!.isAdded) {
// 提交事务
supportFragmentManager.beginTransaction()
.add(R.id.content_layout, squareFragment!!).commitAllowingStateLoss()
// 记录当前Fragment
currentFragment = squareFragment
}
tab_iv_square.isSelected = true
tab_tv_square.isSelected = true
} else {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_ONE
if (videoFragment == null) {
videoFragment = FirstFragment()
}
if (!videoFragment!!.isAdded) {
// 提交事务
supportFragmentManager.beginTransaction()
.add(R.id.content_layout, videoFragment!!).commitAllowingStateLoss()
// 记录当前Fragment
currentFragment = videoFragment
}
tab_iv_video.isSelected = true
tab_tv_video.isSelected = true
}
}
} else { } else {
tab_rl_square.visibility = View.GONE tab_rl_square.visibility = View.GONE
tab_rl_invite.visibility = View.GONE tab_rl_invite.visibility = View.GONE
tab_rl_msg.visibility = View.GONE tab_rl_msg.visibility = View.GONE
if (!isLoadFlag) {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_ONE
if (videoFragment == null) {
videoFragment = FirstFragment()
}
if (!videoFragment!!.isAdded) {
// 提交事务
supportFragmentManager.beginTransaction()
.add(R.id.content_layout, videoFragment!!).commitAllowingStateLoss()
// 记录当前Fragment
currentFragment = videoFragment
}
tab_iv_video.isSelected = true
tab_tv_video.isSelected = true
}
} }
this.isLoadFlag = true
} }
/** /**
......
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