Provide a better package structure for Room database related files.

This commit is contained in:
Severiano Jaramillo 2018-12-01 09:25:25 -06:00
parent dd770fdb5b
commit 5ec8afbdb3
28 changed files with 58 additions and 56 deletions

View file

@ -89,11 +89,11 @@ class DatabaseLoadActivity: ConnectedActivity() {
* @param assetList The list of assets obtained in the last 'list_assets' API call.
*/
private fun handlePlatformAssetBatch(assetList: List<Asset>) {
val assets = mutableListOf<cy.agorise.bitsybitshareswallet.entities.Asset>()
val assets = mutableListOf<cy.agorise.bitsybitshareswallet.database.entities.Asset>()
// TODO find if there is a better way to convert to Bitsy Asset instances
for (_asset in assetList) {
val asset = cy.agorise.bitsybitshareswallet.entities.Asset(
val asset = cy.agorise.bitsybitshareswallet.database.entities.Asset(
_asset.objectId,
_asset.symbol,
_asset.precision,

View file

@ -9,7 +9,7 @@ import android.widget.Toast
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.entities.Authority
import cy.agorise.bitsybitshareswallet.database.entities.Authority
import cy.agorise.bitsybitshareswallet.repositories.AuthorityRepository
import cy.agorise.bitsybitshareswallet.repositories.UserAccountRepository
import cy.agorise.bitsybitshareswallet.utils.Constants
@ -235,7 +235,7 @@ class ImportBrainkeyActivity : ConnectedActivity() {
val name = accountProperties.name
val isLTM = accountProperties.membership_expiration_date == Constants.LIFETIME_EXPIRATION_DATE
val userAccount = cy.agorise.bitsybitshareswallet.entities.UserAccount(id, name, isLTM)
val userAccount = cy.agorise.bitsybitshareswallet.database.entities.UserAccount(id, name, isLTM)
val userAccountRepository = UserAccountRepository(application)
userAccountRepository.insert(userAccount)

View file

@ -10,7 +10,7 @@ import android.widget.Toast
import androidx.collection.LongSparseArray
import com.google.android.material.bottomnavigation.BottomNavigationView
import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.database.entities.Balance
import cy.agorise.bitsybitshareswallet.fragments.BalancesFragment
import cy.agorise.bitsybitshareswallet.fragments.MerchantsFragment
import cy.agorise.bitsybitshareswallet.processors.TransfersLoader

View file

@ -8,7 +8,7 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SortedList
import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.database.entities.Balance
class BalancesAdapter(private val context: Context) :
RecyclerView.Adapter<BalancesAdapter.ViewHolder>() {

View file

@ -11,7 +11,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SortedList
import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
class TransactionsAdapter(private val context: Context) :
RecyclerView.Adapter<TransactionsAdapter.ViewHolder>() {

View file

@ -1,19 +1,21 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import cy.agorise.bitsybitshareswallet.entities.*
import cy.agorise.bitsybitshareswallet.database.daos.*
import cy.agorise.bitsybitshareswallet.database.entities.*
@Database(entities = [
Asset::class,
Authority::class,
Balance::class,
EquivalentValue::class,
Transfer::class,
UserAccount::class
], version = 1, exportSchema = false)
Asset::class,
Authority::class,
Balance::class,
EquivalentValue::class,
Transfer::class,
UserAccount::class
],
version = 1, exportSchema = false)
abstract class BitsyDatabase : RoomDatabase() {
abstract fun assetDao(): AssetDao

View file

@ -1,11 +1,11 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.Asset
import cy.agorise.bitsybitshareswallet.database.entities.Asset
@Dao
interface AssetDao {

View file

@ -1,10 +1,10 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.Authority
import cy.agorise.bitsybitshareswallet.database.entities.Authority
import io.reactivex.Single
@Dao

View file

@ -1,11 +1,11 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.database.entities.Balance
@Dao
interface BalanceDao {

View file

@ -1,10 +1,10 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.EquivalentValue
import cy.agorise.bitsybitshareswallet.database.entities.EquivalentValue
@Dao
interface EquivalentValueDao {

View file

@ -1,11 +1,11 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
import io.reactivex.Single
@Dao

View file

@ -1,10 +1,10 @@
package cy.agorise.bitsybitshareswallet.daos
package cy.agorise.bitsybitshareswallet.database.daos
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import cy.agorise.bitsybitshareswallet.entities.UserAccount
import cy.agorise.bitsybitshareswallet.database.entities.UserAccount
@Dao
interface UserAccountDao {

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -1,4 +1,4 @@
package cy.agorise.bitsybitshareswallet.entities
package cy.agorise.bitsybitshareswallet.database.entities
import androidx.room.ColumnInfo
import androidx.room.Entity

View file

@ -14,9 +14,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.adapters.BalancesAdapter
import cy.agorise.bitsybitshareswallet.adapters.TransactionsAdapter
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.entities.UserAccount
import cy.agorise.bitsybitshareswallet.database.entities.Balance
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.entities.UserAccount
import cy.agorise.bitsybitshareswallet.utils.Constants
import cy.agorise.bitsybitshareswallet.viewmodels.BalanceViewModel
import cy.agorise.bitsybitshareswallet.viewmodels.TransactionViewModel

View file

@ -10,7 +10,7 @@ import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
import cy.agorise.bitsybitshareswallet.models.HistoricalOperationEntry
import cy.agorise.bitsybitshareswallet.repositories.AuthorityRepository
import cy.agorise.bitsybitshareswallet.repositories.TransferRepository

View file

@ -2,9 +2,9 @@ package cy.agorise.bitsybitshareswallet.repositories
import android.app.Application
import android.os.AsyncTask
import cy.agorise.bitsybitshareswallet.daos.AssetDao
import cy.agorise.bitsybitshareswallet.daos.BitsyDatabase
import cy.agorise.bitsybitshareswallet.entities.Asset
import cy.agorise.bitsybitshareswallet.database.daos.AssetDao
import cy.agorise.bitsybitshareswallet.database.BitsyDatabase
import cy.agorise.bitsybitshareswallet.database.entities.Asset
class AssetRepository internal constructor(application: Application) {

View file

@ -2,9 +2,9 @@ package cy.agorise.bitsybitshareswallet.repositories
import android.content.Context
import android.os.AsyncTask
import cy.agorise.bitsybitshareswallet.daos.AuthorityDao
import cy.agorise.bitsybitshareswallet.daos.BitsyDatabase
import cy.agorise.bitsybitshareswallet.entities.Authority
import cy.agorise.bitsybitshareswallet.database.daos.AuthorityDao
import cy.agorise.bitsybitshareswallet.database.BitsyDatabase
import cy.agorise.bitsybitshareswallet.database.entities.Authority
import io.reactivex.Single
class AuthorityRepository internal constructor(context: Context) {

View file

@ -3,9 +3,9 @@ package cy.agorise.bitsybitshareswallet.repositories
import android.content.Context
import android.os.AsyncTask
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.daos.BalanceDao
import cy.agorise.bitsybitshareswallet.daos.BitsyDatabase
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.database.daos.BalanceDao
import cy.agorise.bitsybitshareswallet.database.BitsyDatabase
import cy.agorise.bitsybitshareswallet.database.entities.Balance
class BalanceRepository internal constructor(context: Context) {

View file

@ -3,9 +3,9 @@ package cy.agorise.bitsybitshareswallet.repositories
import android.content.Context
import android.os.AsyncTask
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.daos.BitsyDatabase
import cy.agorise.bitsybitshareswallet.daos.TransferDao
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.BitsyDatabase
import cy.agorise.bitsybitshareswallet.database.daos.TransferDao
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
import io.reactivex.Single
class TransferRepository internal constructor(context: Context) {

View file

@ -3,9 +3,9 @@ package cy.agorise.bitsybitshareswallet.repositories
import android.app.Application
import android.os.AsyncTask
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.daos.BitsyDatabase
import cy.agorise.bitsybitshareswallet.daos.UserAccountDao
import cy.agorise.bitsybitshareswallet.entities.UserAccount
import cy.agorise.bitsybitshareswallet.database.BitsyDatabase
import cy.agorise.bitsybitshareswallet.database.daos.UserAccountDao
import cy.agorise.bitsybitshareswallet.database.entities.UserAccount
class UserAccountRepository internal constructor(application: Application) {

View file

@ -3,7 +3,7 @@ package cy.agorise.bitsybitshareswallet.viewmodels
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.entities.Balance
import cy.agorise.bitsybitshareswallet.database.entities.Balance
import cy.agorise.bitsybitshareswallet.repositories.BalanceRepository

View file

@ -3,7 +3,7 @@ package cy.agorise.bitsybitshareswallet.viewmodels
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.entities.Transfer
import cy.agorise.bitsybitshareswallet.database.entities.Transfer
import cy.agorise.bitsybitshareswallet.repositories.TransferRepository
class TransactionViewModel(application: Application) : AndroidViewModel(application) {

View file

@ -3,7 +3,7 @@ package cy.agorise.bitsybitshareswallet.viewmodels
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import cy.agorise.bitsybitshareswallet.entities.UserAccount
import cy.agorise.bitsybitshareswallet.database.entities.UserAccount
import cy.agorise.bitsybitshareswallet.repositories.UserAccountRepository
class UserAccountViewModel(application: Application) : AndroidViewModel(application) {