예제 #1
0
 /** Set state mode based on explicit user action. */
 private void setUserMode(int mode) {
   mState.userMode = mode;
   /// M: Check the fragment get from FragmentManager whether is null.
   DirectoryFragment directory = DirectoryFragment.get(getFragmentManager());
   if (directory != null) {
     directory.onUserModeChanged();
   } else {
     Log.w(TAG, "setUserMode with null DirectoryFragment in activity:" + this.hashCode());
   }
 }
예제 #2
0
  private void onCurrentDirectoryChanged(int anim) {
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();

    mDirectoryContainer.setDrawDisappearingFirst(anim == ANIM_DOWN);

    if (cwd == null) {
      // No directory means recents
      if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
        RecentsCreateFragment.show(fm);
      } else {
        DirectoryFragment.showRecentsOpen(fm, anim);

        /// M: When state has stored, we need use store state to init fragment(this may happen when
        // activity
        /// re-create, in this case we need use the userMode store in saveInstance, and only when
        // activity
        /// first created we need follow the below design. {@
        if (!mState.restored) {
          // Start recents in grid when requesting visual things
          final boolean visualMimes =
              MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes);
          mState.userMode = visualMimes ? MODE_GRID : MODE_LIST;
          mState.derivedMode = mState.userMode;
        }
        /// @}
      }
    } else {
      if (mState.currentSearch != null) {
        // Ongoing search
        DirectoryFragment.showSearch(fm, root, mState.currentSearch, anim);
      } else {
        // Normal boring directory
        DirectoryFragment.showNormal(fm, root, cwd, anim);
      }
    }

    // Forget any replacement target
    if (mState.action == ACTION_CREATE) {
      final SaveFragment save = SaveFragment.get(fm);
      if (save != null) {
        save.setReplaceTarget(null);
      }
    }

    if (mState.action == ACTION_OPEN_TREE) {
      final PickFragment pick = PickFragment.get(fm);
      if (pick != null) {
        final CharSequence displayName = (mState.stack.size() <= 1) ? root.title : cwd.displayName;
        pick.setPickTarget(cwd, displayName);
      }
    }

    final RootsFragment roots = RootsFragment.get(fm);
    if (roots != null) {
      roots.onCurrentRootChanged();
    }

    updateActionBar();
    invalidateOptionsMenu();
    dumpStack();
  }
예제 #3
0
 private void setDisplayFileSize(boolean display) {
   LocalPreferences.setDisplayFileSize(this, display);
   mState.showSize = display;
   DirectoryFragment.get(getFragmentManager()).onDisplayStateChanged();
   invalidateOptionsMenu();
 }