use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.
the class LocalFileListAdapter method swapDirectory.
/**
* Change the adapted directory for a new one
*
* @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
*/
public void swapDirectory(final File directory) {
localFileListFragmentInterface.setLoading(true);
final Handler uiHandler = new Handler(Looper.getMainLooper());
Executors.newSingleThreadExecutor().execute(() -> {
List<File> fileList;
if (directory == null) {
fileList = new ArrayList<>();
} else {
if (mLocalFolderPicker) {
fileList = getFolders(directory);
} else {
fileList = getFiles(directory);
}
}
if (!fileList.isEmpty()) {
FileSortOrder sortOrder = preferences.getSortOrderByType(FileSortOrder.Type.localFileListView);
fileList = sortOrder.sortLocalFiles(fileList);
// Fetch preferences for showing hidden files
boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
if (!showHiddenFiles) {
fileList = filterHiddenFiles(fileList);
}
}
final List<File> newFiles = fileList;
uiHandler.post(() -> {
mFiles = newFiles;
mFilesAll = new ArrayList<>();
mFilesAll.addAll(mFiles);
notifyDataSetChanged();
localFileListFragmentInterface.setLoading(false);
});
});
}
use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.
the class OCFileListAdapter method setData.
public void setData(List<Object> objects, SearchType searchType, FileDataStorageManager storageManager, @Nullable OCFile folder, boolean clear) {
if (storageManager != null && mStorageManager == null) {
mStorageManager = storageManager;
showShareAvatar = mStorageManager.getCapability(user.getAccountName()).getVersion().isShareesOnDavSupported();
}
if (mStorageManager == null) {
mStorageManager = new FileDataStorageManager(user, activity.getContentResolver());
}
if (clear) {
mFiles.clear();
resetLastTimestamp();
preferences.setPhotoSearchTimestamp(0);
VirtualFolderType type;
switch(searchType) {
case FAVORITE_SEARCH:
type = VirtualFolderType.FAVORITE;
break;
case GALLERY_SEARCH:
type = VirtualFolderType.GALLERY;
break;
default:
type = VirtualFolderType.NONE;
break;
}
if (type != VirtualFolderType.GALLERY) {
mStorageManager.deleteVirtuals(type);
}
}
// early exit
if (objects.size() > 0 && mStorageManager != null) {
if (searchType == SearchType.SHARED_FILTER) {
parseShares(objects);
} else {
if (searchType != SearchType.GALLERY_SEARCH) {
parseVirtuals(objects, searchType);
}
}
}
if (searchType != SearchType.GALLERY_SEARCH && searchType != SearchType.RECENTLY_MODIFIED_SEARCH) {
FileSortOrder sortOrder = preferences.getSortOrderByFolder(folder);
mFiles = sortOrder.sortCloudFiles(mFiles);
} else {
mFiles = FileStorageUtils.sortOcFolderDescDateModifiedWithoutFavoritesFirst(mFiles);
}
mFilesAll.clear();
mFilesAll.addAll(mFiles);
new Handler(Looper.getMainLooper()).post(this::notifyDataSetChanged);
}
use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.
the class OCFileListAdapter method setFavoriteAttributeForItemID.
public void setFavoriteAttributeForItemID(String fileId, boolean favorite, boolean removeFromList) {
for (OCFile file : mFiles) {
if (file.getRemoteId().equals(fileId)) {
file.setFavorite(favorite);
if (removeFromList) {
mFiles.remove(file);
}
break;
}
}
for (OCFile file : mFilesAll) {
if (file.getRemoteId().equals(fileId)) {
file.setFavorite(favorite);
mStorageManager.saveFile(file);
if (removeFromList) {
mFiles.remove(file);
}
break;
}
}
FileSortOrder sortOrder = preferences.getSortOrderByFolder(currentDirectory);
mFiles = sortOrder.sortCloudFiles(mFiles);
new Handler(Looper.getMainLooper()).post(this::notifyDataSetChanged);
}
use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.
the class SortingOrderDialogFragment method setupActiveOrderSelection.
/**
* tints the icon reflecting the actual sorting choice in the apps primary color.
*/
private void setupActiveOrderSelection() {
final int color = ThemeColorUtils.primaryColor(null, true, true, getContext());
for (View view : mTaggedViews) {
if (!((FileSortOrder) view.getTag()).name.equals(mCurrentSortOrderName)) {
continue;
}
if (view instanceof ImageButton) {
ThemeButtonUtils.colorImageButton((ImageButton) view, color);
}
if (view instanceof TextView) {
((TextView) view).setTextColor(color);
((TextView) view).setTypeface(Typeface.DEFAULT_BOLD);
}
}
}
Aggregations