[charter]

[3.2.0]
[缓存fragment]
This commit is contained in:
yangyakun
2023-04-28 11:46:59 +08:00
parent 977a3c77fb
commit f42b2e8e51

View File

@@ -34,6 +34,11 @@ class M1ContainFragment :
var fragmentTag: String = M1VideoFragment.TAG
var fragment: Fragment? = null
var videoFragment:M1VideoFragment? = null
var softFragment:M1SoftFragment? = null
var orderInfoFragment:OrderInfoFragment? = null
var orderLineFragment:M1OrderLineFragment? = null
override fun onCreate(savedInstanceState: Bundle?) {
CallerLogger.d(M_BUS_P+ TAG, "onCreate")
super.onCreate(savedInstanceState)
@@ -50,29 +55,45 @@ class M1ContainFragment :
CallerLogger.d(M_BUS_P+ TAG, "setCheckView")
when (tab) {
VIDEOTAB -> {
fragment = childFragmentManager.findFragmentByTag(M1VideoFragment.TAG)
fragment =videoFragment
?: childFragmentManager.findFragmentByTag(M1VideoFragment.TAG)
?: M1VideoFragment.newInstance()
if(videoFragment==null&&fragment is M1VideoFragment){
videoFragment = fragment as M1VideoFragment
}
bb_bottom_bar.setCheckIndex(BottomBar.SelectView.VIDEO)
cl_container.setBackgroundResource(R.drawable.m1_function_bg)
fragmentTag = M1VideoFragment.TAG
}
SETTINGSOFTTAB -> {
fragment = childFragmentManager.findFragmentByTag(M1SoftFragment.TAG)
fragment =softFragment
?: childFragmentManager.findFragmentByTag(M1SoftFragment.TAG)
?: M1SoftFragment.newInstance()
if(softFragment==null&&fragment is M1SoftFragment){
softFragment = fragment as M1SoftFragment
}
bb_bottom_bar.setCheckIndex(BottomBar.SelectView.SETTING)
cl_container.setBackgroundResource(R.drawable.m1_function_bg)
fragmentTag = M1SoftFragment.TAG
}
ORDERINFO -> {
fragment = childFragmentManager.findFragmentByTag(OrderInfoFragment.TAG)
fragment =orderInfoFragment
?: childFragmentManager.findFragmentByTag(OrderInfoFragment.TAG)
?: OrderInfoFragment.newInstance()
if(orderInfoFragment==null&&fragment is OrderInfoFragment){
orderInfoFragment = fragment as OrderInfoFragment
}
bb_bottom_bar.setCheckIndex(BottomBar.SelectView.ORDERINFO)
cl_container.background = null
fragmentTag = OrderInfoFragment.TAG
}
SELECTLINE ->{
fragment = childFragmentManager.findFragmentByTag(M1OrderLineFragment.TAG)
fragment =orderLineFragment
?: childFragmentManager.findFragmentByTag(M1OrderLineFragment.TAG)
?: M1OrderLineFragment.newInstance()
if(orderLineFragment==null&&fragment is M1OrderLineFragment){
orderLineFragment = fragment as M1OrderLineFragment
}
bb_bottom_bar.setCheckIndex(BottomBar.SelectView.LINE)
cl_container.background = null
fragmentTag = M1OrderLineFragment.TAG