fix: folders in recent files

This commit is contained in:
tehcneko 2023-01-07 10:58:13 +08:00 committed by xtaodada
parent d784214c4b
commit 5773a43da5
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -968,13 +968,18 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
ListItem item = new ListItem();
item.title = file.getName();
item.file = file;
String fname = file.getName();
String[] sp = fname.split("\\.");
item.ext = sp.length > 1 ? sp[sp.length - 1] : "?";
item.subtitle = AndroidUtilities.formatFileSize(file.length());
fname = fname.toLowerCase();
if (fname.endsWith(".jpg") || fname.endsWith(".png") || fname.endsWith(".gif") || fname.endsWith(".jpeg")) {
item.thumb = file.getAbsolutePath();
if (file.isDirectory()) {
item.icon = R.drawable.files_folder;
item.subtitle = LocaleController.getString("Folder", R.string.Folder);
} else {
String fname = file.getName();
String[] sp = fname.split("\\.");
item.ext = sp.length > 1 ? sp[sp.length - 1] : "?";
item.subtitle = AndroidUtilities.formatFileSize(file.length());
fname = fname.toLowerCase();
if (fname.endsWith(".jpg") || fname.endsWith(".png") || fname.endsWith(".gif") || fname.endsWith(".jpeg")) {
item.thumb = file.getAbsolutePath();
}
}
listAdapter.recentItems.add(item);
}