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 Create new center fragment to compose (openMF#2116)
* refactor: refactor Create new center fragment to compose * fix: fix build fail
- Loading branch information
1 parent
a679ee4
commit cb0304e
Showing
18 changed files
with
539 additions
and
376 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
6 changes: 1 addition & 5 deletions
6
...atenewcenter/CreateNewCenterRepository.kt → ...a/repository/CreateNewCenterRepository.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,16 +1,12 @@ | ||
package com.mifos.mifosxdroid.online.createnewcenter | ||
package com.mifos.core.data.repository | ||
|
||
import com.mifos.core.data.CenterPayload | ||
import com.mifos.core.objects.organisation.Office | ||
import com.mifos.core.objects.response.SaveResponse | ||
import rx.Observable | ||
|
||
/** | ||
* Created by Aditya Gupta on 10/08/23. | ||
*/ | ||
interface CreateNewCenterRepository { | ||
|
||
fun offices(): Observable<List<Office>> | ||
|
||
fun createCenter(centerPayload: CenterPayload): Observable<SaveResponse> | ||
} |
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
42 changes: 42 additions & 0 deletions
42
core/domain/src/main/java/com/mifos/core/domain/use_cases/CreateNewCenterUseCase.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,42 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.CenterPayload | ||
import com.mifos.core.data.repository.CreateNewCenterRepository | ||
import com.mifos.core.objects.response.SaveResponse | ||
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 CreateNewCenterUseCase @Inject constructor(private val repository: CreateNewCenterRepository) { | ||
|
||
suspend operator fun invoke(centerPayload: CenterPayload): Flow<Resource<SaveResponse>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
repository.createCenter(centerPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<SaveResponse>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(exception: Throwable) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
override fun onNext(saveResponse: SaveResponse) { | ||
trySend(Resource.Success(saveResponse)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
|
||
} catch (exception: Exception) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...se/GetIndividualCollectionSheetUseCase.kt → ...es/GetIndividualCollectionSheetUseCase.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
2 changes: 1 addition & 1 deletion
2
...t/domain/use_case/GetOfficeListUseCase.kt → .../domain/use_cases/GetOfficeListUseCase.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
2 changes: 1 addition & 1 deletion
2
...omain/use_case/GetStaffInOfficeUseCase.kt → ...main/use_cases/GetStaffInOfficeUseCase.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
Oops, something went wrong.