This file contains hidden or 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 is for no filter, just basic paging | |
val maritalStatusVal: StateFlow<CreateScreenUiState> = flow { | |
val maritalStatusData = kmbMasterDataUseCase.getMaritalStatus( | |
body = KmbMasterDataRequestModel.KmbMasterDataRequest() | |
).cachedIn(viewModelScope) | |
emit(CreateScreenUiState(maritalStatus = maritalStatusData)) | |
}.stateIn( | |
viewModelScope, | |
SharingStarted.WhileSubscribed(5_000), | |
CreateScreenUiState.default |
This file contains hidden or 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
// BaseResponseDto | |
data class KreditPlusBaseResponseDto<DATA>( | |
@SerializedName("code") | |
val code: Int? = 0, | |
@SerializedName("data") | |
val data: DATA?, | |
@SerializedName("errors") | |
val errors: HashMap<String, String>? = hashMapOf(), | |
@SerializedName("status") |
This file contains hidden or 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
// Dto Class | |
sealed interface MockDraftDetailResponseDto { | |
data class MockDraftDetail( | |
@SerializedName("code") | |
val code: Int, | |
@SerializedName("data") | |
val data: Data, | |
@SerializedName("errors") | |
val errors: Errors? = null, |
This file contains hidden or 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
1. collectLatest() dont stop collecting data when onPause() lifecycle, but collect() did stop |
This file contains hidden or 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
//RESOURCE CLASS | |
package com.kreditplus.sally.core.utils.network | |
import com.google.gson.Gson | |
import com.google.gson.JsonParser | |
import com.google.gson.annotations.SerializedName | |
import com.kreditplus.sally.core.base.dto.KreditPlusBaseResponseDto | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.catch | |
import kotlinx.coroutines.flow.map |
This file contains hidden or 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
private val filterAgentState = MutableStateFlow(FilterAgentState.default) | |
@OptIn(ExperimentalCoroutinesApi::class) | |
val getListAgent: StateFlow<ListAgentVisit> = filterAgentState.flatMapLatest { filterState -> | |
flow { | |
val agentList = useCase.getListAgentVisitWithFullResponse( | |
body = GetAgentVisitRequest( | |
branchCode = useCase.getAccountInfo().branchCode, | |
moId = useCase.getAccountInfo().employeeId, |
This file contains hidden or 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
val getListAgent: StateFlow<ListAgentVisit> = flow { | |
val agentList = useCase.getListAgentVisitWithFullResponse( | |
body = GetAgentVisitRequest( | |
branchCode = useCase.getAccountInfo().branchCode, | |
moId = useCase.getAccountInfo().employeeId, | |
skip = 1, | |
search = "", | |
prospectConsument = "", | |
agentProfessionCode = "", | |
startDate = "", |
This file contains hidden or 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
override fun onViewCreated() { | |
observeVisitDetail() | |
} | |
private fun observeVisitDetail() { | |
viewLifecycleOwner.lifecycleScope.launch { | |
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { | |
viewModel.agentDetail?.collect { visitingUiState -> | |
when (visitingUiState) { | |
is VisitingDetailUiState.Success -> { |
This file contains hidden or 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
val visitId = savedStateHandle.get<Int>("visitId") | |
val agentDetail: StateFlow<VisitingDetailUiState>? = | |
visitId?.let { | |
useCase.getDetailAgentVisitFullResponseFlow(id = it).map { visitDetail -> | |
Log.d("MYTAG", ": got exec") | |
when (visitDetail) { | |
is SallyResponseResource.Loading -> { | |
VisitingDetailUiState.Loading | |
} |
This file contains hidden or 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
override fun onViewCreated() { | |
viewModel.getAgentVisitDetailFullResponseFlow() | |
observeVisitDetail() | |
} |
NewerOlder