/**
   * asynchronously load avatars
   *
   * @param avatarSize set a avatar size in one of 24*24, 32*32, 48*48, 64*64, 72*72, 96*96
   */
  public void loadAvatarUrls(int avatarSize) {
    List<Avatar> avatars;

    if (!Utils.isNetworkOn() || !avatarManager.isNeedToLoadNewAvatars()) {
      // Toast.makeText(AccountsActivity.this, getString(R.string.network_down),
      // Toast.LENGTH_SHORT).show();

      // use cached avatars
      avatars = avatarManager.getAvatarList();

      if (avatars == null) {
        return;
      }

      // set avatars url to adapter
      mAccountAdapter.setAvatars((ArrayList<Avatar>) avatars);

      // notify adapter data changed
      mAccountAdapter.notifyDataSetChanged();

      return;
    }

    LoadAvatarUrlsTask task = new LoadAvatarUrlsTask(avatarSize);

    ConcurrentAsyncTask.execute(task);
  }
Ejemplo n.º 2
0
 public boolean checkCameraUploadNetworkAvailable() {
   if (!Utils.isNetworkOn()) {
     return false;
   }
   // user does not allow mobile connections
   if (!Utils.isWiFiOn() && !isDataPlanAllowed()) {
     return false;
   }
   // Wi-Fi or 2G/3G/4G connections available
   return true;
 }
  private void refreshDir(boolean forceRefresh) {
    String repoID = getNavContext().getRepoID();
    String dirPath = getNavContext().getDirPath();

    if (!Utils.isNetworkOn() || !forceRefresh) {
      List<SeafDirent> dirents =
          getDataManager()
              .getCachedDirents(getNavContext().getRepoID(), getNavContext().getDirPath());
      if (dirents != null) {
        updateAdapterWithDirents(dirents);
        return;
      }
    }

    mLoadDirTask = new LoadDirTask(repoID, dirPath, getDataManager());
    ConcurrentAsyncTask.execute(mLoadDirTask);
  }
  private void chooseRepo(boolean forceRefresh) {
    mStep = STEP_CHOOSE_REPO;
    mUpLayout.setVisibility(View.VISIBLE);
    mCurrentDir = mAccount.getDisplayName();
    setCurrentDirText(mCurrentDir);

    setListAdapter(getReposAdapter());

    getNavContext().setRepoID(null);

    if (!Utils.isNetworkOn() || !forceRefresh) {
      List<SeafRepo> repos = getDataManager().getReposFromCache();
      if (repos != null) {
        updateAdapterWithRepos(repos);
        return;
      }
    }

    mLoadReposTask = new LoadReposTask(getDataManager());
    ConcurrentAsyncTask.execute(mLoadReposTask);
  }