diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-11-15 12:05:53 +0530 |
---|---|---|
committer | Aditya Wasan <adityawasan55@gmail.com> | 2019-11-15 12:05:53 +0530 |
commit | de9a201587bfefc9fed8adba3db5a0a2e9557fde (patch) | |
tree | f78fbbc34f5a543d6d86452a749bbf33819bba89 /app/src | |
parent | 98927998244c3cce103f92f6e1a85050e8d0c5ba (diff) |
Also count subdirectories in child count (#573)
* Also count sub-directories in child count
* Respect hidden folders setting in child count
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt index f5b982bb..893ece62 100644 --- a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt +++ b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt @@ -4,11 +4,13 @@ */ package com.zeapo.pwdstore.ui.adapters +import android.content.SharedPreferences import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatTextView +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView import com.zeapo.pwdstore.R import com.zeapo.pwdstore.utils.PasswordItem @@ -19,6 +21,7 @@ import java.util.TreeSet abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<PasswordItem>) : RecyclerView.Adapter<EntryRecyclerAdapter.ViewHolder>() { internal val selectedItems: MutableSet<Int> = TreeSet() + internal var settings: SharedPreferences? = null // Return the size of your dataset (invoked by the layout manager) override fun getItemCount(): Int { @@ -76,13 +79,18 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P // Replace the contents of a view (invoked by the layout manager) override fun onBindViewHolder(holder: ViewHolder, position: Int) { + settings = settings ?: PreferenceManager.getDefaultSharedPreferences(holder.view.context.applicationContext) val pass = values[position] + val showHidden = settings?.getBoolean("show_hidden_folders", false) ?: false holder.name.text = pass.toString() if (pass.type == PasswordItem.TYPE_CATEGORY) { holder.type.visibility = View.GONE holder.typeImage.setImageResource(R.drawable.ic_multiple_files_24dp) holder.folderIndicator.visibility = View.VISIBLE - val childCount = (pass.file.list { current, name -> File(current, name).isFile } ?: emptyArray<File>()).size + val children = pass.file.listFiles { pathname -> + !(!showHidden && (pathname.isDirectory && pathname.isHidden)) + } ?: emptyArray<File>() + val childCount = children.size if (childCount > 0) { holder.childCount.visibility = View.VISIBLE holder.childCount.text = "$childCount" |