public void navToActivitiesView(boolean forceRefresh) { // mActivity.disableUpButton(); if (!Utils.isNetworkOn() || !forceRefresh) { List<SeafActivity> activities = getDataManager().getActivitiesFromCache(); if (activities != null) { updateAdapterWithActivities(activities); return; } } // load repos in background showLoading(true); ConcurrentAsyncTask.execute(new LoadTask(getDataManager())); }
private void setFileView(SeafDirent dirent, Viewholder viewHolder, int position) { NavContext nav = mActivity.getNavContext(); DataManager dataManager = mActivity.getDataManager(); String repoName = nav.getRepoName(); String repoID = nav.getRepoID(); String filePath = Utils.pathJoin(nav.getDirPath(), dirent.name); File file = dataManager.getLocalRepoFile(repoName, repoID, filePath); boolean cacheExists = false; if (file.exists()) { SeafCachedFile cf = dataManager.getCachedFile(repoName, repoID, filePath); String subtitle = null; long size = file.length(); if (size == dirent.size) { subtitle = dirent.getSubtitle(); } else { subtitle = Utils.readableFileSize(size) + ", modified"; } if (cf != null) { cacheExists = true; if (dirent.id.equals(cf.fileID) && dirent.size == size) { subtitle += ", cached"; } } viewHolder.subtitle.setText(subtitle); if (Utils.isViewableImage(file.getName())) { setImageThumbNail(file, dirent, dataManager, viewHolder); } else viewHolder.icon.setImageResource(dirent.getIcon()); } else { viewHolder.subtitle.setText(dirent.getSubtitle()); viewHolder.icon.setImageResource(dirent.getIcon()); } setFileAction(dirent, viewHolder, position, cacheExists); }