database: move databases to feature modules
Move all databases to their respective feature modules. This makes things a bit easier to work with.
This commit is contained in:
parent
c5b1293a90
commit
267578d606
9 changed files with 18 additions and 39 deletions
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Auxio Project
|
||||
* DatabaseUtils.kt is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.database
|
||||
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Shortcut for querying all items in a database and running [block] with the cursor returned.
|
||||
* Will not run if the cursor is null.
|
||||
*/
|
||||
fun <R> SQLiteDatabase.queryAll(tableName: String, block: (Cursor) -> R) =
|
||||
query(tableName, null, null, null, null, null, null)?.use(block)
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.database
|
||||
package org.oxycblt.auxio.music
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
|
@ -25,6 +25,7 @@ import android.database.sqlite.SQLiteOpenHelper
|
|||
import androidx.core.database.sqlite.transaction
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.ui.assertBackgroundThread
|
||||
import org.oxycblt.auxio.ui.queryAll
|
||||
|
||||
/**
|
||||
* Database for storing blacklisted paths.
|
|
@ -27,7 +27,6 @@ import android.provider.MediaStore.Audio.Genres
|
|||
import android.provider.MediaStore.Audio.Media
|
||||
import androidx.core.database.getStringOrNull
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.database.BlacklistDatabase
|
||||
import org.oxycblt.auxio.logD
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.database
|
||||
package org.oxycblt.auxio.playback.state
|
||||
|
||||
/**
|
||||
* A database entity that stores a compressed variant of the current playback state.
|
|
@ -16,13 +16,14 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.database
|
||||
package org.oxycblt.auxio.playback.state
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import androidx.core.database.sqlite.transaction
|
||||
import org.oxycblt.auxio.ui.queryAll
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.ui.assertBackgroundThread
|
||||
|
|
@ -21,9 +21,6 @@ package org.oxycblt.auxio.playback.state
|
|||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.oxycblt.auxio.database.PlaybackState
|
||||
import org.oxycblt.auxio.database.PlaybackStateDatabase
|
||||
import org.oxycblt.auxio.database.QueueItem
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.logE
|
||||
import org.oxycblt.auxio.music.Album
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.database
|
||||
package org.oxycblt.auxio.playback.state
|
||||
|
||||
/**
|
||||
* A database entity that stores a simplified representation of a song in a queue.
|
|
@ -27,7 +27,7 @@ import androidx.lifecycle.viewModelScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.oxycblt.auxio.database.BlacklistDatabase
|
||||
import org.oxycblt.auxio.music.BlacklistDatabase
|
||||
|
||||
/**
|
||||
* ViewModel that acts as a wrapper around [BlacklistDatabase], allowing for the addition/removal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Auxio Project
|
||||
* InterfaceUtils.kt is part of Auxio.
|
||||
* AndroidUtils.kt is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,6 +25,8 @@ import android.content.Intent
|
|||
import android.content.res.ColorStateList
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
|
@ -198,6 +200,14 @@ fun Context.newMainIntent(): PendingIntent {
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for querying all items in a database and running [block] with the cursor returned.
|
||||
* Will not run if the cursor is null.
|
||||
*/
|
||||
fun <R> SQLiteDatabase.queryAll(tableName: String, block: (Cursor) -> R) =
|
||||
query(tableName, null, null, null, null, null, null)?.use(block)
|
||||
|
||||
|
||||
/**
|
||||
* Assert that we are on a background thread.
|
||||
*/
|
Loading…
Reference in a new issue