| | |
| | | import androidx.fragment.app.FragmentTransaction; |
| | | import androidx.viewbinding.ViewBinding; |
| | | |
| | | import com.runt.open.mvvm.R; |
| | | import com.runt.open.mvvm.base.fragments.BaseFragment; |
| | | import com.runt.open.mvvm.base.model.BaseViewModel; |
| | | |
| | |
| | | * 试用于加载各种fragment需求的activity |
| | | * Created by Runt (qingingrunt2010@qq.com) on 2022/8/13. |
| | | */ |
| | | public class BaseFragmentActivity <VB extends ViewBinding,VM extends BaseViewModel> |
| | | public abstract class BaseFragmentActivity <VB extends ViewBinding,VM extends BaseViewModel> |
| | | extends BaseActivity<VB,VM>{ |
| | | |
| | | |
| | |
| | | * 添加fragment |
| | | * @param fragment |
| | | */ |
| | | protected void addAndShowFragment(BaseFragment fragment){ |
| | | protected void addAndShowFragment(int viewId,BaseFragment fragment){ |
| | | if(fragments.contains(fragment)){ |
| | | showFragment(fragment); |
| | | return; |
| | |
| | | for(int i = 0 ; i < fragments.size() ; i ++){ |
| | | transaction.hide(fragments.get(i)); |
| | | } |
| | | transaction.add(R.id.framelayout,fragment).commit(); |
| | | transaction.add(viewId,fragment).commit(); |
| | | fragments.add(fragment); |
| | | } |
| | | |