public <T extends DashBaseFragment> T getFragmentByClass(Class<T> class1) {
   for (WeakReference<DashBaseFragment> f : fragList) {
     DashBaseFragment b = f.get();
     if (b != null && !b.isDetached() && class1.isInstance(b)) {
       return (T) b;
     }
   }
   return null;
 }
 private <T extends Fragment> void showFragment(
     FragmentManager manager,
     FragmentTransaction fragmentTransaction,
     String tag,
     Class<T> cl,
     boolean cond) {
   try {
     Fragment frag = manager.findFragmentByTag(tag);
     if (manager.findFragmentByTag(tag) == null) {
       if (cond) {
         T ni = cl.newInstance();
         fragmentTransaction.add(R.id.content, ni, tag);
       }
     } else {
       if (!cond) {
         fragmentTransaction.remove(manager.findFragmentByTag(tag));
       } else if (frag instanceof DashBaseFragment) {
         if (((DashBaseFragment) frag).getView() != null) {
           ((DashBaseFragment) frag).onOpenDash();
         }
       }
     }
   } catch (Exception e) {
     getMyApplication().showToastMessage("Error showing dashboard " + tag);
     e.printStackTrace();
   }
 }