Skip to content

Commit

Permalink
Merge pull request #4224 from malirauf/fix#4142
Browse files Browse the repository at this point in the history
fix NPE on LoadFilesListTask#listTrashBinFiles
  • Loading branch information
VishalNehra committed Aug 20, 2024
2 parents 53adcbb + dd33caa commit 4612942
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,26 +604,31 @@ else if (cursor.getCount() > 0 && cursor.moveToFirst()) {

TrashBin trashBin = AppConfig.getInstance().getTrashBinInstance();
List<LayoutElementParcelable> deletedFiles = new ArrayList<>();
if (trashBin != null) {
for (TrashBinFile trashBinFile : trashBin.listFilesInBin()) {
HybridFile hybridFile =

This comment has been minimized.

Copy link
@Playgirlkaybraz11

Playgirlkaybraz11 Aug 29, 2024

app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java

This comment has been minimized.

Copy link
@Playgirlkaybraz11
new HybridFile(
OpenMode.TRASH_BIN,
trashBinFile.getDeletedPath(
AppConfig.getInstance().getTrashBinInstance().getConfig()),
trashBinFile.getFileName(),
trashBinFile.isDirectory());
if (trashBinFile.getDeleteTime() != null) {
hybridFile.setLastModified(trashBinFile.getDeleteTime() * 1000);
}
LayoutElementParcelable element = hybridFile.generateLayoutElement(context, true);
element.date = trashBinFile.getDeleteTime();
element.longSize = trashBinFile.getSizeBytes();
element.size = Formatter.formatFileSize(context, trashBinFile.getSizeBytes());
element.dateModification = Utils.getDate(context, trashBinFile.getDeleteTime() * 1000);
element.isDirectory = trashBinFile.isDirectory();
deletedFiles.add(element);

if (trashBin == null) return deletedFiles;

List<TrashBinFile> filesInBin = trashBin.listFilesInBin();

if (filesInBin == null) return deletedFiles;

for (TrashBinFile trashBinFile : filesInBin) {
HybridFile hybridFile =
new HybridFile(
OpenMode.TRASH_BIN,
trashBinFile.getDeletedPath(
AppConfig.getInstance().getTrashBinInstance().getConfig()),
trashBinFile.getFileName(),
trashBinFile.isDirectory());
if (trashBinFile.getDeleteTime() != null) {
hybridFile.setLastModified(trashBinFile.getDeleteTime() * 1000);
}
LayoutElementParcelable element = hybridFile.generateLayoutElement(context, true);
element.date = trashBinFile.getDeleteTime();
element.longSize = trashBinFile.getSizeBytes();
element.size = Formatter.formatFileSize(context, trashBinFile.getSizeBytes());
element.dateModification = Utils.getDate(context, trashBinFile.getDeleteTime() * 1000);
element.isDirectory = trashBinFile.isDirectory();
deletedFiles.add(element);
}
return deletedFiles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ public TrashBinFile toTrashBinRestoreFile(Context context) {
TrashBin trashBin = AppConfig.getInstance().getTrashBinInstance();
for (TrashBinFile trashBinFile : trashBin.listFilesInBin()) {
if (trashBinFile.getDeletedPath(trashBin.getConfig()).equals(path)) {
// finding path to restore to
// finding path to restore tof
return new TrashBinFile(
getName(context), isDirectory(context), trashBinFile.getPath(), length(context), null);
}
Expand Down

1 comment on commit 4612942

@Playgirlkaybraz11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.