mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
fix: npe on MediaRepository.java in list sorting comparison
This commit is contained in:
parent
0131bc171a
commit
701a40b224
@ -16,15 +16,16 @@ import androidx.annotation.WorkerThread;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
|
||||||
import org.session.libsession.utilities.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
import org.session.libsignal.utilities.guava.Optional;
|
import org.session.libsignal.utilities.guava.Optional;
|
||||||
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||||
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -78,12 +79,18 @@ class MediaRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Comparator<MediaFolder> folderNameSorter = (Comparator<MediaFolder>) (first, second) -> {
|
||||||
|
if (first == null || first.getTitle() == null) return 1;
|
||||||
|
if (second == null || second.getTitle() == null) return -1;
|
||||||
|
return first.getTitle().toLowerCase().compareTo(second.getTitle().toLowerCase());
|
||||||
|
};
|
||||||
|
|
||||||
List<MediaFolder> mediaFolders = Stream.of(folders.values()).map(folder -> new MediaFolder(folder.getThumbnail(),
|
List<MediaFolder> mediaFolders = Stream.of(folders.values()).map(folder -> new MediaFolder(folder.getThumbnail(),
|
||||||
folder.getTitle(),
|
folder.getTitle(),
|
||||||
folder.getCount(),
|
folder.getCount(),
|
||||||
folder.getBucketId()))
|
folder.getBucketId()))
|
||||||
.sorted((o1, o2) -> o1.getTitle().toLowerCase().compareTo(o2.getTitle().toLowerCase()))
|
.sorted(folderNameSorter)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Uri allMediaThumbnail = imageFolders.getThumbnailTimestamp() > videoFolders.getThumbnailTimestamp() ? imageFolders.getThumbnail() : videoFolders.getThumbnail();
|
Uri allMediaThumbnail = imageFolders.getThumbnailTimestamp() > videoFolders.getThumbnailTimestamp() ? imageFolders.getThumbnail() : videoFolders.getThumbnail();
|
||||||
if (allMediaThumbnail != null) {
|
if (allMediaThumbnail != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user