aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllThemes.java
blob: 8fbc8cb0af0f5789b531d112e621628d41568bbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package ml.docilealligator.infinityforreddit.asynctasks;

import android.content.SharedPreferences;
import android.os.Handler;

import java.util.concurrent.Executor;

import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;

public class DeleteAllThemes {

    public static void deleteAllThemes(Executor executor, Handler handler,
                                       RedditDataRoomDatabase redditDataRoomDatabase,
                                       SharedPreferences lightThemeSharedPreferences,
                                       SharedPreferences darkThemeSharedPreferences,
                                       SharedPreferences amoledThemeSharedPreferences,
                                       DeleteAllThemesListener deleteAllThemesListener) {
        executor.execute(() -> {
            redditDataRoomDatabase.customThemeDao().deleteAllCustomThemes();
            lightThemeSharedPreferences.edit().clear().apply();
            darkThemeSharedPreferences.edit().clear().apply();
            amoledThemeSharedPreferences.edit().clear().apply();
            handler.post(deleteAllThemesListener::success);
        });
    }

    public interface DeleteAllThemesListener {
        void success();
    }
}