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 = {
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.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,50 +47,70 @@
android:textStyle="bold"
tools:ignore="HardcodedText" />
</RelativeLayout>
</FrameLayout>
<androidx.appcompat.widget.LinearLayoutCompat
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
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/id_ke_cl"
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="43sp"
android:textSize="45sp"
android:textStyle="bold"
tools:text="0" />
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/id_size_unit"
android:id="@+id/tv_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="10dp"
android:layout_marginTop="8dp"
android:includeFontPadding="false"
android:text="KB"
android:textColor="@color/white"
android:textSize="12sp"
tools:text="KB" />
</androidx.appcompat.widget.LinearLayoutCompat>
tools:ignore="HardcodedText" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="45dp"
android:layout_marginBottom="35dp"
android:text="Cleanable"
android:textColor="@color/white"
android:textSize="14sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
......@@ -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