aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java19
2 files changed, 16 insertions, 7 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
index 45902fd8..678dee79 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -9,6 +9,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
@@ -268,7 +269,8 @@ public class CustomThemeListingActivity extends BaseActivity implements
new InsertCustomThemeAsyncTask.InsertCustomThemeAsyncTaskListener() {
@Override
public void success() {
- Snackbar.make(coordinatorLayout, R.string.import_theme_success, Snackbar.LENGTH_SHORT).show();
+ Toast.makeText(CustomThemeListingActivity.this, R.string.import_theme_success, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new RecreateActivityEvent());
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
index 0eba4b1d..f6443841 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
@@ -39,23 +39,30 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
+ if (checkDuplicate) {
+ if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
+ isDuplicate = true;
+ return null;
+ }
+ }
+ CustomTheme previousTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name);
if (customTheme.isLightTheme) {
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
+ } else if (previousTheme.isLightTheme) {
+ lightThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isDarkTheme) {
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
+ } else if (previousTheme.isDarkTheme) {
+ darkThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isAmoledTheme) {
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
- }
- if (checkDuplicate) {
- if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
- isDuplicate = true;
- return null;
- }
+ } else if (previousTheme.isAmoledTheme) {
+ amoledThemeSharedPreferences.edit().clear().apply();
}
redditDataRoomDatabase.customThemeDao().insert(customTheme);
return null;