This is ActivityUtil code
public class ActivityUtil {
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment, int frameId, String fragmentTag) {
//Fragment fragment1=fragmentManager.findFragmentByTag(fragmentTag);
Preconditions.checkNotNull(fragmentManager);
Preconditions.checkNotNull(fragment);
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(frameId, fragment, fragmentTag);
transaction.addToBackStack(fragmentTag);
transaction.commit();
}
}
This is main fragment class here i want add /replace fragment transaction by using kotlin fragment i.e,CameraFragment Class
I Already used Photofragment class now i want change the kotlin fragment, how do achieve this scenario?
public class ExpLotBcodeFragment extends Fragment{
public ExpLotBcodeFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRetainInstance(true);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_exp_lot_bcode, container, false);
}
@OnClick({R.id.scan})
public void onClick(View view) {
switch (view.getId()) {
case R.id.scan:
//here i want to add kotlin call CameraFragment class
//This is old call
ActivityUtil.addFragmentToActivity(getFragmentManager(),
photoFragment, R.id.frame_content, "photoFragment");
break;
}
This is kotlin class
class CameraFragment : Fragment() {
companion object {
fun newInstance(): CameraFragment {
return CameraFragment ()
}
}
override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_exp_lot_bcode, container, false)
}
}
From CameraFragment class i want to add/replace to ExpLotBcodeFragment class ?