From 4b1a30a1485e0a1deaa8224a85c1e2d9aabc0ed4 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 18 Dec 2024 11:21:15 +0100 Subject: [PATCH] use api Signed-off-by: alperozturk --- .../java/com/nextcloud/client/database/dao/FileDao.kt | 3 +++ .../android/datamodel/FileDataStorageManager.java | 9 +++++++++ .../owncloud/android/ui/adapter/OCFileListAdapter.java | 2 +- .../android/ui/adapter/RecommendedFilesAdapter.kt | 2 +- .../owncloud/android/ui/fragment/OCFileListFragment.java | 5 +++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/database/dao/FileDao.kt b/app/src/main/java/com/nextcloud/client/database/dao/FileDao.kt index 37ef4568c5..509383e7eb 100644 --- a/app/src/main/java/com/nextcloud/client/database/dao/FileDao.kt +++ b/app/src/main/java/com/nextcloud/client/database/dao/FileDao.kt @@ -17,6 +17,9 @@ interface FileDao { @Query("SELECT * FROM filelist WHERE _id = :id LIMIT 1") fun getFileById(id: Long): FileEntity? + @Query("SELECT * FROM filelist WHERE local_id = :localId LIMIT 1") + fun getFileByLocalId(localId: Long): FileEntity? + @Query("SELECT * FROM filelist WHERE path = :path AND file_owner = :fileOwner LIMIT 1") fun getFileByEncryptedRemotePath(path: String, fileOwner: String): FileEntity? diff --git a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index 8df5366f51..f05eb396da 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -345,6 +345,15 @@ public class FileDataStorageManager { return null; } + public @Nullable + OCFile getFileByLocalId(long localId) { + FileEntity fileEntity = fileDao.getFileByLocalId(localId); + if (fileEntity != null) { + return createFileInstance(fileEntity); + } + return null; + } + public @Nullable OCFile getFileByLocalPath(String path) { FileEntity fileEntity = fileDao.getFileByLocalPath(path, user.getAccountName()); diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index 1624a355e7..60535bedde 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -781,7 +781,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter mOriginalMenuItems = new ArrayList<>(); - private ArrayList recommendedFiles = new ArrayList<>(); + private final ArrayList recommendedFiles = new ArrayList<>(); @Override public void onCreate(Bundle savedInstanceState) { @@ -443,7 +443,8 @@ public class OCFileListFragment extends ExtendedListFragment implements final var client = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), requireActivity()); final var result = new GetRecommendationsRemoteOperation().execute(client); if (result.isSuccess()) { - recommendedFiles.addAll(result.getResultData().getRecommendations()); + final var recommendations = result.getResultData().getRecommendations(); + recommendedFiles.addAll(recommendations); requireActivity().runOnUiThread(new Runnable() { @SuppressLint("NotifyDataSetChanged") @Override