Last active
November 5, 2020 07:20
-
-
Save jafar260698/55cb5aa8879947b34580efdbee63416f to your computer and use it in GitHub Desktop.
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
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