-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dfa049
commit 2f8a6d6
Showing
19 changed files
with
234 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.binay.shaw.justap | ||
|
||
import android.app.Application | ||
import com.binay.shaw.justap.utils.Logger | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class JusTap: Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
Logger.debugLog("JusTap Application Created") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
app/src/main/java/com/binay/shaw/justap/data/local/db/AccountsDAO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
package com.binay.shaw.justap.data.local.db | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.* | ||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import androidx.room.Update | ||
import com.binay.shaw.justap.domain.model.Accounts | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
|
||
@Dao | ||
interface AccountsDAO { | ||
|
||
@Insert(onConflict = OnConflictStrategy.IGNORE) | ||
suspend fun insertAccount(accounts: Accounts) | ||
suspend fun insertAccount(accounts: Accounts): Long | ||
|
||
@Delete | ||
suspend fun deleteAccount(accounts: Accounts) | ||
suspend fun deleteAccount(accounts: Accounts): Int | ||
|
||
@Update | ||
suspend fun updateAccount(accounts: Accounts) | ||
suspend fun updateAccount(accounts: Accounts): Int | ||
|
||
@Query(value = "SELECT * FROM accountsDB") | ||
fun getAccountsList() : LiveData<List<Accounts>> | ||
fun getAccountsList(): Flow<List<Accounts>> | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/binay/shaw/justap/data/local/repository/AccountRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.binay.shaw.justap.data.local.repository | ||
|
||
import com.binay.shaw.justap.data.local.db.AccountsDAO | ||
import com.binay.shaw.justap.domain.model.Accounts | ||
import com.binay.shaw.justap.domain.repository.AccountRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class AccountRepositoryImpl @Inject constructor( | ||
private val accountsDao: AccountsDAO | ||
) : AccountRepository { | ||
|
||
override suspend fun getAccounts(): Flow<List<Accounts>> { | ||
return accountsDao.getAccountsList() | ||
} | ||
|
||
override suspend fun insertAccount(accounts: Accounts): Long { | ||
return accountsDao.insertAccount(accounts) | ||
} | ||
|
||
override suspend fun deleteAccount(accounts: Accounts): Int { | ||
return accountsDao.deleteAccount(accounts) | ||
} | ||
|
||
override suspend fun updateAccount(accounts: Accounts): Int { | ||
return accountsDao.updateAccount(accounts) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/binay/shaw/justap/di/modules/AppModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.binay.shaw.justap.di.modules | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object AppModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideAppContext(app: Application): Context { | ||
return app.applicationContext | ||
} | ||
|
||
// @Provides | ||
// @Singleton | ||
// fun provideSharedPreferences(app: Application): SharedPreferences { | ||
// return app.getSharedPreferences("Settings", Context.MODE_PRIVATE) | ||
// } | ||
} |
48 changes: 48 additions & 0 deletions
48
app/src/main/java/com/binay/shaw/justap/di/modules/DatabaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.binay.shaw.justap.di.modules | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import com.binay.shaw.justap.data.local.database.LocalUserDatabase | ||
import com.binay.shaw.justap.data.local.db.AccountsDAO | ||
import com.binay.shaw.justap.data.local.db.LocalHistoryDAO | ||
import com.binay.shaw.justap.data.local.db.LocalUserDAO | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DatabaseModule { | ||
|
||
// Provides the LocalUserDatabase instance | ||
@Provides | ||
@Singleton | ||
fun provideLocalUserDatabase(context: Context): LocalUserDatabase { | ||
return Room.databaseBuilder( | ||
context.applicationContext, | ||
LocalUserDatabase::class.java, | ||
"account_database" | ||
).fallbackToDestructiveMigration() | ||
.build() | ||
} | ||
|
||
// Provides LocalUserDAO from the database | ||
@Provides | ||
fun provideLocalUserDao(database: LocalUserDatabase): LocalUserDAO { | ||
return database.localUserDao() | ||
} | ||
|
||
// Provides AccountsDAO from the database | ||
@Provides | ||
fun provideAccountsDao(database: LocalUserDatabase): AccountsDAO { | ||
return database.accountsDao() | ||
} | ||
|
||
// Provides LocalHistoryDAO from the database | ||
@Provides | ||
fun provideLocalHistoryDao(database: LocalUserDatabase): LocalHistoryDAO { | ||
return database.localUserHistoryDao() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/binay/shaw/justap/di/modules/RepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.binay.shaw.justap.di.modules | ||
|
||
import com.binay.shaw.justap.data.local.db.AccountsDAO | ||
import com.binay.shaw.justap.data.local.repository.AccountRepositoryImpl | ||
import com.binay.shaw.justap.domain.repository.AccountRepository | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RepositoryModule { | ||
|
||
@Provides | ||
fun provideAccountRepository(accountsDAO: AccountsDAO): AccountRepository { | ||
return AccountRepositoryImpl(accountsDAO) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/binay/shaw/justap/domain/repository/AccountRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.binay.shaw.justap.domain.repository | ||
|
||
import com.binay.shaw.justap.domain.model.Accounts | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface AccountRepository { | ||
|
||
suspend fun getAccounts(): Flow<List<Accounts>> | ||
|
||
suspend fun insertAccount(accounts: Accounts): Long | ||
|
||
suspend fun deleteAccount(accounts: Accounts): Int | ||
|
||
suspend fun updateAccount(accounts: Accounts): Int | ||
} |
26 changes: 0 additions & 26 deletions
26
app/src/main/java/com/binay/shaw/justap/domain/repository/AccountsRepository.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.