コード例 #1
0
  @Override
  public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Bundle args = getArguments();
    bucket = args.getString(BUNDLE_ARGS_S3_BUCKET);
    prefix = args.getString(BUNDLE_ARGS_S3_PREFIX);

    final ProgressDialog dialog =
        getProgressDialog(R.string.content_progress_dialog_message_load_local_content);

    // Create the User File Manager
    AWSMobileClient.defaultMobileClient()
        .createUserFileManager(
            bucket,
            prefix,
            new UserFileManager.BuilderResultHandler() {

              @Override
              public void onComplete(final UserFileManager userFileManager) {
                if (isAdded()) {
                  UserFilesBrowserFragment.this.userFileManager = userFileManager;
                  createContentList(getView(), userFileManager);
                  userFileManager.setContentRemovedListener(contentListItems);
                  dialog.dismiss();
                  refreshContent(currentPath);
                } else {
                  userFileManager.destroy();
                }
              }
            });
  }
コード例 #2
0
 @Override
 public void onResume() {
   super.onResume();
   if (userFileManager != null) {
     userFileManager.setContentRemovedListener(contentListItems);
     refreshContent(currentPath);
   }
 }
コード例 #3
0
 @Override
 public void onPause() {
   super.onPause();
   if (userFileManager != null) {
     // Remove any Progress listeners that may be registered.
     userFileManager.clearAllListeners();
   }
 }
コード例 #4
0
  @Override
  public void onDestroyView() {
    unregisterForContextMenu(cacheLimitTextView);

    if (userFileManager != null) {
      userFileManager.destroy();
    }

    super.onDestroyView();
  }
コード例 #5
0
 @Override
 public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
   menu.add(refreshText);
   menu.add(downloadRecentText);
   menu.add(setCacheSizeText);
   menu.add(clearCacheText);
   menu.add(uploadText);
   menu.add(newFolderText);
   super.onCreateOptionsMenu(menu, inflater);
 }
コード例 #6
0
 @Override
 public void onCreate(final Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   refreshText = getString(R.string.content_refresh_text);
   downloadRecentText = getString(R.string.content_download_recent_text);
   setCacheSizeText = getString(R.string.content_set_cache_size_text);
   clearCacheText = getString(R.string.content_clear_cache_text);
   uploadText = getString(R.string.user_files_browser_upload_text);
   newFolderText = getString(R.string.user_files_browser_new_folder_text);
   setHasOptionsMenu(true);
 }
コード例 #7
0
  @Override
  public void onCreateContextMenu(
      final ContextMenu menu, final View view, final ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    if (view == cacheLimitTextView) {
      for (final SpannableString string : ContentUtils.cacheSizeStrings) {
        menu.add(string).setActionView(view);
      }
      menu.setHeaderTitle(ContentUtils.getCenteredString(setCacheSizeText));
    } else if (view.getId() == listView.getId()) {
      final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
      final ContentItem content = contentListItems.getItem(info.position).getContentItem();

      if (ContentState.REMOTE_DIRECTORY.equals(content.getContentState())) {
        menu.add(R.string.user_files_browser_context_menu_delete).setActionView(view);
      } else {
        final ContentState contentState = content.getContentState();
        final boolean isNewerVersionAvailable =
            ContentState.isCachedWithNewerVersionAvailableOrTransferring(contentState);
        final boolean isCached = contentState == ContentState.CACHED || isNewerVersionAvailable;
        final boolean isPinned = userFileManager.isContentPinned(content.getFilePath());

        // if item is downloaded
        if (isCached) {
          menu.add(getString(R.string.content_context_menu_open)).setActionView(view);
        } else {
          menu.add(R.string.content_context_menu_open_remote).setActionView(view);
          menu.add(getString(R.string.content_context_menu_download)).setActionView(view);
        }
        if (isNewerVersionAvailable) {
          menu.add(getString(R.string.content_context_menu_download_latest)).setActionView(view);
        }
        if (isCached && !isPinned) {
          menu.add(getString(R.string.content_context_menu_pin)).setActionView(view);
        }
        if (!isCached) {
          menu.add(getString(R.string.content_context_menu_download_pin)).setActionView(view);
        }
        if (isPinned) {
          menu.add(getString(R.string.content_context_menu_unpin)).setActionView(view);
        }
        if (isCached) {
          menu.add(getString(R.string.content_context_menu_delete_local)).setActionView(view);
        }
        menu.add(R.string.user_files_browser_context_menu_delete).setActionView(view);
      }
      menu.setHeaderTitle(content.getFilePath());
    }
  }