private void switchFragment(Fragment from, Fragment to) {
if (from == null && to == null){
return;
}
FragmentTransaction fragmentTransaction= fragManager.beginTransaction();
if (!to.isAdded()) {
fragmentTransaction.add(R.id.frame_layout, to).hide(from).show(to);
localFragment = to;
} else {
fragmentTransaction.hide(from).show(to);
localFragment = to;
}
fragmentTransaction.commit();
}