Commit 5ee4cfc5 authored by wanglei's avatar wanglei

...

parent ff4b1cd6
...@@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.collectLatest ...@@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.random.Random import kotlin.random.Random
import kotlin.random.nextLong
@SuppressLint("CustomSplashScreen") @SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity<ActivitySplashBinding>() { class SplashActivity : BaseActivity<ActivitySplashBinding>() {
...@@ -205,18 +206,22 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() { ...@@ -205,18 +206,22 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
val delayTime = Random.nextLong(300, 550) val delayTime = Random.nextLong(300, 550)
delay(delayTime) delay(delayTime)
processTime += delayTime processTime += delayTime
if (processTime >= 15000) { if (processTime >= Random.nextLong(4000, 6000)) {
job?.cancel() job?.cancel()
AdmobOpenUtils.showAppOpenAd(this@SplashActivity) { outTimeAd()
LogEx.logDebug(TAG, "where $it")
binding.pb.progress = 100
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
finish()
}
} }
} }
} }
private fun outTimeAd() {
AdmobOpenUtils.showAppOpenAd(this@SplashActivity) {
LogEx.logDebug(TAG, "where $it")
binding.pb.progress = 100
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
finish()
}
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (ifAgreePrivacy && job?.isActive == false) { if (ifAgreePrivacy && job?.isActive == false) {
......
...@@ -121,7 +121,7 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() { ...@@ -121,7 +121,7 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() {
val mPathFlow = MutableSharedFlow<String>( val mPathFlow = MutableSharedFlow<String>(
replay = 5,//当新的订阅者Collect时,发送几个已经发送过的数据给它 replay = 5,//当新的订阅者Collect时,发送几个已经发送过的数据给它
extraBufferCapacity = 5,//减去replay,MutableSharedFlow还缓存多少数据,缓冲池容量 = replay + extraBufferCapacity extraBufferCapacity = 5,//减去replay,MutableSharedFlow还缓存多少数据,缓冲池容量 = replay + extraBufferCapacity
onBufferOverflow = BufferOverflow.SUSPEND//缓存策略,三种 丢掉最新值、丢掉最旧值和挂起 onBufferOverflow = BufferOverflow.DROP_OLDEST//缓存策略,三种 丢掉最新值、丢掉最旧值和挂起
) )
val pathFlow: SharedFlow<String> = mPathFlow val pathFlow: SharedFlow<String> = mPathFlow
...@@ -133,14 +133,11 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() { ...@@ -133,14 +133,11 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() {
) )
val foundFlow: SharedFlow<Pair<Int, String>> = mFoundFlow val foundFlow: SharedFlow<Pair<Int, String>> = mFoundFlow
var pathShowed = false
val dialogClass = FileScanDialog(this) val dialogClass = FileScanDialog(this)
val scanDialog = dialogClass.showFileScanDialog(pathFlow, foundFlow) { val scanDialog = dialogClass.showFileScanDialog(pathFlow, foundFlow) {
if (!pathShowed) {
pathShowed = true
dialogClass.scanShowUI()
}
pathList.add(it) pathList.add(it)
binding.tvFileNumber.text = pathList.size.toString() binding.tvFileNumber.text = pathList.size.toString()
setAdapterData(it) setAdapterData(it)
...@@ -165,7 +162,7 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() { ...@@ -165,7 +162,7 @@ class FileScanResultActivity : BaseActivity<ActivityFileScanResultBinding>() {
binding.ivWancheng.visibility = View.VISIBLE binding.ivWancheng.visibility = View.VISIBLE
binding.tvScanning.text = "Completed" binding.tvScanning.text = "Completed"
AdmobInterstitialUtils.showInterstitialAd(this@FileScanResultActivity, isShowDialog = false) {} AdmobInterstitialUtils.showInterstitialAd(this@FileScanResultActivity, isShowDialog = false) {}
binding.ivEmpty.isVisible = pathList.isEmpty() binding.flEmpty.isVisible = pathList.isEmpty()
setAdapterData(null) setAdapterData(null)
dialogClass.finishScan { dialogClass.finishScan {
scanDialog.dismiss() scanDialog.dismiss()
......
...@@ -37,8 +37,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() { ...@@ -37,8 +37,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
override fun setListener() { override fun setListener() {
binding.flScan.setOnClickListener { binding.flScan.setOnClickListener {
// startActivity(Intent(requireContext(), ScanJunkActivity::class.java)) startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
sendNotification(requireContext(), ConstObject.ID_SCREENSHOT_CLEAN) // sendNotification(requireContext(), ConstObject.ID_SCREENSHOT_CLEAN)
} }
binding.flRyPhoto.setOnClickListener { binding.flRyPhoto.setOnClickListener {
startActivity(Intent(requireContext(), FileScanResultActivity::class.java).apply { startActivity(Intent(requireContext(), FileScanResultActivity::class.java).apply {
......
...@@ -13,6 +13,7 @@ import com.base.datarecovery.R ...@@ -13,6 +13,7 @@ import com.base.datarecovery.R
import com.base.datarecovery.activity.recovery.FileScanResultActivity import com.base.datarecovery.activity.recovery.FileScanResultActivity
import com.base.datarecovery.ads.AdmobNativeUtils import com.base.datarecovery.ads.AdmobNativeUtils
import com.base.datarecovery.databinding.DialogFileScanBinding import com.base.datarecovery.databinding.DialogFileScanBinding
import com.base.datarecovery.utils.LogEx
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
...@@ -59,8 +60,13 @@ class FileScanDialog( ...@@ -59,8 +60,13 @@ class FileScanDialog(
AdmobNativeUtils.showNativeAd(activity, binding.flAd, R.layout.layout_native_custom_big) AdmobNativeUtils.showNativeAd(activity, binding.flAd, R.layout.layout_native_custom_big)
var pathShowed = false
activity.lifecycleScope.launch(Dispatchers.Main) { activity.lifecycleScope.launch(Dispatchers.Main) {
pathFlow.collectLatest { path -> pathFlow.collectLatest { path ->
if (!pathShowed) {
pathShowed = true
binding.tvPath.visibility = View.VISIBLE
}
binding.tvPath.text = path binding.tvPath.text = path
} }
} }
...@@ -85,8 +91,4 @@ class FileScanDialog( ...@@ -85,8 +91,4 @@ class FileScanDialog(
clickAction.invoke() clickAction.invoke()
} }
} }
fun scanShowUI() {
binding.tvPath.visibility = View.VISIBLE
}
} }
\ No newline at end of file
...@@ -185,14 +185,34 @@ ...@@ -185,14 +185,34 @@
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_folder_recovery" /> tools:listitem="@layout/item_folder_recovery" />
<ImageView <LinearLayout
android:id="@+id/iv_empty" android:id="@+id/fl_empty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:src="@mipmap/queshengye" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:ignore="ContentDescription" /> tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/queshengye"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="File no found"
android:textColor="@color/black"
android:textSize="16sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
\ 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