2020-11-20 15:38:08 +01:00
|
|
|
package com.cappielloantonio.play.database;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
|
|
import androidx.room.Database;
|
|
|
|
|
import androidx.room.Room;
|
|
|
|
|
import androidx.room.RoomDatabase;
|
|
|
|
|
|
2021-07-29 17:12:55 +02:00
|
|
|
import com.cappielloantonio.play.database.dao.DownloadDao;
|
2020-12-05 21:31:12 +01:00
|
|
|
import com.cappielloantonio.play.database.dao.QueueDao;
|
2020-11-21 13:54:49 +01:00
|
|
|
import com.cappielloantonio.play.database.dao.RecentSearchDao;
|
2021-08-08 19:21:56 +02:00
|
|
|
import com.cappielloantonio.play.database.dao.ServerDao;
|
2021-07-29 17:12:55 +02:00
|
|
|
import com.cappielloantonio.play.model.Download;
|
2020-12-05 21:31:12 +01:00
|
|
|
import com.cappielloantonio.play.model.Queue;
|
2020-11-21 13:54:49 +01:00
|
|
|
import com.cappielloantonio.play.model.RecentSearch;
|
2021-08-08 19:21:56 +02:00
|
|
|
import com.cappielloantonio.play.model.Server;
|
2020-11-20 15:38:08 +01:00
|
|
|
|
2021-09-02 14:18:10 +02:00
|
|
|
@Database(entities = {Queue.class, Server.class, RecentSearch.class, Download.class}, version = 17, exportSchema = false)
|
2020-11-20 15:38:08 +01:00
|
|
|
public abstract class AppDatabase extends RoomDatabase {
|
|
|
|
|
private static final String TAG = "AppDatabase";
|
2021-07-28 15:28:32 +02:00
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
private final static String DB_NAME = "play_db";
|
2021-04-27 11:01:02 +02:00
|
|
|
private static AppDatabase instance;
|
2020-11-20 15:38:08 +01:00
|
|
|
|
|
|
|
|
public static synchronized AppDatabase getInstance(Context context) {
|
2021-04-20 17:35:01 +02:00
|
|
|
if (instance == null && context != null) {
|
2021-05-02 12:20:43 +02:00
|
|
|
instance = Room.databaseBuilder(context, AppDatabase.class, DB_NAME)
|
2020-11-20 15:38:08 +01:00
|
|
|
.fallbackToDestructiveMigration()
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 15:28:32 +02:00
|
|
|
public abstract QueueDao queueDao();
|
2020-11-21 13:54:49 +01:00
|
|
|
|
2021-08-08 19:21:56 +02:00
|
|
|
public abstract ServerDao serverDao();
|
|
|
|
|
|
2020-11-21 13:54:49 +01:00
|
|
|
public abstract RecentSearchDao recentSearchDao();
|
2021-07-29 17:12:55 +02:00
|
|
|
|
|
|
|
|
public abstract DownloadDao downloadDao();
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|