Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-18 11:21:15 +01:00 committed by Alper Öztürk
parent 9aa94c9086
commit 4b1a30a148
5 changed files with 17 additions and 4 deletions

View file

@ -17,6 +17,9 @@ interface FileDao {
@Query("SELECT * FROM filelist WHERE _id = :id LIMIT 1") @Query("SELECT * FROM filelist WHERE _id = :id LIMIT 1")
fun getFileById(id: Long): FileEntity? 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") @Query("SELECT * FROM filelist WHERE path = :path AND file_owner = :fileOwner LIMIT 1")
fun getFileByEncryptedRemotePath(path: String, fileOwner: String): FileEntity? fun getFileByEncryptedRemotePath(path: String, fileOwner: String): FileEntity?

View file

@ -345,6 +345,15 @@ public class FileDataStorageManager {
return null; return null;
} }
public @Nullable
OCFile getFileByLocalId(long localId) {
FileEntity fileEntity = fileDao.getFileByLocalId(localId);
if (fileEntity != null) {
return createFileInstance(fileEntity);
}
return null;
}
public @Nullable public @Nullable
OCFile getFileByLocalPath(String path) { OCFile getFileByLocalPath(String path) {
FileEntity fileEntity = fileDao.getFileByLocalPath(path, user.getAccountName()); FileEntity fileEntity = fileDao.getFileByLocalPath(path, user.getAccountName());

View file

@ -781,7 +781,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
return false; return false;
} }
if (!recommendedFiles.isEmpty()) { if (!recommendedFiles.isEmpty() && currentDirectory.isRootDirectory()) {
return true; return true;
} }

View file

@ -49,7 +49,7 @@ class RecommendedFilesAdapter(
name.text = item.name name.text = item.name
timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp) timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp)
val file = storageManager.getFileById(item.id) ?: return val file = storageManager.getFileByLocalId(item.id) ?: return
delegate.setThumbnail(thumbnail, shimmerThumbnail, file) delegate.setThumbnail(thumbnail, shimmerThumbnail, file)

View file

@ -252,7 +252,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
protected MenuItemAddRemove menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH; protected MenuItemAddRemove menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH;
private List<MenuItem> mOriginalMenuItems = new ArrayList<>(); private List<MenuItem> mOriginalMenuItems = new ArrayList<>();
private ArrayList<Recommendation> recommendedFiles = new ArrayList<>(); private final ArrayList<Recommendation> recommendedFiles = new ArrayList<>();
@Override @Override
public void onCreate(Bundle savedInstanceState) { 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 client = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), requireActivity());
final var result = new GetRecommendationsRemoteOperation().execute(client); final var result = new GetRecommendationsRemoteOperation().execute(client);
if (result.isSuccess()) { if (result.isSuccess()) {
recommendedFiles.addAll(result.getResultData().getRecommendations()); final var recommendations = result.getResultData().getRecommendations();
recommendedFiles.addAll(recommendations);
requireActivity().runOnUiThread(new Runnable() { requireActivity().runOnUiThread(new Runnable() {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override