Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Migration_18_19.java « migration « persistence « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 576e2204a9f7103ce2e5a798239d526c8d6bbf74 (plain)
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
31
32
33
34
35
36
37
38
39
package it.niedermann.owncloud.notes.persistence.migration;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.bumptech.glide.Glide;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Migration_18_19 extends Migration {

    private static final String TAG = Migration_18_19.class.getSimpleName();
    private final ExecutorService executor = Executors.newSingleThreadExecutor();
    @NonNull
    private final Context context;


    public Migration_18_19(@NonNull Context context) {
        super(18, 19);
        this.context = context;
    }

    /**
     * Clears the {@link Glide} disk cache to fix wrong avatars in a multi user setup
     * https://github.com/stefan-niedermann/nextcloud-deck/issues/531
     */
    @Override
    public void migrate(@NonNull SupportSQLiteDatabase db) {
        executor.submit(() -> {
            Log.i(TAG, "Clearing Glide disk cache");
            Glide.get(context.getApplicationContext()).clearDiskCache();
        });
    }
}