Skip to content

Commit 83371d2

Browse files
committed
getFileByRemotePath
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent f74fd34 commit 83371d2

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ OCFile getFileByDecryptedRemotePath(String path) {
147147
return getFileByPath(ProviderTableMeta.FILE_PATH_DECRYPTED, path);
148148
}
149149

150+
@Nullable
151+
public OCFile getFileByRemotePath(String path) {
152+
OCFile file = getFileByDecryptedRemotePath(path);
153+
154+
if (file == null) {
155+
file = getFileByDecryptedRemotePath(path + OCFile.PATH_SEPARATOR);
156+
}
157+
158+
return file;
159+
}
160+
150161
public void addCreateFileOfflineOperation(String[] localPaths, String[] remotePaths) {
151162
if (localPaths.length != remotePaths.length) {
152163
Log_OC.d(TAG, "Local path and remote path size do not match");

app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.nextcloud.model.SearchResultEntryType
1717
import com.nextcloud.utils.CalendarEventManager
1818
import com.nextcloud.utils.ContactManager
1919
import com.nextcloud.utils.GlideHelper
20+
import com.nextcloud.utils.extensions.getPreviewEndpoint
2021
import com.nextcloud.utils.extensions.getType
2122
import com.owncloud.android.databinding.UnifiedSearchItemBinding
2223
import com.owncloud.android.datamodel.FileDataStorageManager
@@ -59,15 +60,24 @@ class UnifiedSearchItemViewHolder(
5960

6061
viewThemeUtils.platform.colorImageView(binding.thumbnail, ColorRole.PRIMARY)
6162

62-
val remotePath = entry.remotePath() + OCFile.PATH_SEPARATOR
63-
val file = storageManager.getFileByDecryptedRemotePath(remotePath)
63+
val file = storageManager.getFileByRemotePath(entry.remotePath())
6464
val entryType = entry.getType()
6565

6666
if (file?.isFolder == true) {
6767
// FIXME: icon is not visible
68-
overlayManager.setFolderThumbnail(file, binding.thumbnail, binding.thumbnailShimmer)
68+
overlayManager.setFolderThumbnail(
69+
file,
70+
binding.thumbnail,
71+
binding.thumbnailShimmer
72+
)
6973
} else {
7074
filesAction.loadFileThumbnail(entry, onClientReady = {
75+
if (binding.thumbnail.tag == entry.thumbnailUrl) {
76+
return@loadFileThumbnail
77+
}
78+
79+
binding.thumbnail.tag = entry.thumbnailUrl
80+
7181
GlideHelper.loadIntoImageView(
7282
context,
7383
it,

0 commit comments

Comments
 (0)