Commit 8a5eff91 authored by wanglei's avatar wanglei

...

parent 901b66d6
......@@ -10,7 +10,7 @@ android {
compileSdk 34
defaultConfig {
applicationId "com.base.datarecovery"
applicationId "com.test.basd.cleanmaster"
minSdk 24
targetSdk 34
versionCode 1
......
{
"project_info": {
"project_number": "347166098933",
"project_id": "comtestklplafilemanager",
"storage_bucket": "comtestklplafilemanager.appspot.com"
"project_number": "993178188325",
"project_id": "testcleanmaster",
"storage_bucket": "testcleanmaster.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:347166098933:android:37d25f227cd33ae60b8cbc",
"mobilesdk_app_id": "1:993178188325:android:a7986c2607f23024825dcc",
"android_client_info": {
"package_name": "com.base.datarecovery"
"package_name": "com.test.basd.cleanmaster"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDMBvW8CR7gxtL1n3V2Gx5vvoECmMvM6c8"
"current_key": "AIzaSyCY5uqNx8qS5ZPvSIknbh2nH2v5vjzCmPI"
}
],
"services": {
......
......@@ -3,7 +3,10 @@ package com.base.datarecovery.activity.recovery
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.os.Environment
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.R
import com.base.datarecovery.adapter.FileFolderAdapter
import com.base.datarecovery.ads.AdmobInterstitialUtils
import com.base.datarecovery.bean.ConstObject.SCAN_DOCUMENTS
......@@ -14,16 +17,25 @@ import com.base.datarecovery.bean.RecoveryBean
import com.base.datarecovery.bean.RecoveryBean.Companion.setType
import com.base.datarecovery.databinding.ActivityFileScanResultBinding
import com.base.datarecovery.help.BaseActivity
import com.base.datarecovery.help.FileHelp.loadFileByFilter
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.utils.FileHexEx
import com.base.datarecovery.utils.LogEx
import com.base.datarecovery.view.DialogViews.showExitFunctionDialog
import com.base.datarecovery.view.FileScanDialog
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch
import java.io.File
import java.util.HashMap
class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() {
private val TAG = "FileScanResultActivity"
private var scanOnce: Boolean = false
private var scanType = 0
override val binding: ActivityFileScanResultBinding by lazy {
ActivityFileScanResultBinding.inflate(layoutInflater)
......@@ -106,6 +118,60 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() {
binding.tvFolderNumber.text = list.size.toString()
fileFolderAdapter.setData(list)
}
private fun beginScan() {
if (scanOnce)
return
scanOnce = true
val mPathFlow = MutableSharedFlow<String>(
replay = 5,//当新的订阅者Collect时,发送几个已经发送过的数据给它
extraBufferCapacity = 5,//减去replay,MutableSharedFlow还缓存多少数据,缓冲池容量 = replay + extraBufferCapacity
onBufferOverflow = BufferOverflow.SUSPEND//缓存策略,三种 丢掉最新值、丢掉最旧值和挂起
)
val pathFlow: SharedFlow<String> = mPathFlow
val mFoundFlow = MutableSharedFlow<Int>(
replay = 5,//当新的订阅者Collect时,发送几个已经发送过的数据给它
extraBufferCapacity = 5,//减去replay,MutableSharedFlow还缓存多少数据,缓冲池容量 = replay + extraBufferCapacity
onBufferOverflow = BufferOverflow.SUSPEND//缓存策略,三种 丢掉最新值、丢掉最旧值和挂起
)
val foundFlow: SharedFlow<Int> = mFoundFlow
val dialogClass = FileScanDialog(this)
val scanDialog = dialogClass.showFileScanDialog(pathFlow, foundFlow)
val filter = when (scanType) {
SCAN_PHOTOS -> FileHexEx::isImage
SCAN_DOCUMENTS -> FileHexEx::isDocument
SCAN_VIDEOS -> FileHexEx::isVideo
else -> FileHexEx::isImage
}
var oneShowAd = false
val root = Environment.getExternalStorageDirectory()
val pathList = arrayListOf<String>()
lifecycleScope.loadFileByFilter(
mPathFlow,
mFoundFlow,
root, filter = filter,
onDo = { file ->
LogEx.logDebug(TAG, "file =${file.absolutePath}")
pathList.add(file.absolutePath)
if (!oneShowAd) {
oneShowAd = true
lifecycleScope.launch(Dispatchers.Main) {
dialogClass.scanShowUI()
AdmobInterstitialUtils.showInterstitialAd(this@FileScanResultActivity, true, false) { }
}
}
},
onFinish = {
scanDialog.dismiss()
dialogClass.stopScan(scanType, pathList)
}
)
}
}
\ No newline at end of file
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