Skip to content

Commit

Permalink
Merge pull request #2217 from gururani-abhishek/mvvm_architecture
Browse files Browse the repository at this point in the history
Mvvm architecture
  • Loading branch information
jawidMuhammadi authored Jul 27, 2023
2 parents 03da770 + c2e3ed4 commit ea2036e
Show file tree
Hide file tree
Showing 150 changed files with 3,737 additions and 770 deletions.
18 changes: 16 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.dagger.hilt.android'

apply from: '../config/quality/quality.gradle'

Expand Down Expand Up @@ -80,6 +81,10 @@ android {
buildFeatures {
viewBinding = true
}

kapt {
correctErrorTypes = true
}
}

dependencies {
Expand Down Expand Up @@ -154,14 +159,19 @@ dependencies {
//Biometric Authentication
implementation "androidx.biometric:biometric:$rootProject.biometric"

// Unit tests dependencies
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"

// Unit tests dependencies
testImplementation "junit:junit:$rootProject.jUnitVersion"
testImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"

implementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
implementation "org.mockito:mockito-android:$rootProject.mockitoVersion"
androidTestImplementation "junit:junit:$rootProject.jUnitVersion"
androidTestImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
androidTestImplementation "org.mockito:mockito-android:$rootProject.mockitoVersion"
androidTestImplementation "androidx.annotation:annotation:1.0.0"
implementation "androidx.arch.core:core-testing:$rootProject.archCoreVersion"
androidTestImplementation("androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion") {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
Expand All @@ -176,5 +186,9 @@ dependencies {
implementation 'com.github.rahul-gill.mifos-ui-library:uihouse:alpha-2.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

// Hilt
implementation("com.google.dagger:hilt-android:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")

}
apply plugin: 'com.google.gms.google-services'
20 changes: 2 additions & 18 deletions app/src/main/java/org/mifos/mobile/MifosSelfServiceApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.mifos.mobile.passcode.utils.ForegroundChecker
import com.raizlabs.android.dbflow.config.FlowConfig
import com.raizlabs.android.dbflow.config.FlowManager
import dagger.hilt.android.HiltAndroidApp
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.injection.component.ApplicationComponent
import org.mifos.mobile.injection.component.DaggerApplicationComponent
import org.mifos.mobile.injection.module.ApplicationModule
import org.mifos.mobile.ui.fragments.applySavedTheme
import org.mifos.mobile.utils.LanguageHelper.onAttach
import java.util.Locale
Expand All @@ -20,8 +18,8 @@ import java.util.Locale
* @author ishan
* @since 08/07/16
*/
@HiltAndroidApp
class MifosSelfServiceApp : MultiDexApplication() {
private var applicationComponent: ApplicationComponent? = null

companion object {
private var instance: MifosSelfServiceApp? = null
Expand Down Expand Up @@ -50,18 +48,4 @@ class MifosSelfServiceApp : MultiDexApplication() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(onAttach(base, Locale.getDefault().language))
}

fun component(): ApplicationComponent? {
if (applicationComponent == null) {
applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(ApplicationModule(this))
.build()
}
return applicationComponent
}

// Needed to replace the component with a test specific one
fun setComponent(applicationComponent: ApplicationComponent?) {
this.applicationComponent = applicationComponent
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import android.text.TextUtils
import dagger.hilt.android.qualifiers.ApplicationContext
import org.mifos.mobile.api.BaseURL
import org.mifos.mobile.api.SelfServiceInterceptor
import org.mifos.mobile.injection.ApplicationContext
import org.mifos.mobile.ui.fragments.AppTheme
import javax.inject.Inject
import javax.inject.Singleton
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/org/mifos/mobile/injection/ActivityContext.kt

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/java/org/mifos/mobile/injection/ApplicationContext.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
package org.mifos.mobile.injection.module

import android.app.Application
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import org.mifos.mobile.api.BaseApiManager
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.api.local.DatabaseHelper
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.injection.ApplicationContext
import javax.inject.Singleton

/**
* @author ishan
* @since 08/07/16
*/
@Module
class ApplicationModule(private val application: Application) {
@Provides
fun provideApplication(): Application {
return application
}

@Provides
@ApplicationContext
fun provideContext(): Context {
return application
}
@InstallIn(SingletonComponent::class)
class ApplicationModule() {

@Provides
@Singleton
Expand All @@ -37,4 +31,10 @@ class ApplicationModule(private val application: Application) {
fun provideBaseApiManager(preferencesHelper: PreferencesHelper?): BaseApiManager {
return BaseApiManager(preferencesHelper!!)
}

@Provides
@Singleton
fun providesDataManager(preferencesHelper: PreferencesHelper?, baseApiManager: BaseApiManager?, databaseHelper: DatabaseHelper): DataManager {
return DataManager(preferencesHelper!!, baseApiManager!!, databaseHelper!!)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.mifos.mobile.injection.module

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.mifos.mobile.repositories.NotificationRepositoryImp
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.repositories.LoanRepository
import org.mifos.mobile.repositories.LoanRepositoryImp
import org.mifos.mobile.repositories.NotificationRepository
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.repositories.ClientRepository
import org.mifos.mobile.repositories.ClientRepositoryImp
import org.mifos.mobile.repositories.RecentTransactionRepository
import org.mifos.mobile.repositories.RecentTransactionRepositoryImp
import org.mifos.mobile.repositories.UserAuthRepository
import org.mifos.mobile.repositories.UserAuthRepositoryImp

@Module
@InstallIn(SingletonComponent::class)
class RepositoryModule {

@Provides
fun providesUserAuthRepository(dataManager: DataManager): UserAuthRepository {
return UserAuthRepositoryImp(dataManager)
}

@Provides
fun providesLoanRepository(dataManager: DataManager): LoanRepository {
return LoanRepositoryImp(dataManager)
}

@Provides
fun providesNotificationRepository(dataManager: DataManager) : NotificationRepository {
return NotificationRepositoryImp(dataManager)
}

@Provides
fun providesClientRepository(
dataManager: DataManager, preferencesHelper: PreferencesHelper
): ClientRepository {
return ClientRepositoryImp(dataManager, preferencesHelper)
}

@Provides
fun providesRecentTransactionRepository(dataManager: DataManager): RecentTransactionRepository {
return RecentTransactionRepositoryImp(dataManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.reactivex.observers.DisposableObserver
import io.reactivex.schedulers.Schedulers
import org.mifos.mobile.R
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.injection.ApplicationContext
import dagger.hilt.android.qualifiers.ApplicationContext
import org.mifos.mobile.models.accounts.loan.LoanAccount
import org.mifos.mobile.models.accounts.savings.SavingAccount
import org.mifos.mobile.models.client.ClientAccounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import io.reactivex.observers.DisposableObserver
import io.reactivex.schedulers.Schedulers
import org.mifos.mobile.R
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.injection.ApplicationContext
import dagger.hilt.android.qualifiers.ApplicationContext
import org.mifos.mobile.models.CheckboxStatus
import org.mifos.mobile.models.accounts.loan.LoanAccount
import org.mifos.mobile.models.accounts.savings.SavingAccount
Expand Down
Loading

0 comments on commit ea2036e

Please sign in to comment.