Commit d4677a01 authored by wanglei's avatar wanglei

...

parent 97c90b31
......@@ -122,7 +122,15 @@ class MyApplication : BaseApplication() {
if (flag && !isInterOpenShowing) {
if (AdmobMaxHelper.isOpenAdLoaded()) {
AdmobMaxHelper.admobMaxShowOpenAd(activity, {}, {})
var loaded: Boolean = true
AdmobMaxHelper.admobMaxShowOpenAd(activity, {
loaded = it
}, {
val sp = AppPreferences.getInstance().getString("splashShowInter", "0").toInt()
if (sp == 1 && !loaded) {
AdmobMaxHelper.admobMaxShowInterstitialAd(activity)
}
})
} else {
topActivity?.startActivity(
Intent(
......
......@@ -37,9 +37,11 @@ import com.base.filerecoveryrecyclebin.fcm.NotificationUtil
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.help.ConfigHelper
import com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
import com.base.filerecoveryrecyclebin.utils.AppPreferences
import com.base.filerecoveryrecyclebin.utils.BarUtils
import com.base.filerecoveryrecyclebin.utils.LogEx
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
......@@ -113,13 +115,21 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
if (it >= 100) {
job?.cancel()
jumpNext()
this.cancel()
}
}
}
}
var jumped: Boolean = false
private fun jumpNext() {
if (jumped) {
return
}
jumped = true
LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
when (actionId) {
ID_JUNK_CLEAN_PUSH -> {
startActivity(Intent(this, ScanJunkActivity::class.java))
......@@ -225,11 +235,22 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
private fun outTimeAd() {
LogEx.logDebug(TAG, "outTimeAd")
AdmobMaxHelper.admobMaxShowOpenAd(this, showBeforeAction = {
var loaded: Boolean = true
AdmobMaxHelper.admobMaxShowOpenAd(this, showBeforeAction = { flag ->
loaded = flag
job?.cancel()
}, onHidden = {
binding.pb.progress = 100
jumpNext()
val sp = AppPreferences.getInstance().getString("splashShowInter", "0").toInt()
if (sp == 1 && !loaded) {
AdmobMaxHelper.admobMaxShowInterstitialAd(this) {
binding.pb.progress = 100
jumpNext()
}
} else {
binding.pb.progress = 100
jumpNext()
}
})
}
......
package com.base.filerecoveryrecyclebin.activity.junkclean
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Color
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import androidx.activity.OnBackPressedCallback
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.filerecoveryrecyclebin.BuildConfig
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.activity.ResultActivity
import com.base.filerecoveryrecyclebin.adapter.JunkExpandAdapter
import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import com.base.filerecoveryrecyclebin.ads.admob.AdmobInterstitialUtils
import com.base.filerecoveryrecyclebin.bean.ChildBean
import com.base.filerecoveryrecyclebin.bean.ConstObject.JUNK_CLEANER
import com.base.filerecoveryrecyclebin.bean.ParentBean
import com.base.filerecoveryrecyclebin.databinding.ActivityLayoutCleanJunkBinding
import com.base.filerecoveryrecyclebin.databinding.ItemChildBinding
import com.base.filerecoveryrecyclebin.databinding.ItemParentBinding
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import com.base.filerecoveryrecyclebin.help.PermissionHelp.checkStorePermission
import com.base.filerecoveryrecyclebin.help.PermissionHelp.requestStorePermission
import com.base.filerecoveryrecyclebin.utils.BarUtils
import com.base.filerecoveryrecyclebin.utils.MediaStoreUtils
import com.base.filerecoveryrecyclebin.view.DialogViews.showExitFunctionDialog
import pokercc.android.expandablerecyclerview.ExpandableAdapter
import com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.random.Random
/**
......@@ -35,54 +34,47 @@ import kotlin.random.Random
*/
class CleanJunkActivity : BaseActivity<ActivityLayoutCleanJunkBinding>() {
private val parentList by lazy {
mutableListOf(
ParentBean(
title = "Useless installation package",
childItem = child3,
parentSize = sizes[0],
isParentSelected = true,
expanded = false
),
ParentBean(
title = "Temp File",
childItem = child4,
parentSize = sizes[1],
isParentSelected = true,
expanded = false
),
ParentBean(
title = "Log File",
childItem = child5,
parentSize = sizes[2],
isParentSelected = true,
expanded = false
)
)
}
private val child1 = ArrayList<ChildBean>()
private val child2 = ArrayList<ChildBean>()
private val child3 = ArrayList<ChildBean>()
private val child4 = ArrayList<ChildBean>()
private val child5 = ArrayList<ChildBean>()
private val sizes = MutableList(3) { 0L }
private var scanCount = 0
private val selectList = mutableListOf<String>()
private var selectSize = 0L
private val TAG = "CleanJunkActivity"
override val binding: ActivityLayoutCleanJunkBinding by lazy {
ActivityLayoutCleanJunkBinding.inflate(layoutInflater)
}
private lateinit var junkExpandAdapter: JunkExpandAdapter
@SuppressLint("SetTextI18n", "NotifyDataSetChanged")
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
junkExpandAdapter = JunkExpandAdapter { size ->
if (size == 0L) {
binding.tvBtn.text = "Got it"
binding.tvSize.text = "0"
binding.tvUnit.text = "B"
} else {
binding.tvBtn.text = "Clean up ${size.toFormatSize(1)}"
val split = size.toFormatSize().split(" ")
binding.tvSize.text = split[0]
binding.tvUnit.text = split[1]
}
}
binding.exRv.adapter = junkExpandAdapter
setAdapter()
if (checkStorePermission()) {
scanJunk()
} else {
showGerPermission(desc = "", deny = { finishToMain() }, allow = {
requestStorePermission(launcher) {
scanJunk()
}
})
}
}
override fun initListener() {
binding.idJunksBack.setOnClickListener {
binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
......@@ -99,368 +91,95 @@ class CleanJunkActivity : BaseActivity<ActivityLayoutCleanJunkBinding>() {
}
})
binding.idClBtn.setOnClickListener {
if (binding.idClBtn.text == "Got it") {
binding.tvBtn.setOnClickListener {
if (binding.tvBtn.text == "Got it") {
startActivity(Intent(this@CleanJunkActivity, ResultActivity::class.java).apply {
putExtra("clean_size", JUNK_CLEANER)
putExtra("from", 0)
})
} else {
startActivity(
Intent(this, CleaningActivity::class.java)
.putExtra("list", selectList.toTypedArray())
.putExtra("size", selectSize)
Intent(this, CleaningActivity::class.java).apply {
val list = junkExpandAdapter.getChoosePath()
putExtra("list", list.toTypedArray())
putExtra("size", list.sumOf { it.childSize })
}
)
scanJunk()
}
finish()
}
}
private fun setAdapter() {
binding.idExRl.adapter = mAdapter
binding.idExRl.layoutManager = LinearLayoutManager(this)
scanJunk()
}
private fun scanJunk() {
val apk = MediaStoreUtils.queryFiles(this, MediaStoreUtils.FileType.APK) ?: listOf()
apk.forEach { l ->
sizes[0] += l.size
val bean = ChildBean(R.mipmap.apk, l.name, l.path, l.size)
child3.add(bean)
}
// testApk()
scanCount += 1
updateSize(doneIndex = 0)
private fun scanJunk() = lifecycleScope.launch(Dispatchers.Main) {
var totalSize = 0L
val temp = MediaStoreUtils.queryFiles(this, MediaStoreUtils.FileType.TMP) ?: listOf()
temp.forEach { l ->
sizes[1] += l.size
val bean = ChildBean(null, l.name, l.path, l.size)
child4.add(bean)
}
// testTemp()
scanCount += 1
updateSize(doneIndex = 1)
val log = MediaStoreUtils.queryFiles(this, MediaStoreUtils.FileType.LOG) ?: listOf()
log.forEach { l ->
sizes[2] += l.size
val bean = ChildBean(null, l.name, l.path, l.size)
child5.add(bean)
}
// testLog()
scanCount += 2
updateSize(doneIndex = 2)
}
val list = arrayListOf<ChildBean>()
private fun testLog() {
if (BuildConfig.DEBUG) {
repeat(5) {
sizes[2] += Random.nextLong()
val bean = ChildBean(null, "log", "", Random.nextLong())
child5.add(bean)
async {
val apk = MediaStoreUtils.queryFiles(this@CleanJunkActivity, MediaStoreUtils.FileType.APK) ?: listOf()
apk.forEach { l ->
totalSize += l.size
list.add(ChildBean(R.mipmap.apk, l.name, l.path, l.size))
}
}
}
private fun testTemp() {
if (BuildConfig.DEBUG) {
repeat(5) {
sizes[1] += Random.nextLong()
val bean = ChildBean(null, "temp", "", Random.nextLong())
child4.add(bean)
}
}
}
private fun testApk() {
if (BuildConfig.DEBUG) {
repeat(5) {
sizes[0] += Random.nextLong(1500)
val bean = ChildBean(R.mipmap.apk, "apk", "", Random.nextLong())
child3.add(bean)
}
}
}
@SuppressLint("SetTextI18n")
private fun updateSize(doneIndex: Int = -1) {
addData(index = doneIndex)
val split = sizes.sum().toFormatSize(1).split(' ')
binding.idKeCl.text = split[0]
binding.idSizeUnit.text = split[1]
if (scanCount >= 3) {
selectList.clear()
selectSize = 0L
for (i in parentList.indices) {
if (parentList[i].childItem.isNotEmpty()) {
val childSize = parentList[i].childItem.filter {
it.isChildSelected
}.sumOf {
it.childSize
}
for (a in parentList[i].childItem) {
if (a.isChildSelected) {
if (a.pathList?.isNotEmpty() == true) {
for (o in a.pathList!!) {
selectList.add(o)
}
}
}
}
selectSize += childSize
} else {
if (parentList[i].isParentSelected) {
selectSize += parentList[i].parentSize
}
if (BuildConfig.DEBUG) {
repeat(5) {
val size = Random.nextLong(500)
totalSize += size
list.add(ChildBean(R.mipmap.apk, "1", "apl$it", size))
}
}
parentList.forEach { parent ->
selectList.addAll(parent.childItem.filter {
it.isChildSelected
}.map { it.chilepath })
}
}
binding.idClBtn.isVisible = scanCount >= 3
binding.idClBtn.isEnabled = sizes.sum() > 0
if (scanCount >= 3 && sizes.sum().toInt() == 0) {
binding.idClBtn.text = "Got it"
} else {
binding.idClBtn.text = "Clean up ${selectSize.toFormatSize(1)}"
}
binding.idClBtn.isEnabled = true
}
delay(Random.nextLong(1500, 2000))
}.await()
junkExpandAdapter.addChildData(0, list)
@SuppressLint("NotifyDataSetChanged")
private fun addData(index: Int) {
if (parentList.isNotEmpty()) {
parentList[index].isfinish = true
parentList[index].parentSize = sizes[index]
mAdapter.notifyDataSetChanged()
}
}
@SuppressLint("SetTextI18n")
private fun updateView() {
selectList.clear()
var allSize = 0L
for (i in parentList.indices) {
if (parentList[i].childItem.isNotEmpty()) {
val childSize = parentList[i].childItem.filter {
it.isChildSelected
}.sumOf {
it.childSize
}
for (a in parentList[i].childItem) {
if (a.isChildSelected) {
if (a.pathList?.isNotEmpty() == true) {
for (o in a.pathList!!) {
selectList.add(o)
}
}
}
}
allSize += childSize
} else {
if (parentList[i].isParentSelected) {
allSize += parentList[i].parentSize
}
list.clear()
async {
val temp = MediaStoreUtils.queryFiles(this@CleanJunkActivity, MediaStoreUtils.FileType.TMP) ?: listOf()
temp.forEach { l ->
totalSize += l.size
list.add(ChildBean(R.mipmap.temp_clean, l.name, l.path, l.size))
}
}
selectSize = allSize
binding.idClBtn.text = "Clean up ${allSize.toFormatSize()}"
binding.idClBtn.isEnabled = allSize > 0
parentList.forEach { parent ->
selectList.addAll(parent.childItem.filter {
it.isChildSelected
}.map { it.chilepath })
}
}
private val mAdapter by lazy {
class ParentViewHolder(val binding: ItemParentBinding) :
ExpandableAdapter.ViewHolder(binding.root)
class ChildViewHolder(val binding: ItemChildBinding) :
ExpandableAdapter.ViewHolder(binding.root)
object : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
var animators = mutableMapOf<Int, ValueAnimator>()
override fun getChildCount(groupPosition: Int): Int {
return parentList[groupPosition].childItem.size
}
override fun getGroupCount(): Int {
return parentList.size
}
override fun onViewDetachedFromWindow(holder: ViewHolder) {
super.onViewDetachedFromWindow(holder)
animators[holder.adapterPosition]?.pause()
}
override fun onViewAttachedToWindow(holder: ViewHolder) {
super.onViewAttachedToWindow(holder)
animators[holder.adapterPosition]?.resume()
}
override fun onCreateChildViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
val binding = ItemChildBinding.inflate(inflater, viewGroup, false)
return ChildViewHolder(binding)
}
override fun onCreateGroupViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
val binding = ItemParentBinding.inflate(inflater, viewGroup, false)
return ParentViewHolder(binding)
}
override fun onGroupViewHolderExpandChange(
holder: ViewHolder,
groupPosition: Int,
animDuration: Long,
expand: Boolean
) {
}
@SuppressLint("NotifyDataSetChanged")
override fun onBindGroupViewHolder(
holder: ViewHolder,
groupPosition: Int,
expand: Boolean,
payloads: List<Any>
) {
val viewHolder = holder as? ParentViewHolder ?: return
val parentType = parentList[groupPosition]
viewHolder.binding.idTypeName.text = parentType.title
parentType.expanded = expand
if (parentType.expanded) {
viewHolder.binding.idXiala.setImageResource(R.mipmap.zhankai)
} else {
viewHolder.binding.idXiala.setImageResource(R.mipmap.shouqi)
}
if (parentType.isfinish) {
viewHolder.binding.idImgLoad.isVisible = false
viewHolder.binding.idImgChoose.isVisible = true
} else {
val animator =
animators[groupPosition] ?: ValueAnimator.ofFloat(0f, 360f).apply {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
holder.binding.idImgLoad.rotation = it.animatedValue as Float
}
start()
animators[groupPosition] = this
}
viewHolder.binding.idImgLoad.isVisible = true
viewHolder.binding.idImgChoose.isVisible = false
}
viewHolder.binding.idTypeSize.text = parentType.parentSize.toFormatSize(1)
viewHolder.binding.idXiala.isVisible = parentType.childItem.isNotEmpty()
viewHolder.binding.idImgChoose.isSelected = parentType.isParentSelected
viewHolder.binding.idImgChoose.setOnClickListener {
viewHolder.binding.idImgChoose.isSelected =
!viewHolder.binding.idImgChoose.isSelected
parentType.isParentSelected = !parentType.isParentSelected
if (parentType.isParentSelected) {
for (app in parentType.childItem) {
app.isChildSelected = true
notifyDataSetChanged()
}
} else {
for (app in parentType.childItem) {
app.isChildSelected = false
notifyDataSetChanged()
}
}
updateView()
if (BuildConfig.DEBUG) {
repeat(5) {
val size = Random.nextLong(500)
totalSize += size
list.add(ChildBean(R.mipmap.temp_clean, "1", "temp$it", size))
}
}
@SuppressLint("NotifyDataSetChanged")
override fun onBindChildViewHolder(
holder: ViewHolder,
groupPosition: Int,
childPosition: Int,
payloads: List<Any>
) {
val viewHolder = holder as? ChildViewHolder ?: return
val childType = parentList[groupPosition].childItem[childPosition]
when (groupPosition) {
0 -> {
val packageManager: PackageManager = this@CleanJunkActivity.packageManager
val apkFilePath = childType.chilepath // 替换成您的APK文件路径
val packageInfo =
packageManager.getPackageArchiveInfo(
apkFilePath,
PackageManager.GET_ACTIVITIES
)
if (packageInfo != null) {
val applicationInfo = packageInfo.applicationInfo
val appIcon = packageManager.getApplicationIcon(applicationInfo)
viewHolder.binding.idImgIcon.setImageDrawable(appIcon)
} else {
viewHolder.binding.idImgIcon.setImageResource(R.mipmap.apk)
}
}
1 -> {
viewHolder.binding.idImgIcon.setImageResource(R.mipmap.qingchuicon)
}
2 -> {
viewHolder.binding.idImgIcon.setImageResource(R.mipmap.del)
}
3 -> {
}
4 -> {
}
}
viewHolder.binding.idTvAppName.text = childType.childname
viewHolder.binding.idImgSelect.isSelected = childType.isChildSelected
viewHolder.binding.idTvSize.text = childType.childSize.toFormatSize()
viewHolder.itemView.setOnClickListener {
when (childPosition) {
childPosition -> {
viewHolder.binding.idImgSelect.isSelected =
!viewHolder.binding.idImgSelect.isSelected
childType.isChildSelected = !childType.isChildSelected
if (!childType.isChildSelected) {
parentList[groupPosition].isParentSelected = false
notifyDataSetChanged()
}
updateView()
}
}
delay(Random.nextLong(1500, 2000))
}.await()
junkExpandAdapter.addChildData(1, list)
list.clear()
async {
val log = MediaStoreUtils.queryFiles(this@CleanJunkActivity, MediaStoreUtils.FileType.LOG) ?: listOf()
log.forEach { l ->
totalSize += l.size
list.add(ChildBean(R.mipmap.log_clean, l.name, l.path, l.size))
}
if (BuildConfig.DEBUG) {
repeat(5) {
val size = Random.nextLong(500)
totalSize += size
list.add(ChildBean(R.mipmap.log_clean, "1", "log$it", size))
}
}
delay(Random.nextLong(1500, 2000))
}.await()
junkExpandAdapter.addChildData(2, list)
}
binding.tvBtn.isVisible = true
binding.tvBtn.isEnabled = true
}
override fun onDestroy() {
super.onDestroy()
for (animator in mAdapter.animators.values) {
animator.cancel()
junkExpandAdapter.animators.values.forEach {
it.cancel()
}
}
}
\ No newline at end of file
package com.base.filerecoveryrecyclebin.adapter
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import androidx.core.view.isVisible
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.bean.ChildBean
import com.base.filerecoveryrecyclebin.bean.ParentBean
import com.base.filerecoveryrecyclebin.databinding.ItemChildBinding
import com.base.filerecoveryrecyclebin.databinding.ItemParentBinding
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import com.base.filerecoveryrecyclebin.utils.LogEx
import pokercc.android.expandablerecyclerview.ExpandableAdapter
class JunkExpandAdapter(private val chooseAction: (size: Long) -> Unit) : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
private val TAG = "JunkExpandAdapter"
private val parentBeanList by lazy {
mutableListOf(
ParentBean(
title = "Useless installation package",
isParentSelected = true,
expanded = false
),
ParentBean(
title = "Temp File",
isParentSelected = true,
expanded = false
),
ParentBean(
title = "Log File",
isParentSelected = true,
expanded = false
)
)
}
var animators = mutableMapOf<Int, ValueAnimator>()
inner class ChildViewHolder(val binding: ItemChildBinding) : ViewHolder(binding.root)
inner class ParentViewHolder(val binding: ItemParentBinding) : ViewHolder(binding.root)
override fun getChildCount(groupPosition: Int): Int {
return parentBeanList[groupPosition].childItem.size
}
override fun getGroupCount(): Int {
return parentBeanList.size
}
override fun onCreateChildViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
val binding = ItemChildBinding.inflate(inflater, viewGroup, false)
return ChildViewHolder(binding)
}
override fun onCreateGroupViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
val binding = ItemParentBinding.inflate(inflater, viewGroup, false)
return ParentViewHolder(binding)
}
@SuppressLint("NotifyDataSetChanged")
override fun onBindGroupViewHolder(holder: ViewHolder, groupPosition: Int, expand: Boolean, payloads: List<Any>) {
val viewHolder = holder as? ParentViewHolder ?: return
val parentBean = parentBeanList[groupPosition]
viewHolder.binding.idTypeName.text = parentBean.title
parentBean.expanded = expand
if (parentBean.expanded) {
viewHolder.binding.idXiala.setImageResource(R.mipmap.zhankai)
} else {
viewHolder.binding.idXiala.setImageResource(R.mipmap.shouqi)
}
viewHolder.binding.idTypeSize.text = parentBean.parentSize.toFormatSize(1)
viewHolder.binding.idXiala.isVisible = parentBean.childItem.isNotEmpty()
viewHolder.binding.idImgChoose.isSelected = parentBean.isParentSelected
bindParentAnimation(parentBean, groupPosition, viewHolder)
viewHolder.binding.idImgChoose.setOnClickListener {
viewHolder.binding.idImgChoose.isSelected = !viewHolder.binding.idImgChoose.isSelected
parentBean.isParentSelected = viewHolder.binding.idImgChoose.isSelected
parentBean.childItem.forEach {
it.isChildSelected = parentBean.isParentSelected
}
notifyDataSetChanged()
chooseSizeChange()
}
}
override fun onGroupViewHolderExpandChange(holder: ViewHolder, groupPosition: Int, animDuration: Long, expand: Boolean) {}
private fun chooseSizeChange() {
val selectSize = parentBeanList.sumOf { it.childItem.filter { it.isChildSelected }.sumOf { it.childSize } }
chooseAction.invoke(selectSize)
}
fun getChoosePath(): List<ChildBean> {
return parentBeanList.flatMap { it.childItem }.filter { it.isChildSelected }
}
private fun bindParentAnimation(parentBean: ParentBean, groupPosition: Int, viewHolder: ParentViewHolder) {
if (parentBean.isfinish) {
viewHolder.binding.idImgLoad.isVisible = false
viewHolder.binding.idImgChoose.isVisible = true
animators[groupPosition]?.cancel()
} else {
LogEx.logDebug(TAG, "play parent ValueAnimator")
animators[groupPosition] ?: ValueAnimator.ofFloat(0f, 360f).apply {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
viewHolder.binding.idImgLoad.rotation = it.animatedValue as Float
}
start()
animators[groupPosition] = this
}
viewHolder.binding.idImgLoad.isVisible = true
viewHolder.binding.idImgChoose.isVisible = false
}
}
@SuppressLint("NotifyDataSetChanged")
override fun onBindChildViewHolder(holder: ViewHolder, groupPosition: Int, childPosition: Int, payloads: List<Any>) {
val viewHolder = holder as? ChildViewHolder ?: return
val childBean = parentBeanList[groupPosition].childItem[childPosition]
val parentBean = parentBeanList[groupPosition]
val context = holder.itemView.context
viewHolder.binding.idTvAppName.text = childBean.childname
viewHolder.binding.idImgSelect.isSelected = childBean.isChildSelected
viewHolder.binding.idTvSize.text = childBean.childSize.toFormatSize()
when (groupPosition) {
0 -> {
try {
val apkFilePath = childBean.chilepath // 替换成您的APK文件路径
val packageInfo =
context.packageManager.getPackageArchiveInfo(apkFilePath, PackageManager.GET_ACTIVITIES)
if (packageInfo != null) {
val applicationInfo = packageInfo.applicationInfo
val appIcon: Drawable = context.packageManager.getApplicationIcon(applicationInfo)
viewHolder.binding.idImgIcon.setImageDrawable(appIcon)
} else {
holder.binding.idImgIcon.setImageResource(R.mipmap.apk)
}
} catch (e: Exception) {
holder.binding.idImgIcon.setImageResource(R.mipmap.apk)
}
}
1 -> {
holder.binding.idImgIcon.setImageResource(R.mipmap.temp_clean)
}
2 -> {
holder.binding.idImgIcon.setImageResource(R.mipmap.log_clean)
}
}
viewHolder.itemView.setOnClickListener {
viewHolder.binding.idImgSelect.isSelected = !viewHolder.binding.idImgSelect.isSelected
childBean.isChildSelected = viewHolder.binding.idImgSelect.isSelected
parentBean.isParentSelected = parentBean.childItem.all { it.isChildSelected }
notifyDataSetChanged()
chooseSizeChange()
}
}
@SuppressLint("NotifyDataSetChanged")
fun addChildData(position: Int, childBeanList: List<ChildBean>) {
val parentBean = parentBeanList[position]
parentBean.isfinish = true
parentBean.isParentSelected = true
parentBean.childItem.addAll(childBeanList)
parentBean.parentSize = childBeanList.sumOf { it.childSize }
LogEx.logDebug(TAG, "addChildData parentBean=$parentBean")
notifyDataSetChanged()
chooseSizeChange()
}
}
\ No newline at end of file
......@@ -80,7 +80,10 @@ object AdmobMaxHelper {
}
}
fun admobMaxShowOpenAd(activity: Activity, showBeforeAction: () -> Unit, onHidden: (() -> Unit)? = null) {
fun admobMaxShowOpenAd(
activity: Activity, showBeforeAction: (flag: Boolean) -> Unit,
onHidden: (() -> Unit)? = null,
) {
if (isBlack) {
onHidden?.invoke()
return
......
......@@ -64,7 +64,7 @@ object AdmobOpenUtils {
}
fun showAppOpenAd(activity: Activity, showBefore: (() -> Unit)? = null, onHidden: ((where: Int) -> Unit)? = null) {
fun showAppOpenAd(activity: Activity, showBefore: ((flag: Boolean) -> Unit)? = null, onHidden: ((where: Int) -> Unit)? = null) {
if (activity.isFinishing || activity.isDestroyed) {
return
......@@ -114,7 +114,7 @@ object AdmobOpenUtils {
}
override fun onAdShowedFullScreenContent() {
showBefore?.invoke()
showBefore?.invoke(true)
showAd(thisMOpenAd?.responseInfo, "openAd", activity)
}
}
......
......@@ -21,7 +21,7 @@ object AdMaxOpenUtils {
private var appOpenAd: MaxAppOpenAd? = null
private var openLoadTime = Long.MAX_VALUE
private var onHidden: (() -> Unit)? = null
private var loadingListener: (() -> Unit)? = null
private var loadingListener: ((flag: Boolean) -> Unit)? = null
private var activityString = ""
private fun setListener(activity: Activity) {
......@@ -33,7 +33,7 @@ object AdMaxOpenUtils {
override fun onAdLoaded(p0: MaxAd) {
LogEx.logDebug(TAG, "广告拉取成功")
openLoadTime = System.currentTimeMillis()
loadingListener?.invoke()
loadingListener?.invoke(true)
loadingListener = null
AdMaxEvent.pullAd(p0, "openAd")
}
......@@ -42,7 +42,7 @@ object AdMaxOpenUtils {
LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p0)
LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p1.message.toString())
LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p1.code)
loadingListener?.invoke()
loadingListener?.invoke(false)
loadingListener = null
AdDisplayUtils.getInstance().incrementAdRequestFailCount()
val reqId = UUID.randomUUID().toString()
......@@ -93,7 +93,7 @@ object AdMaxOpenUtils {
fun showAppOpenAd(
activity: Activity,
loadCallBack: (() -> Unit)? = null,
loadCallBack: ((loaded: Boolean) -> Unit)? = null,
onHidden: (() -> Unit)? = null
) {
......@@ -144,8 +144,8 @@ object AdMaxOpenUtils {
LogEx.logDebug(TAG, "展示时候,发现广告需要拉取")
val loaded = loadAppOpenAd(activity)
if (loaded) {
loadingListener = {
loadCallBack?.invoke()
loadingListener = { loadResult ->
loadCallBack?.invoke(loadResult)
LogEx.logDebug(TAG, "loadingListener callback")
if (appOpenAd?.isReady == true) {
AdMaxOpenUtils.onHidden = onHidden
......
......@@ -2,8 +2,8 @@ package com.base.filerecoveryrecyclebin.bean
data class ParentBean(
val title: String,
val childItem: List<ChildBean>,
var parentSize: Long,
val childItem: ArrayList<ChildBean> = arrayListOf(),
var parentSize: Long = 0,
var isParentSelected: Boolean,
var expanded: Boolean = true,
var isfinish: Boolean = false
......@@ -12,9 +12,9 @@ data class ParentBean(
data class ChildBean(
val image: Int? = null,
val childname: String,
val chilepath: String="",
val chilepath: String = "",
val childSize: Long = 0L,
var isChildSelected: Boolean = true,
var pathList: List<String>? = null,
var packageName:String?=""
var packageName: String? = ""
)
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#999A9C" android:state_enabled="false" />
<item android:color="@color/white" android:state_enabled="true" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:drawable="@drawable/bg_577dfd_22"/>
<item android:state_enabled="false" android:drawable="@drawable/bg_e6e7e9_22"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#e6e7e9" />
<corners android:radius="22dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
\ No newline at end of file
......@@ -15,29 +15,31 @@
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<View
android:layout_width="match_parent"
android:layout_height="40dp" />
<RelativeLayout
android:id="@+id/id_top_rl"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/id_junks_back"
<FrameLayout
android:id="@+id/fl_fanhui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="20dp"
android:src="@mipmap/fanhui" />
android:padding="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/fanhui"
tools:ignore="ContentDescription" />
</FrameLayout>
<TextView
android:id="@+id/id_tv_title_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center"
android:text="Clean Junk"
android:textColor="@color/white"
......@@ -45,48 +47,68 @@
android:textStyle="bold"
tools:ignore="HardcodedText" />
</RelativeLayout>
</FrameLayout>
<androidx.appcompat.widget.LinearLayoutCompat
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal">
android:layout_height="wrap_content">
<TextView
android:id="@+id/id_ke_cl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginEnd="7dp"
android:includeFontPadding="false"
android:textColor="@color/white"
android:textSize="43sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:id="@+id/id_size_unit"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="10dp"
android:includeFontPadding="false"
android:textColor="@color/white"
android:textSize="12sp"
tools:text="KB" />
</androidx.appcompat.widget.LinearLayoutCompat>
android:orientation="vertical"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal">
<TextView
android:id="@+id/tv_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginEnd="7dp"
android:includeFontPadding="false"
android:text="0"
android:textColor="@color/white"
android:textSize="45sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tv_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="8dp"
android:includeFontPadding="false"
android:text="KB"
android:textColor="@color/white"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="35dp"
android:text="Cleanable"
android:textColor="@color/white"
android:textSize="14sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="45dp"
android:text="Cleanable"
android:textColor="@color/white"
android:textSize="14sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<FrameLayout
......@@ -104,14 +126,14 @@
android:orientation="vertical">
<pokercc.android.expandablerecyclerview.ExpandableRecyclerView
android:id="@+id/id_ex_rl"
android:id="@+id/ex_rv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="visible" />
<TextView
android:id="@+id/id_cl_btn"
android:id="@+id/tv_btn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginHorizontal="40dp"
......
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