Kashismails
07/30/2022, 1:43 PMopen class RealmServiceImpl(private val realm: Realm) {
fun insertSupplier(supplier: SupplierDomainModel) {
CoroutineScope(Dispatchers.Default).async {
write(supplier)
}
}
fun insertPackedOrder(order: OrderDomainModel) {
CoroutineScope(Dispatchers.Default).async {
writeOrderPacked(order)
}
}
private suspend fun writeOrderPacked(order: OrderDomainModel) =
realm.write {
copyToRealm(
order.asOrderEntity()
)
}
private suspend fun write(supplier: SupplierDomainModel) =
realm.write {
copyToRealm(
supplier.asEntity()
)
}
private fun delete() {
realm.writeBlocking {
val writeTransactionTasks = realm.query<SupplierEntity>().find()
delete(writeTransactionTasks)
}
}
fun removePackedOrder(order: OrderDomainModel) {
CoroutineScope(Dispatchers.Default).launch {
removeOrder(order)
}
}
private suspend fun removeOrder(order: OrderDomainModel) {
realm.write {
val deletable = this.query<OrderEntity>("orderId == ${order.orderItemId}").find().first()
delete(deletable)
}
}
fun getPackedOrders() = realm.query<OrderEntity>().find()
fun getSupplier() = realm.query<SupplierEntity>().find().last()
}
this is my realm class
supplier's data is getting retrieved successfully
suspend fun getShippingBookedOrders(): DataState<List<OrdersDTO>> {
return withContext(Dispatchers.Default + SupervisorJob()) {
val ktor = async {
ktorService.getShippingBookedOrders(supplierId = supplier!!.sid)
}
val ktorServiceList = ktor.await()
val ordersList =realmServiceImpl.getPackedOrders()
ktorServiceList.data?.asDomainModel()?.map { item ->
item.isPacked = ordersList.any {
item.orderItemId == it.orderId
}
}
ktorServiceList
}
}
open class OrderEntity: RealmObject {
open var orderId: Int = -130
}
Kashismails
07/30/2022, 1:43 PMYesayaathuman
07/30/2022, 10:45 AMKhanzada Kashif
08/01/2022, 6:10 AMfun getPackedOrders() : List<OrderEntity> = realm.query<OrderEntity>().find()
this is how I am reading data, I have tried .asFlow() as well.IsaacMart
08/01/2022, 12:52 PMcoroutinedispatcher
08/01/2022, 8:57 PMsundernegi
08/02/2022, 11:37 AMALAN R S
08/02/2022, 3:11 PMkevindmoore
08/02/2022, 3:59 PMraghunandan
08/03/2022, 11:46 AMGaurav
08/03/2022, 2:02 PMKotlinLeaner
08/03/2022, 3:15 PMval string = "Welcome<br>how are you?"
when I am trying to regex
string?.replace("\\<.*?\\>", " ");
it's not working. It returning same string. Anyone know how to fix this problem?Vinicius Matheus
08/03/2022, 4:52 PMRomão
08/03/2022, 9:15 PMval moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
val jsonAdapter: JsonAdapter<User> = moshi.adapter(User::class.java)
val data = AssetManager.open("users.json").bufferedReader().use { it.readText() }
jsonAdapter.fromJson(data)
how to read the User.json in the assets folder into a string? then input the string into jsonAdapter.fromJson(string)?Paul
08/04/2022, 9:15 PMColton Idle
08/05/2022, 3:16 AMLukasz Kalnik
08/05/2022, 1:27 PMModalBottomSheetLayout
where the contents is the main screen with a list of items, and the sheetContent
are item details (with different settings).
As the item details are quite complex, and don't influence the main screen, I would like to have them in a separate ViewModel. How can I pass the itemId
from the MainScreenViewModel
to the ItemDetailsViewModel
. I don't really fancy creating a shared ViewModel just to pass one value (which is anyway only temporary, as the ItemDetailsViewModel
will store itemId
as well to get the item data).Nat Strangerweather
08/06/2022, 9:39 AMRegan Russell
08/07/2022, 1:14 AMRegan Russell
08/07/2022, 1:17 AM@Inject @Named( something ) Observable<String> someChanges;
When I try to inject that into a new adapter it is always null.
I don’t see any other reference to the variable except
compositeDisposable.add((Disposable) someChanges ....
the rest of the code is a mess and its unreadable, unintelligible…Regan Russell
08/07/2022, 1:25 AMRegan Russell
08/07/2022, 4:35 AMARCHIT JAIN
08/08/2022, 10:03 AMreactormonk
08/09/2022, 8:00 AMLopsPower
08/09/2022, 8:47 AMjuliocbcotta
08/10/2022, 3:21 PMnonTransitiveRClass
in my project, but to avoid a bunch of import alias I thought I could encapsulate the R classes from library modules and avoid the class name conflict...
How to encapsulate the R
or R.string
class in my class ?
I tried this
object MyR {
val string: R.string = R.string
}
but I get thisIheme Tobechukwu
08/10/2022, 7:57 PMRafiul Islam
08/10/2022, 9:41 PMBohirjon Akhmedov
08/11/2022, 5:44 AM