album renaming performance review (WIP)
This commit is contained in:
parent
96422e3340
commit
3355779f16
3 changed files with 9 additions and 9 deletions
|
@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -190,6 +191,9 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
|
|||
result.error("renameDirectory-args", "failed because of missing arguments", null);
|
||||
return;
|
||||
}
|
||||
if (!dirPath.endsWith(File.separator)) {
|
||||
dirPath += File.separator;
|
||||
}
|
||||
|
||||
ImageProvider provider = new MediaStoreImageProvider();
|
||||
provider.renameDirectory(activity, dirPath, newName, new ImageProvider.AlbumRenameOpCallback() {
|
||||
|
|
|
@ -90,11 +90,7 @@ public abstract class ImageProvider {
|
|||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public void renameDirectory(Context context, String oldDirPath, String newDirName, final AlbumRenameOpCallback callback) {
|
||||
if (!oldDirPath.endsWith(File.separator)) {
|
||||
oldDirPath += File.separator;
|
||||
}
|
||||
|
||||
public void renameDirectory(Context context, final String oldDirPath, String newDirName, final AlbumRenameOpCallback callback) {
|
||||
DocumentFileCompat destinationDirDocFile = StorageUtils.createDirectoryIfAbsent(context, oldDirPath);
|
||||
if (destinationDirDocFile == null) {
|
||||
callback.onFailure(new Exception("failed to find directory at path=" + oldDirPath));
|
||||
|
@ -118,15 +114,16 @@ public abstract class ImageProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
String[] oldEntryPaths = entries.stream().map(entry -> oldDirPath + entry.get("displayName")).toArray(String[]::new);
|
||||
String[] mimeTypes = entries.stream().map(entry -> (String) entry.get("mimeType")).toArray(String[]::new);
|
||||
MediaScannerConnection.scanFile(context, oldEntryPaths, mimeTypes, null);
|
||||
|
||||
List<SettableFuture<Map<String, Object>>> scanFutures = new ArrayList<>();
|
||||
String newDirPath = new File(oldDirPath).getParent() + File.separator + newDirName + File.separator;
|
||||
for (Map<String, Object> entry : entries) {
|
||||
String displayName = (String) entry.get("displayName");
|
||||
String mimeType = (String) entry.get("mimeType");
|
||||
|
||||
String oldEntryPath = oldDirPath + displayName;
|
||||
MediaScannerConnection.scanFile(context, new String[]{oldEntryPath}, new String[]{mimeType}, null);
|
||||
|
||||
SettableFuture<Map<String, Object>> scanFuture = SettableFuture.create();
|
||||
scanFutures.add(scanFuture);
|
||||
String newEntryPath = newDirPath + displayName;
|
||||
|
|
|
@ -219,7 +219,6 @@ class _CollectionScrollViewState extends State<CollectionScrollView> {
|
|||
text: 'No favourites',
|
||||
);
|
||||
}
|
||||
debugPrint('collection.filters=${collection.filters}');
|
||||
if (collection.filters.any((filter) => filter is MimeFilter && filter.mime == MimeTypes.anyVideo)) {
|
||||
return EmptyContent(
|
||||
icon: AIcons.video,
|
||||
|
|
Loading…
Reference in a new issue