convert local file list adapter to Kotlin - #17394
Conversation
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
8dcd383 to
02df024
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates the legacy LocalFileListAdapter (and related fragment interface + tests) from Java into a new Kotlin implementation under com.owncloud.android.ui.adapter.localFileList, splitting binding/view-holder responsibilities into dedicated Kotlin classes.
Changes:
- Replaced the Java
LocalFileListAdapterwith a coroutine-based Kotlin adapter and extracted binders/view-holders into separate Kotlin files. - Converted
LocalFileListFragmentInterfacefrom Java to Kotlin and updated call sites/imports accordingly. - Moved and extended unit tests to cover stable IDs, filtering, and footer counting behavior.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/test/java/com/owncloud/android/ui/adapter/LocalFileListAdapterTest.kt | Removed old test in legacy package after adapter migration |
| app/src/test/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListAdapterTest.kt | Added/expanded tests for stable IDs, filtering, and footer counting |
| app/src/main/java/com/owncloud/android/ui/interfaces/LocalFileListFragmentInterface.kt | Kotlin replacement for the fragment↔adapter communication interface |
| app/src/main/java/com/owncloud/android/ui/interfaces/LocalFileListFragmentInterface.java | Removed legacy Java interface after Kotlin conversion |
| app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java | Updated adapter import to new Kotlin package |
| app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt | Updated adapter import to new Kotlin package |
| app/src/main/java/com/owncloud/android/ui/dialog/ConflictsResolveDialog.kt | Switched thumbnail binding for local files to the new thumbnail binder |
| app/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java | Removed legacy Java adapter after Kotlin migration |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileThumbnailBinder.kt | New thumbnail binding helper extracted from adapter logic |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListItemViewHolder.kt | New list-item view-holder in Kotlin |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListItemBinder.kt | New binder responsible for selection/thumbnail/details binding |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListGridItemViewHolder.kt | New grid-item view-holder in Kotlin (base holder) |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListFooterViewHolder.kt | New footer view-holder in Kotlin |
| app/src/main/java/com/owncloud/android/ui/adapter/localFileList/LocalFileListAdapter.kt | New Kotlin adapter implementation using coroutines for background loading |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| thumbnailView.setImageResource(R.drawable.file) | ||
|
|
||
| // Cancellation needs to be checked and done before changing the drawable in fileIcon, or | ||
| // ThumbnailsCacheManager#cancelPotentialThumbnailWork will NEVER cancel any task. | ||
| val allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView) |
| val placeholder = if (MimeTypeUtil.isVideo(file)) { | ||
| ThumbnailsCacheManager.mDefaultVideo | ||
| } else { | ||
| ThumbnailsCacheManager.mDefaultImg | ||
| } |
| @SuppressLint("NotifyDataSetChanged") | ||
| override fun filter(text: String) { | ||
| files = if (text.isEmpty()) allFiles else filterByName(allFiles, text).toMutableList() | ||
| notifyDataSetChanged() | ||
| } |
| fun swapDirectory(directory: File?) { | ||
| fragmentInterface.setLoading(true) | ||
| currentOffset = 0 | ||
|
|
||
| backgroundScope.launch { | ||
| showFirstPage(loadFirstPage(directory)) |
| @Suppress("LongParameterList", "TooManyFunctions") | ||
| class LocalFileListAdapter( | ||
| localFolderPickerMode: Boolean, | ||
| private val fragmentInterface: LocalFileListFragmentInterface, | ||
| private val preferences: AppPreferences, |
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ |
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ |
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ |
|
APK file: https://github.com/nextcloud/android/actions/runs/30464579402/artifacts/8729571267 |
|
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
master-IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/17394-IT-master-16-17 |
No description provided.