Skip to content

Commit 89ee4b0

Browse files
committed
use ResultParser
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 6123665 commit 89ee4b0

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

app/src/main/java/com/nextcloud/utils/ResultParser.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
1212
object ResultParser {
1313
@Suppress("DEPRECATION", "ReturnCount")
1414
@JvmStatic
15-
fun <T : Any> RemoteOperationResult<*>.dataOfType(type: Class<T>): List<T> {
15+
fun <T : Any> RemoteOperationResult<*>.list(type: Class<T>): List<T> {
1616
if (!isSuccess) return emptyList()
1717
val data = data ?: return emptyList()
1818
return data.filterIsInstance(type)
1919
}
2020

21-
inline fun <reified T : Any> RemoteOperationResult<*>.dataOfType(): List<T> = dataOfType(T::class.java)
21+
inline fun <reified T : Any> RemoteOperationResult<*>.list(): List<T> = list(T::class.java)
2222

2323
@JvmStatic
24-
fun <T : Any> RemoteOperationResult<*>.firstDataOfTypeOrNull(type: Class<T>): T? = dataOfType(type).firstOrNull()
24+
fun <T : Any> RemoteOperationResult<*>.data(type: Class<T>): T? = list(type).firstOrNull()
2525
}

app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
304304
sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result);
305305
}
306306

307-
308-
final var remoteFiles = ResultParser.dataOfType(result, RemoteFile.class);
307+
final var remoteFiles = ResultParser.list(result, RemoteFile.class);
309308
if (!remoteFiles.isEmpty() && !mSyncFullAccount && !mOnlyFileMetadata) {
310309
// this needed because if file has new share or share is removed, eTag is not changing.
311310
// that's why another separate EVENT_SINGLE_FOLDER_SHARES_SYNCED introduced before.

0 commit comments

Comments
 (0)