mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-01 06:45:19 +00:00
Correctly count children in password list (#1095)
This commit is contained in:
@@ -17,9 +17,6 @@ import com.zeapo.pwdstore.R
|
|||||||
import com.zeapo.pwdstore.SearchableRepositoryAdapter
|
import com.zeapo.pwdstore.SearchableRepositoryAdapter
|
||||||
import com.zeapo.pwdstore.stableId
|
import com.zeapo.pwdstore.stableId
|
||||||
import com.zeapo.pwdstore.utils.PasswordItem
|
import com.zeapo.pwdstore.utils.PasswordItem
|
||||||
import com.zeapo.pwdstore.utils.PreferenceKeys
|
|
||||||
import com.zeapo.pwdstore.utils.sharedPrefs
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
open class PasswordItemRecyclerAdapter :
|
open class PasswordItemRecyclerAdapter :
|
||||||
SearchableRepositoryAdapter<PasswordItemRecyclerAdapter.PasswordItemViewHolder>(
|
SearchableRepositoryAdapter<PasswordItemRecyclerAdapter.PasswordItemViewHolder>(
|
||||||
@@ -49,8 +46,6 @@ open class PasswordItemRecyclerAdapter :
|
|||||||
lateinit var itemDetails: ItemDetailsLookup.ItemDetails<String>
|
lateinit var itemDetails: ItemDetailsLookup.ItemDetails<String>
|
||||||
|
|
||||||
fun bind(item: PasswordItem) {
|
fun bind(item: PasswordItem) {
|
||||||
val settings = itemView.context.sharedPrefs
|
|
||||||
val showHidden = settings.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false)
|
|
||||||
val parentPath = item.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
|
val parentPath = item.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
|
||||||
val source = if (parentPath.isNotEmpty()) {
|
val source = if (parentPath.isNotEmpty()) {
|
||||||
"$parentPath\n$item"
|
"$parentPath\n$item"
|
||||||
@@ -62,10 +57,7 @@ open class PasswordItemRecyclerAdapter :
|
|||||||
name.text = spannable
|
name.text = spannable
|
||||||
if (item.type == PasswordItem.TYPE_CATEGORY) {
|
if (item.type == PasswordItem.TYPE_CATEGORY) {
|
||||||
folderIndicator.visibility = View.VISIBLE
|
folderIndicator.visibility = View.VISIBLE
|
||||||
val children = with(item.file) {
|
val count = item.file.listFiles { path -> path.isDirectory || path.extension == "gpg" }?.size ?: 0
|
||||||
if (showHidden) listFiles() else listFiles { pathname -> pathname.isDirectory && !pathname.isHidden }
|
|
||||||
} ?: emptyArray<File>()
|
|
||||||
val count = children.size
|
|
||||||
childCount.visibility = if (count > 0) View.VISIBLE else View.GONE
|
childCount.visibility = if (count > 0) View.VISIBLE else View.GONE
|
||||||
childCount.text = "$count"
|
childCount.text = "$count"
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user