@Override
  public void onBackPressed() {
    if ((null != plist) && plist.isNotEmpty()) {
      plist.popBack();
    } else {
      super.onBackPressed();
    }

    if (null != plist && !plist.isNotEmpty()) {
      getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    }
  }
  private void checkLocalRepository(File localDir) {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (localDir != null && settings.getBoolean("repository_initialized", false)) {
      Log.d("PASS", "Check, dir: " + localDir.getAbsolutePath());
      // do not push the fragment if we already have it
      if (fragmentManager.findFragmentByTag("PasswordsList") == null
          || settings.getBoolean("repo_changed", false)) {
        settings.edit().putBoolean("repo_changed", false).apply();

        // todo move this as it is duplicated upthere!
        if (fragmentManager.findFragmentByTag("PasswordsList") != null) {
          fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        }

        // clean things up
        if (fragmentManager.findFragmentByTag("ToCloneOrNot") != null) {
          fragmentManager.popBackStack();
        }

        plist = new PasswordFragment();
        Bundle args = new Bundle();
        args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath());

        plist.setArguments(args);

        fragmentTransaction.addToBackStack("passlist");

        getSupportActionBar().show();

        fragmentTransaction.replace(R.id.main_layout, plist, "PasswordsList");
        fragmentTransaction.commit();
      }
    } else {
      // if we still have the pass list (after deleting the repository for instance) remove it
      if (fragmentManager.findFragmentByTag("PasswordsList") != null) {
        fragmentManager.popBackStack();
      }

      getSupportActionBar().hide();

      ToCloneOrNot cloneFrag = new ToCloneOrNot();
      fragmentTransaction.replace(R.id.main_layout, cloneFrag, "ToCloneOrNot");
      fragmentTransaction.commit();
    }
  }
 private File getCurrentDir() {
   if ((null != plist)) {
     return plist.getCurrentDir();
   }
   return PasswordRepository.getWorkTree();
 }
 public void filterListAdapter(String filter) {
   if ((null != plist)) {
     plist.filterAdapter(filter);
   }
 }
 /** Updates the adapter with the current view of passwords */
 public void refreshListAdapter() {
   if ((null != plist)) {
     plist.refreshAdapter();
   }
 }
 /** clears adapter's content and updates it with a fresh list of passwords from the root */
 public void updateListAdapter() {
   if ((null != plist)) {
     plist.updateAdapter();
   }
 }