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 checker inbox & task to jetpack compose with multi…
… module
- Loading branch information
1 parent
f60cc54
commit bf1bf8c
Showing
26 changed files
with
632 additions
and
62 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
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,89 @@ | ||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("kotlin-kapt") | ||
id("com.google.dagger.hilt.android") | ||
} | ||
|
||
android { | ||
namespace = "com.sparklead.feature.checker_inbox_task" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 26 | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.8" | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
|
||
implementation(project(":core:data")) | ||
implementation(project(":core:designsystem")) | ||
implementation(project(":core:common")) | ||
|
||
|
||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.11.0") | ||
implementation(project(":core:network")) | ||
implementation(project(":core:datastore")) | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
|
||
|
||
// swipe refresh | ||
implementation("com.google.accompanist:accompanist-swiperefresh:0.25.1") | ||
|
||
// coil | ||
implementation("io.coil-kt:coil-compose:2.5.0") | ||
|
||
|
||
// Hilt dependency | ||
implementation("com.google.dagger:hilt-android:2.50") | ||
kapt("com.google.dagger:hilt-android-compiler:2.50") | ||
|
||
//rxjava dependencies | ||
implementation("io.reactivex:rxandroid:1.1.0") | ||
implementation("io.reactivex:rxjava:1.3.8") | ||
|
||
// Jetpack Compose | ||
implementation("androidx.compose.material:material:1.6.0") | ||
implementation("androidx.compose.compiler:compiler:1.5.8") | ||
implementation("androidx.compose.ui:ui-tooling-preview:1.6.1") | ||
implementation("androidx.activity:activity-compose:1.8.2") | ||
debugImplementation("androidx.compose.ui:ui-tooling:1.6.1") | ||
implementation("androidx.compose.material3:material3:1.1.2") | ||
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0") | ||
implementation("androidx.compose.material:material-icons-extended:1.6.1") | ||
|
||
// ViewModel utilities for Compose | ||
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0") | ||
implementation("androidx.hilt:hilt-navigation-compose:1.1.0") | ||
} |
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 |
24 changes: 24 additions & 0 deletions
24
.../src/androidTest/java/com/sparklead/feature/checker_inbox_task/ExampleInstrumentedTest.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,24 @@ | ||
package com.sparklead.feature.checker_inbox_task | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.sparklead.feature.checker_inbox_task.test", appContext.packageName) | ||
} | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
29 changes: 29 additions & 0 deletions
29
.../feature/checker_inbox_task/checker_inbox_and_task/data/CheckerInboxTasksRepositoryImp.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,29 @@ | ||
package com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.data | ||
|
||
import com.mifos.core.network.datamanager.DataManagerCheckerInbox | ||
import com.mifos.core.objects.checkerinboxandtasks.CheckerTask | ||
import com.mifos.core.objects.checkerinboxandtasks.RescheduleLoansTask | ||
import com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.domain.repository.CheckerInboxTasksRepository | ||
import rx.Observable | ||
import javax.inject.Inject | ||
|
||
|
||
/** | ||
* Created by Aditya Gupta on 21/03/24. | ||
*/ | ||
|
||
class CheckerInboxTasksRepositoryImp @Inject constructor(private val dataManagerCheckerInbox: DataManagerCheckerInbox) : | ||
CheckerInboxTasksRepository { | ||
|
||
override fun getRescheduleLoansTaskList(): Observable<List<RescheduleLoansTask>> { | ||
return dataManagerCheckerInbox.getRechdeduleLoansTaskList() | ||
} | ||
|
||
override fun getCheckerTaskList( | ||
actionName: String?, | ||
entityName: String?, | ||
resourceId: Int? | ||
): Observable<List<CheckerTask>> { | ||
return dataManagerCheckerInbox.getCheckerTaskList() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...sparklead/feature/checker_inbox_task/checker_inbox_and_task/di/CheckerInboxTasksModule.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.sparklead.feature.checker_inbox_task.checker_inbox_and_task.di | ||
|
||
import com.mifos.core.network.datamanager.DataManagerCheckerInbox | ||
import com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.data.CheckerInboxTasksRepositoryImp | ||
import com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.domain.repository.CheckerInboxTasksRepository | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class CheckerInboxTasksModule { | ||
|
||
@Provides | ||
fun providesCheckerInboxTasksRepository(dataManagerCheckerInbox: DataManagerCheckerInbox): CheckerInboxTasksRepository = | ||
CheckerInboxTasksRepositoryImp(dataManagerCheckerInbox) | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...hecker_inbox_task/checker_inbox_and_task/domain/repository/CheckerInboxTasksRepository.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,21 @@ | ||
package com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.domain.repository | ||
|
||
import com.mifos.core.objects.checkerinboxandtasks.CheckerTask | ||
import com.mifos.core.objects.checkerinboxandtasks.RescheduleLoansTask | ||
import rx.Observable | ||
|
||
|
||
/** | ||
* Created by Aditya Gupta on 21/03/24. | ||
*/ | ||
|
||
interface CheckerInboxTasksRepository { | ||
|
||
fun getRescheduleLoansTaskList(): Observable<List<RescheduleLoansTask>> | ||
|
||
fun getCheckerTaskList( | ||
actionName: String? = null, entityName: String? = null, | ||
resourceId: Int? = null | ||
): Observable<List<CheckerTask>> | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
.../checker_inbox_task/checker_inbox_and_task/domain/usecase/GetCheckerInboxBadgesUseCase.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.sparklead.feature.checker_inbox_task.checker_inbox_and_task.domain.usecase | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.sparklead.feature.checker_inbox_task.checker_inbox_and_task.domain.repository.CheckerInboxTasksRepository | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Observable | ||
import rx.Scheduler | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Aditya Gupta on 21/03/24. | ||
*/ | ||
|
||
class GetCheckerInboxBadgesUseCase @Inject constructor(private val repository: CheckerInboxTasksRepository) { | ||
|
||
operator fun invoke(): Flow<Resource<Pair<Int,Int>>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
Observable.zip(repository.getCheckerTaskList(),repository.getRescheduleLoansTaskList()) { | ||
checkerTasks,rescheduleLoanTasks -> | ||
Pair(checkerTasks.size,rescheduleLoanTasks.size) | ||
}.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<Pair<Int,Int>>() { | ||
override fun onCompleted() { | ||
|
||
} | ||
|
||
override fun onError(error: Throwable) { | ||
trySend(Resource.Error(error.message.toString())) | ||
} | ||
|
||
override fun onNext(badges : Pair<Int, Int>) { | ||
trySend(Resource.Success(badges)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e : Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
Oops, something went wrong.