| @ -0,0 +1,47 @@ | |||
| package com.nivesh.production.niveshfd.partnerOnBoarding.ui.fragments1 | |||
| import android.app.Activity | |||
| import android.content.Context | |||
| import androidx.fragment.app.Fragment | |||
| import com.nivesh.production.niveshfd.fd.ui.activity.BaseActivity | |||
| open class BaseFragment : Fragment() { | |||
| private lateinit var mActivity: Activity | |||
| override fun onAttach(context: Context) { | |||
| super.onAttach(context) | |||
| mActivity = context as BaseActivity | |||
| } | |||
| companion object { | |||
| fun addFragment( | |||
| activity: BaseActivity, | |||
| containerViewId: Int, | |||
| fragment: Fragment, | |||
| tag: String, | |||
| addToBackStack: Boolean | |||
| ) { | |||
| val fragmentTransaction = activity.supportFragmentManager.beginTransaction() | |||
| fragmentTransaction.add(containerViewId, fragment, tag) | |||
| if (addToBackStack) { | |||
| fragmentTransaction.addToBackStack(tag) | |||
| } | |||
| fragmentTransaction.commit() | |||
| } | |||
| fun replaceFragment( | |||
| activity: BaseActivity, | |||
| containerViewId: Int, | |||
| fragment: Fragment, | |||
| tag: String, | |||
| addToBackStack: Boolean | |||
| ) { | |||
| val fragmentTransaction = activity.supportFragmentManager.beginTransaction() | |||
| fragmentTransaction.replace(containerViewId, fragment, tag) | |||
| if (addToBackStack) { | |||
| fragmentTransaction.addToBackStack(tag) | |||
| } | |||
| fragmentTransaction.commit() | |||
| } | |||
| } | |||
| } | |||
Powered by TurnKey Linux.