replace queue store with room database
This commit is contained in:
parent
bb2793dbea
commit
44c1bb63b6
10 changed files with 150 additions and 324 deletions
|
|
@ -6,6 +6,9 @@ import android.content.Context;
|
|||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.room.Room;
|
||||
|
||||
import com.dkanada.gramophone.database.JellyDatabase;
|
||||
import com.dkanada.gramophone.helper.EventListener;
|
||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||
|
|
@ -22,6 +25,7 @@ import org.jellyfin.apiclient.logging.ILogger;
|
|||
public class App extends Application {
|
||||
private static App app;
|
||||
|
||||
private static JellyDatabase database;
|
||||
private static ApiClient apiClient;
|
||||
|
||||
@Override
|
||||
|
|
@ -29,6 +33,7 @@ public class App extends Application {
|
|||
super.onCreate();
|
||||
|
||||
app = this;
|
||||
database = createDatabase(this);
|
||||
apiClient = createApiClient(this);
|
||||
|
||||
// default theme
|
||||
|
|
@ -42,6 +47,12 @@ public class App extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
public static JellyDatabase createDatabase(Context context) {
|
||||
return Room.databaseBuilder(context, JellyDatabase.class, "database")
|
||||
.allowMainThreadQueries()
|
||||
.build();
|
||||
}
|
||||
|
||||
public static ApiClient createApiClient(Context context) {
|
||||
String appName = context.getString(R.string.app_name);
|
||||
String appVersion = BuildConfig.VERSION_NAME;
|
||||
|
|
@ -59,6 +70,10 @@ public class App extends Application {
|
|||
return new ApiClient(httpClient, logger, server, appName, appVersion, device, eventListener);
|
||||
}
|
||||
|
||||
public static JellyDatabase getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public static ApiClient getApiClient() {
|
||||
return apiClient;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue