Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 9244434

Browse files
authored
Correctly count children in password list (#1095)
1 parent 7a58e39 commit 9244434

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import com.zeapo.pwdstore.R
1717
import com.zeapo.pwdstore.SearchableRepositoryAdapter
1818
import com.zeapo.pwdstore.stableId
1919
import com.zeapo.pwdstore.utils.PasswordItem
20-
import com.zeapo.pwdstore.utils.PreferenceKeys
21-
import com.zeapo.pwdstore.utils.sharedPrefs
22-
import java.io.File
2320

2421
open class PasswordItemRecyclerAdapter :
2522
SearchableRepositoryAdapter<PasswordItemRecyclerAdapter.PasswordItemViewHolder>(
@@ -49,8 +46,6 @@ open class PasswordItemRecyclerAdapter :
4946
lateinit var itemDetails: ItemDetailsLookup.ItemDetails<String>
5047

5148
fun bind(item: PasswordItem) {
52-
val settings = itemView.context.sharedPrefs
53-
val showHidden = settings.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false)
5449
val parentPath = item.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
5550
val source = if (parentPath.isNotEmpty()) {
5651
"$parentPath\n$item"
@@ -62,10 +57,7 @@ open class PasswordItemRecyclerAdapter :
6257
name.text = spannable
6358
if (item.type == PasswordItem.TYPE_CATEGORY) {
6459
folderIndicator.visibility = View.VISIBLE
65-
val children = with(item.file) {
66-
if (showHidden) listFiles() else listFiles { pathname -> pathname.isDirectory && !pathname.isHidden }
67-
} ?: emptyArray<File>()
68-
val count = children.size
60+
val count = item.file.listFiles { path -> path.isDirectory || path.extension == "gpg" }?.size ?: 0
6961
childCount.visibility = if (count > 0) View.VISIBLE else View.GONE
7062
childCount.text = "$count"
7163
} else {

0 commit comments

Comments
 (0)