Added logging

This commit is contained in:
M66B 2019-05-31 08:57:23 +02:00
parent 125f708286
commit fd8e202e59
1 changed files with 22 additions and 2 deletions

View File

@ -5,8 +5,10 @@ import android.content.SharedPreferences;
import android.database.Cursor;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.Database;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverter;
@ -21,6 +23,7 @@ import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -68,10 +71,10 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
@TypeConverters({DB.Converters.class})
public abstract class DB extends RoomDatabase {
public abstract DaoIdentity identity();
public abstract DaoAccount account();
public abstract DaoIdentity identity();
public abstract DaoFolder folder();
public abstract DaoMessage message();
@ -97,6 +100,23 @@ public abstract class DB extends RoomDatabase {
if (sInstance == null) {
Context context = ctx.getApplicationContext();
sInstance = migrate(context, getBuilder(context));
sInstance.getInvalidationTracker().addObserver(new InvalidationTracker.Observer(
EntityAccount.TABLE_NAME,
EntityIdentity.TABLE_NAME,
EntityFolder.TABLE_NAME,
EntityMessage.TABLE_NAME,
EntityAttachment.TABLE_NAME,
EntityOperation.TABLE_NAME,
EntityContact.TABLE_NAME,
EntityAnswer.TABLE_NAME,
EntityRule.TABLE_NAME,
EntityLog.TABLE_NAME) {
@Override
public void onInvalidated(@NonNull Set<String> tables) {
Log.i("ROOM invalidated=" + TextUtils.join(",", tables));
}
});
}
return sInstance;