Commit d17b317a authored by wanglei's avatar wanglei

...

parent cf359084
......@@ -45,6 +45,7 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
)
val pathFlow: SharedFlow<String> = mPathFlow
@SuppressLint("SetTextI18n")
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
......@@ -54,7 +55,13 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
junkScanAdapter = JunkScanAdapter()
binding.rv.adapter = junkScanAdapter
junkExpandAdapter = JunkExpandAdapter()
junkExpandAdapter = JunkExpandAdapter { size ->
if (size > 0) {
binding.tvBtn.text = "Clean up ${size.toFormatSize()}"
} else {
binding.tvBtn.text = "Got it"
}
}
binding.rvEx.adapter = junkExpandAdapter
lifecycleScope.launch(Dispatchers.Main) {
......
......@@ -12,7 +12,7 @@ import com.base.browserwhite.utils.XmlEx.inflate
import pokercc.android.expandablerecyclerview.ExpandableAdapter
import java.io.File
class JunkExpandAdapter : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
class JunkExpandAdapter(private val selectAction: (size: Long) -> Unit) : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
private val beanList = arrayListOf<ParentBean>()
override fun getChildCount(groupPosition: Int): Int {
......@@ -50,6 +50,7 @@ class JunkExpandAdapter : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
parentBean.isSelect = allSelect
notifyGroupChange(groupPosition, "aa")
}
selectChange()
}
if (childBean.playAnimation) {
......@@ -93,6 +94,7 @@ class JunkExpandAdapter : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
bean.isSelect = !bean.isSelect
bean.childItem.forEach { it.isSelect = bean.isSelect }
notifyDataSetChanged()
selectChange()
}
if (bean.playAnimation) {
val slideInFromRight = AnimationUtils.loadAnimation(holder.itemView.context, R.anim.slide_in_from_right)
......@@ -116,4 +118,9 @@ class JunkExpandAdapter : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
notifyDataSetChanged()
}
private fun selectChange() {
val size = beanList.flatMap { it.childItem }.filter { it.isSelect }.sumOf { bean -> File(bean.path).length() }
selectAction.invoke(size)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment