Example #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    mPresenter = createPresenter();
    mPresenter.attachView(this);
    mPresenter.onCreate();
  }
Example #2
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ((TextView) view.findViewById(R.id.empty)).setText(mPresenter.getEmptyText());
    mRecyclerView = (RecyclerView) view.findViewById(R.id.list);
    mRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

    mPresenter.onViewCreated();
  }
Example #3
0
  @Override
  public void initializeRecyclerView(boolean gridMode, int size, MediaAdapter adapter) {
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContextCompat(), size));

    mAdapter = adapter;
    mRecyclerView.setAdapter(mAdapter);

    if (gridMode) {
      mPresenter.setGridModeOn(true);
    }
  }
Example #4
0
 protected final void setExplorerMode(final boolean explorerMode) {
   MainActivity act = (MainActivity) getActivity();
   if (act == null) return;
   PreferenceManager.getDefaultSharedPreferences(act)
       .edit()
       .putBoolean("explorer_mode", explorerMode)
       .commit();
   reload();
   act.getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
   act.setTitle(mPresenter.getTitle());
   act.invalidateOptionsMenu();
   act.invalidateCrumbs();
 }
Example #5
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.choose:
       getActivity()
           .setResult(
               RESULT_OK, new Intent().setData(Uri.fromFile(new File(mPresenter.getAlbumPath()))));
       getActivity().finish();
       return true;
     case R.id.viewMode:
       mPresenter.setGridModeOn(!PrefUtils.isGridMode(getActivity()));
       return true;
     case R.id.viewExplorer:
       setExplorerMode(!PrefUtils.isExplorerMode(getActivity()));
       return true;
     case R.id.filterAll:
       setFilterMode(MediaAdapter.FileFilterMode.ALL);
       return true;
     case R.id.filterPhotos:
       setFilterMode(MediaAdapter.FileFilterMode.PHOTOS);
       return true;
     case R.id.filterVideos:
       setFilterMode(MediaAdapter.FileFilterMode.VIDEOS);
       return true;
     case R.id.sortNameAsc:
       setSortMode(MediaAdapter.SortMode.NAME_ASC, mPresenter.getAlbumPath());
       return true;
     case R.id.sortNameDesc:
       setSortMode(
           MediaAdapter.SortMode.NAME_DESC, sortRememberDir ? mPresenter.getAlbumPath() : null);
       return true;
     case R.id.sortModifiedAsc:
       setSortMode(
           MediaAdapter.SortMode.MODIFIED_DATE_ASC,
           sortRememberDir ? mPresenter.getAlbumPath() : null);
       return true;
     case R.id.sortModifiedDesc:
       setSortMode(
           MediaAdapter.SortMode.MODIFIED_DATE_DESC,
           sortRememberDir ? mPresenter.getAlbumPath() : null);
       return true;
     case R.id.sortCurrentDir:
       item.setChecked(!item.isChecked());
       if (item.isChecked()) {
         sortRememberDir = true;
         setSortMode(sortCache, mPresenter.getAlbumPath());
       } else {
         sortRememberDir = false;
         SortMemoryProvider.forget(getActivity(), mPresenter.getAlbumPath());
         setSortMode(SortMemoryProvider.getSortMode(getActivity(), null), null);
       }
       return true;
     case R.id.gridSizeOne:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(1);
       break;
     case R.id.gridSizeTwo:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(2);
       break;
     case R.id.gridSizeThree:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(3);
       break;
     case R.id.gridSizeFour:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(4);
       break;
     case R.id.gridSizeFive:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(5);
       break;
     case R.id.gridSizeSix:
       item.setChecked(!item.isChecked());
       mPresenter.setGridColumns(6);
       break;
   }
   return super.onOptionsItemSelected(item);
 }
Example #6
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment, menu);

    if (getActivity() != null) {
      boolean isMain =
          mPresenter.getAlbumPath() == null
              || mPresenter.getAlbumPath().equals(AlbumEntry.ALBUM_OVERVIEW);
      boolean isAlbumSelect = ((MainActivity) getActivity()).isSelectAlbumMode();
      menu.findItem(R.id.choose).setVisible(!isMain && isAlbumSelect);
      menu.findItem(R.id.viewMode).setVisible(!isAlbumSelect);
      menu.findItem(R.id.filter).setVisible(!isAlbumSelect);

      sortCache = SortMemoryProvider.getSortMode(getActivity(), mPresenter.getAlbumPath());
      switch (sortCache) {
        default:
          menu.findItem(R.id.sortNameAsc).setChecked(true);
          break;
        case NAME_DESC:
          menu.findItem(R.id.sortNameDesc).setChecked(true);
          break;
        case MODIFIED_DATE_ASC:
          menu.findItem(R.id.sortModifiedAsc).setChecked(true);
          break;
        case MODIFIED_DATE_DESC:
          menu.findItem(R.id.sortModifiedDesc).setChecked(true);
          break;
      }
      menu.findItem(R.id.sortCurrentDir).setChecked(sortRememberDir);

      MediaAdapter.FileFilterMode filterMode = PrefUtils.getFilterMode(getActivity());
      switch (filterMode) {
        default:
          setStatus(null);
          menu.findItem(R.id.filterAll).setChecked(true);
          break;
        case PHOTOS:
          setStatus(getString(R.string.filtering_photos));
          menu.findItem(R.id.filterPhotos).setChecked(true);
          break;
        case VIDEOS:
          setStatus(getString(R.string.filtering_videos));
          menu.findItem(R.id.filterVideos).setChecked(true);
          break;
      }

      switch (PrefUtils.getGridColumns(getActivity())) {
        default:
          menu.findItem(R.id.gridSizeOne).setChecked(true);
          break;
        case 2:
          menu.findItem(R.id.gridSizeTwo).setChecked(true);
          break;
        case 3:
          menu.findItem(R.id.gridSizeThree).setChecked(true);
          break;
        case 4:
          menu.findItem(R.id.gridSizeFour).setChecked(true);
          break;
        case 5:
          menu.findItem(R.id.gridSizeFive).setChecked(true);
          break;
        case 6:
          menu.findItem(R.id.gridSizeSix).setChecked(true);
          break;
      }
    }

    menu.findItem(R.id.viewExplorer).setChecked(PrefUtils.isExplorerMode(getActivity()));
    if (PrefUtils.isGridMode(getContextCompat())) {
      menu.findItem(R.id.viewMode).setIcon(R.drawable.ic_action_view_list);
    } else {
      menu.findItem(R.id.viewMode).setIcon(R.drawable.ic_action_view_grid);
    }
  }
Example #7
0
 @Override
 public void onResume() {
   super.onResume();
   mPresenter.onResume();
 }