forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor add loan account fragment to compose (openMF#2126)
- Loading branch information
1 parent
3f9f33d
commit fb969f6
Showing
26 changed files
with
1,237 additions
and
732 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
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
41 changes: 41 additions & 0 deletions
41
core/domain/src/main/java/com/mifos/core/domain/use_cases/CreateLoanAccountUseCase.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,41 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.LoansPayload | ||
import com.mifos.core.data.repository.LoanAccountRepository | ||
import com.mifos.core.objects.accounts.loan.Loans | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
class CreateLoanAccountUseCase @Inject constructor(private val loanAccountRepository: LoanAccountRepository) { | ||
|
||
suspend operator fun invoke(loansPayload: LoansPayload): Flow<Resource<Loans>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
loanAccountRepository.createLoansAccount(loansPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<Loans>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(exception: Throwable) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
override fun onNext(loans: Loans) { | ||
trySend(Resource.Success(loans)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
|
||
} catch (exception: Exception) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetAllLoanUseCase.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,38 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.LoanAccountRepository | ||
import com.mifos.core.objects.organisation.LoanProducts | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
class GetAllLoanUseCase @Inject constructor(private val loanAccountRepository: LoanAccountRepository) { | ||
|
||
suspend operator fun invoke(): Flow<Resource<List<LoanProducts>>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
loanAccountRepository.allLoans() | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<List<LoanProducts>>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(exception: Throwable) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
override fun onNext(products: List<LoanProducts>) { | ||
trySend(Resource.Success(products)) | ||
} | ||
}) | ||
awaitClose { channel.close() } | ||
} catch (exception: Exception) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetLoansAccountTemplateUseCase.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,41 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.LoanAccountRepository | ||
import com.mifos.core.objects.templates.loans.LoanTemplate | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
class GetLoansAccountTemplateUseCase @Inject constructor(private val loanAccountRepository: LoanAccountRepository) { | ||
|
||
suspend operator fun invoke(clientId: Int, productId: Int): Flow<Resource<LoanTemplate>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
loanAccountRepository.getLoansAccountTemplate(clientId, productId) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<LoanTemplate>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(exception: Throwable) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
override fun onNext(loanTemplate: LoanTemplate?) { | ||
trySend(Resource.Success(loanTemplate)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
|
||
} catch (exception: Exception) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
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 @@ | ||
/build |
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,23 @@ | ||
plugins { | ||
alias(libs.plugins.mifos.android.feature) | ||
alias(libs.plugins.mifos.android.library.compose) | ||
alias(libs.plugins.mifos.android.library.jacoco) | ||
} | ||
|
||
android { | ||
namespace = "com.mifos.feature.loan" | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(projects.core.domain) | ||
|
||
//DBFlow dependencies | ||
kapt(libs.dbflow.processor) | ||
implementation(libs.dbflow) | ||
kapt(libs.github.dbflow.processor) | ||
testImplementation(libs.hilt.android.testing) | ||
testImplementation(projects.core.testing) | ||
|
||
androidTestImplementation(projects.core.testing) | ||
} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Oops, something went wrong.