diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 8dbe52f18a..e4d08e2335 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -56,7 +56,6 @@ import com.owncloud.android.utils.theme.ViewThemeUtils; import java.io.File; import java.util.Arrays; -import java.util.List; import java.util.Optional; import androidx.annotation.NonNull; @@ -119,14 +118,20 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter { switch (group.type) { - case CURRENT -> { - new Thread(() -> { - uploadHelper.cancelFileUploads( - Arrays.asList(group.items), - group.getItem(0).getAccountName()); - parentActivity.runOnUiThread(this::loadUploadItemsFromDb); - }).start(); - } + case CURRENT -> new Thread(() -> { + OCUpload ocUpload = group.getItem(0); + if (ocUpload == null) { + return; + } + + String accountName = ocUpload.getAccountName(); + if (accountName == null) { + return; + } + + uploadHelper.cancelFileUploads(Arrays.asList(group.items), accountName); + parentActivity.runOnUiThread(this::loadUploadItemsFromDb); + }).start(); case FINISHED -> { uploadsStorageManager.clearSuccessfulUploads(); loadUploadItemsFromDb(); @@ -287,16 +292,27 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter= uploadGroups.length) { + return; + } + + UploadGroup uploadGroup = uploadGroups[section]; + if (uploadGroup == null) { + return; + } + + OCUpload item = uploadGroup.getItem(relativePosition); + if (item == null) { + return; + } + ItemViewHolder itemViewHolder = (ItemViewHolder) holder; - - OCUpload item = uploadGroups[section].getItem(relativePosition); - itemViewHolder.binding.uploadName.setText(item.getLocalPath()); // local file name File remoteFile = new File(item.getRemotePath()); String fileName = remoteFile.getName(); - if (fileName.length() == 0) { + if (fileName.isEmpty()) { fileName = File.separator; } itemViewHolder.binding.uploadName.setText(fileName); @@ -937,9 +953,9 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter= items.length) { + return null; + } + return items[position]; }