public void restoreFromStateWrapper(SavedStateWrapper mSavedState, Activity context) {
   if (mSavedState != null) {
     mActive = mSavedState.mActive;
     for (Crumb c : mSavedState.mCrumbs) {
       if (c.getFile().isDocumentTreeFile())
         ((DocumentFileWrapper) c.getFile()).restoreWrapped(context);
       addCrumb(c, false);
     }
     requestLayout();
     setVisibility(mSavedState.mVisibility);
   }
 }
  public void setActiveOrAdd(@NonNull Crumb crumb, boolean forceRecreate) {
    if (forceRecreate || !setActive(crumb)) {
      clearCrumbs();
      final List<File> newPathSet = new ArrayList<>();

      newPathSet.add(0, crumb.getFile());

      File p = crumb.getFile();
      if (!isStorageOrSd(p)) {
        while ((p = p.getParent()) != null) {
          newPathSet.add(0, p);
          if (isStorageOrSd(p)) break;
        }
      }

      for (int index = 0; index < newPathSet.size(); index++) {
        final File fi = newPathSet.get(index);
        crumb = new Crumb(fi);

        // Restore scroll positions saved before clearing
        if (mOldCrumbs != null) {
          for (Iterator<Crumb> iterator = mOldCrumbs.iterator(); iterator.hasNext(); ) {
            Crumb old = iterator.next();
            if (old.equals(crumb)) {
              crumb.setScrollPosition(old.getScrollPosition());
              crumb.setScrollOffset(old.getScrollOffset());
              crumb.setQuery(old.getQuery());
              iterator.remove(); // minimize number of linear passes by removing un-used crumbs from
              // history
              break;
            }
          }
        }

        addCrumb(crumb, true);
      }

      // History no longer needed
      mOldCrumbs = null;
    } else {
      if (isStorageOrSd(crumb.getFile())) {
        Crumb c = mCrumbs.get(0);
        while (c != null && !isStorageOrSd(c.getFile())) {
          removeCrumbAt(0);
          if (mCrumbs.size() > 0) c = mCrumbs.get(0);
        }
        updateIndices();
        requestLayout();
      }
    }
  }