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-04-18 17:08:07 +02:00
|
|
|
import com.cappielloantonio.play.database.dao.AlbumArtistCrossDao;
|
2020-11-20 15:38:08 +01:00
|
|
|
import com.cappielloantonio.play.database.dao.AlbumDao;
|
|
|
|
|
import com.cappielloantonio.play.database.dao.ArtistDao;
|
|
|
|
|
import com.cappielloantonio.play.database.dao.GenreDao;
|
|
|
|
|
import com.cappielloantonio.play.database.dao.PlaylistDao;
|
2021-04-18 19:06:07 +02:00
|
|
|
import com.cappielloantonio.play.database.dao.PlaylistSongCrossDao;
|
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-04-18 17:08:07 +02:00
|
|
|
import com.cappielloantonio.play.database.dao.SongArtistCrossDao;
|
2020-11-20 15:38:08 +01:00
|
|
|
import com.cappielloantonio.play.database.dao.SongDao;
|
2020-11-24 10:52:00 +01:00
|
|
|
import com.cappielloantonio.play.database.dao.SongGenreCrossDao;
|
2020-11-20 15:38:08 +01:00
|
|
|
import com.cappielloantonio.play.model.Album;
|
2021-04-18 17:08:07 +02:00
|
|
|
import com.cappielloantonio.play.model.AlbumArtistCross;
|
2020-11-20 15:38:08 +01:00
|
|
|
import com.cappielloantonio.play.model.Artist;
|
|
|
|
|
import com.cappielloantonio.play.model.Genre;
|
|
|
|
|
import com.cappielloantonio.play.model.Playlist;
|
2021-04-18 19:06:07 +02:00
|
|
|
import com.cappielloantonio.play.model.PlaylistSongCross;
|
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;
|
2020-11-20 15:38:08 +01:00
|
|
|
import com.cappielloantonio.play.model.Song;
|
2021-04-18 17:08:07 +02:00
|
|
|
import com.cappielloantonio.play.model.SongArtistCross;
|
2020-11-24 10:52:00 +01:00
|
|
|
import com.cappielloantonio.play.model.SongGenreCross;
|
2020-11-20 15:38:08 +01:00
|
|
|
|
2021-04-26 19:17:42 +02:00
|
|
|
@Database(entities = {Album.class, Artist.class, Genre.class, Playlist.class, Song.class, RecentSearch.class, SongGenreCross.class, Queue.class, AlbumArtistCross.class, SongArtistCross.class, PlaylistSongCross.class}, version = 12, exportSchema = false)
|
2020-11-20 15:38:08 +01:00
|
|
|
public abstract class AppDatabase extends RoomDatabase {
|
|
|
|
|
private static final String TAG = "AppDatabase";
|
|
|
|
|
|
|
|
|
|
private static AppDatabase instance;
|
|
|
|
|
private final static String DB_NAME = "play_db";
|
|
|
|
|
|
|
|
|
|
public static synchronized AppDatabase getInstance(Context context) {
|
|
|
|
|
|
2021-04-20 17:35:01 +02:00
|
|
|
if (instance == null && context != null) {
|
2020-11-20 15:38:08 +01:00
|
|
|
instance = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DB_NAME)
|
|
|
|
|
.fallbackToDestructiveMigration()
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract AlbumDao albumDao();
|
|
|
|
|
|
|
|
|
|
public abstract ArtistDao artistDao();
|
|
|
|
|
|
|
|
|
|
public abstract GenreDao genreDao();
|
|
|
|
|
|
|
|
|
|
public abstract PlaylistDao playlistDao();
|
|
|
|
|
|
|
|
|
|
public abstract SongDao songDao();
|
2020-11-21 13:54:49 +01:00
|
|
|
|
|
|
|
|
public abstract RecentSearchDao recentSearchDao();
|
2020-11-24 10:52:00 +01:00
|
|
|
|
|
|
|
|
public abstract SongGenreCrossDao songGenreCrossDao();
|
2020-12-05 21:31:12 +01:00
|
|
|
|
2021-04-18 17:08:07 +02:00
|
|
|
public abstract AlbumArtistCrossDao albumArtistCrossDao();
|
|
|
|
|
|
|
|
|
|
public abstract SongArtistCrossDao songArtistCrossDao();
|
|
|
|
|
|
2021-04-18 19:06:07 +02:00
|
|
|
public abstract PlaylistSongCrossDao playlistSongCrossDao();
|
|
|
|
|
|
2020-12-05 21:31:12 +01:00
|
|
|
public abstract QueueDao queueDao();
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|