Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-18 11:21:15 +01:00
parent a5cdb0c57b
commit e0f096b8d8
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
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")
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?

View file

@ -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());

View file

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

View file

@ -49,7 +49,7 @@ class RecommendedFilesAdapter(
name.text = item.name
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)

View file

@ -252,7 +252,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
protected MenuItemAddRemove menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH;
private List<MenuItem> mOriginalMenuItems = new ArrayList<>();
private ArrayList<Recommendation> recommendedFiles = new ArrayList<>();
private final ArrayList<Recommendation> 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