Skip to content

Instantly share code, notes, and snippets.

@jafar260698
Last active November 5, 2020 07:20
Show Gist options
  • Save jafar260698/55cb5aa8879947b34580efdbee63416f to your computer and use it in GitHub Desktop.
Save jafar260698/55cb5aa8879947b34580efdbee63416f to your computer and use it in GitHub Desktop.
fun loadData() {
val list = mutableListOf<ChequeDetails>()
val disposable =
AppDatabase.getDatabase(MyApplication.context, viewModelScope).chequeDao().getAll()
.flatMap { items ->
Flowable.fromIterable(items)
.map { chequeData ->
val services = AppDatabase.getDatabase(MyApplication.context, viewModelScope)
.chequeServicesDao()
.getChequeServicesBy(chequeData.id)
Log.e("Databasedan olyapti","")
val prefs = SharedPrefs.callUserPrefs()
val userName = prefs.getString("fio", "")
val sum = services.sumBy { it.price ?: 0 }
var tin="" // Mana shu ikkalasi bo'sh ketyapti
var phone_number="" // Mana shu ikkalasi bo'sh ketyapti
val additionData=AppDatabase.getDatabase(MyApplication.context,viewModelScope).chequeAdditional()
.getChequeById(chequeData.id.toInt())
.subscribeOn(Schedulers.io())
.subscribe({
tin=it.tin
phone_number=it.phone_number
Log.e("Inside","Inside RxJAva running")
},{error->
error.printStackTrace()
})
composeDisposable.add(additionData)
val details = ChequeDetails(
userName = userName,
tin = tin,
data = chequeData,
sum = sum,
serviceList = services,
phoneNumber = phone_number
)
Log.e("ChequeListViewModel",details.toString())
details
}
.doOnComplete {
_detailChequeList.postValue(list)
}
}
.subscribeOn(Schedulers.io())
.subscribe({
list.add(it)
}, { error -> error.printStackTrace() })
composeDisposable.add(disposable)
}
Mana shunda tin va phone number deganlari null ga teng bo'lyapti
Yane sal keyinroq compile qilyapti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment