Commit a22d829e authored by Your Name's avatar Your Name

迭代

parent 0dd4ebcd
......@@ -50,9 +50,8 @@ public class MainActivity extends AppCompatActivity {
ActivityMainBinding binding;
private ActivityResultLauncher<String[]> multiplePermissionsLauncher;
private ActivityResultLauncher<Intent> notificationSettingsLauncher;
private static final String PREFS_NAME = "AppPrefs";
private static final String KEY_CLEANED = "cleaned";
private FullscreenDialog fullscreenDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -62,14 +61,14 @@ public class MainActivity extends AppCompatActivity {
initBar();
if (!isCleaned()) {
// fullscreenDialog = new FullscreenDialog(this);
// fullscreenDialog.setOnDialogDismissListener(new FullscreenDialog.OnDialogDismissListener() {
// @Override
// public void onSuccButton() {
// startActivity(new Intent(MainActivity.this,CleanJunkActivity.class));
// }
// });
// fullscreenDialog.show();
fullscreenDialog = new FullscreenDialog(this);
fullscreenDialog.setOnDialogDismissListener(new FullscreenDialog.OnDialogDismissListener() {
@Override
public void onSuccButton() {
startActivity(new Intent(MainActivity.this, CleanJunkActivity.class));
}
});
fullscreenDialog.show();
}
initPermission();
......@@ -90,22 +89,10 @@ public class MainActivity extends AppCompatActivity {
}
private boolean isCleaned() {
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
return prefs.getBoolean(KEY_CLEANED, false);
}
private void setCleaned(boolean cleaned) {
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(KEY_CLEANED, cleaned);
editor.apply();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK) {
setCleaned(true);
}
SharedPreferences prefs = getSharedPreferences("AppPrefs", MODE_PRIVATE);
return prefs.getBoolean("cleaned", false);
}
private void initShow() {
binding.lottieAnimattionView.setAnimation(R.raw.cleaner_junk_found_animation);
binding.lottieAnimattionView.playAnimation();
......@@ -243,17 +230,17 @@ public class MainActivity extends AppCompatActivity {
});
appExitDialog.show();
}
private AtomicBoolean bannerShowed = new AtomicBoolean(false);
@Override
protected void onResume() {
super.onResume();
Log.d("isCleaned", isCleaned() + "111");
if (isCleaned()) {
if (isCleaned() && fullscreenDialog != null) {
Log.d("isCleaned", isCleaned() + "222");
fullscreenDialog.dismiss();
fullscreenDialog = null; // 释放引用
}
if (bannerShowed.get()) return;
bannerShowed.set(true);
AdmobManager.INSTANCE.showBannerAd(this, binding.flBanner, "bottom", null, null);
......@@ -289,7 +276,6 @@ public class MainActivity extends AppCompatActivity {
binding.lottieAnimattionView.setImageDrawable(null); // 清除图像
binding.lottieAnimattionView.destroyDrawingCache(); // 销毁缓存
}
if (binding.radarview != null) {
binding.radarview.setSearching(false);
}
......
......@@ -18,6 +18,7 @@ import android.os.Build;
import android.os.CountDownTimer;
import android.os.Environment;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.content.Intent;
import android.widget.Toast;
......@@ -212,11 +213,17 @@ public class CleanJunkActivity extends BaseActivity<ActivityCleanJunkBinding> {
binding.emptyFilesRecy.setVisibility(View.VISIBLE);
}
});
SharedPreferences prefs = getSharedPreferences("AppPrefs", MODE_PRIVATE);
binding.buttonCleanUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view != null) {
setResult(RESULT_OK);
boolean cleaned = prefs.getBoolean("cleaned", false);
if (!cleaned){
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("cleaned", true);
editor.commit();
}
onClickCleanUpButton(view);
}
}
......@@ -235,11 +242,6 @@ public class CleanJunkActivity extends BaseActivity<ActivityCleanJunkBinding> {
}
sharedPreferences = getSharedPreferences("AppPrefs", MODE_PRIVATE);
}
private void markAsCleaned() {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("isCleaned", true);
editor.apply(); // 使用 apply() 方法异步保存数据
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
......@@ -701,6 +703,7 @@ public class CleanJunkActivity extends BaseActivity<ActivityCleanJunkBinding> {
if (binding != null) {
binding = null;
}
}
}
\ No newline at end of file
......@@ -68,33 +68,23 @@ public class FullscreenDialog {
lottieView = dialog.findViewById(R.id.lottie_animattion_view1);
lottieView.setAnimation(R.raw.cleaner_junk_found_animation); // 替换为你的动画文件名
lottieView.playAnimation(); // 开始播放动画
// 监听动画结束事件
lottieView.addAnimatorListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
lottieView.cancelAnimation();
lottieView.clearAnimation();
lottieView.setAnimation((String) null);
}
});
dialog.setOnDismissListener(dialog -> {
if (lottieView != null) {
lottieView.cancelAnimation();
lottieView.clearAnimation();
lottieView.setAnimation((String) null);
lottieView = null;
}
});
// 显示Dialog
dialog.show();
}
public void dismiss() {
if (dialog != null && dialog.isShowing() ){
if (dialog != null && dialog.isShowing()) {
dialog.setOnDismissListener(null); // 移除监听器,避免重复调用
dialog.setOnCancelListener(null); // 移除取消监听器
dialog.dismiss();
if (lottieView != null) {
lottieView.cancelAnimation(); // 停止动画
lottieView.clearAnimation(); // 清除动画
lottieView.setImageDrawable(null); // 清除图像
lottieView.destroyDrawingCache(); // 销毁缓存
}
}
}
......
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