Skip to content

convert local file list adapter to Kotlin - #17394

Open
alperozturk96 wants to merge 2 commits into
masterfrom
local-file-list-adapter-kt
Open

convert local file list adapter to Kotlin#17394
alperozturk96 wants to merge 2 commits into
masterfrom
local-file-list-adapter-kt

Conversation

@alperozturk96

Copy link
Copy Markdown
Collaborator

No description provided.

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LocalFileListAdapter with a coroutine-based Kotlin adapter and extracted binders/view-holders into separate Kotlin files.
  • Converted LocalFileListFragmentInterface from 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.

Comment on lines +30 to +34
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)
Comment on lines +64 to +68
val placeholder = if (MimeTypeUtil.isVideo(file)) {
ThumbnailsCacheManager.mDefaultVideo
} else {
ThumbnailsCacheManager.mDefaultImg
}
Comment on lines +246 to +250
@SuppressLint("NotifyDataSetChanged")
override fun filter(text: String) {
files = if (text.isEmpty()) allFiles else filterByName(allFiles, text).toMutableList()
notifyDataSetChanged()
}
Comment on lines +169 to +174
fun swapDirectory(directory: File?) {
fragmentInterface.setLoading(true)
currentOffset = 0

backgroundScope.launch {
showFirstPage(loadFirstPage(directory))
Comment on lines +36 to +40
@Suppress("LongParameterList", "TooManyFunctions")
class LocalFileListAdapter(
localFolderPickerMode: Boolean,
private val fragmentInterface: LocalFileListFragmentInterface,
private val preferences: AppPreferences,
Comment on lines +1 to +6
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
Comment on lines +1 to +6
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
Comment on lines +1 to +6
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@github-actions

Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice3232
Correctness6460
Dodgy code206207
Experimental11
Malicious code vulnerability22
Multithreaded correctness2525
Performance4040
Security1919
Total389386

@github-actions

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/30464579402/artifacts/8729571267
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@github-actions

Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants