Erfannj En
10/31/2022, 6:52 AMrecommended android architecture
. Suppose we are building a vpn client
, in which layer should the business logic and Service class be placed? In the ui layer corresponding to its feature, or the domain layeralthaf
10/31/2022, 7:36 AMDanish Ansari
11/02/2022, 11:12 AMStateFlow
to be specific
I have MutableStateFlow<UiState>
and corresponding StateFlow<UiState>
defined in my viewmodel
class MainViewModel:ViewModel() {
private val mutableUiState = MutableStateFlow(UiState())
val uiState = mutableUiState.asStateFlow()
// ...
}
And my UiState is roughly defined like this
data class UiState(
val propertyA: Int = 0,
val propertyB: Boolean = false
) {
private var mutableProperty: Int = 0
val derivedProperty: Boolean
get() = mutableProperty % 2 == 0
fun someMethod(newProperty: Int) {
mutableProperty = newProperty
// some extra logic goes here
}
}
Now the doubt is that in my viewmodel I’m calling mutableUiState.someMethod(someInteger)
but I think uiState
is not getting updated because I have used uiState.derivedProperty
at some place in UI in compose and the UI is not updating.
Someone care to help what I’m doing wrong? ThanksBill
11/03/2022, 2:11 PMTimothy Ademola
11/03/2022, 4:39 PMIsaacMart
11/04/2022, 3:48 PMkhalid64927
11/04/2022, 4:54 PMSolomon Tolu Samuel
11/04/2022, 7:54 PM//Repository
data class PostResponse(
val body: String,
val title: String,
val id: Int,
val userId: Int
)
class NewsRepository @Inject constructor(private val newsRemoteDataSource: NewsRemoteDataSource ) {
val fetchLatestNews : Flow<List<PostResponse>> = newsRemoteDataSource.fatchLatestNews
//ViewModel
data class UiPostResponse(
val post: PostResponse,
val message: String = "message"
)
class UiViewModel @Inject constructor(private val newsRepository: NewsRepository): ViewModel() {
private val data : Flow<UiPostResponse> = newsRepository.fetchLatestNews.map { post->
UiPostResponse(
//
)
}
Please what would be the best way to map a list of flow data to useful UI data in the viewmodel?zt
11/05/2022, 4:23 AMdevhyeon0312
11/06/2022, 10:32 PMPreetham Ivan Dsouza
11/07/2022, 9:42 AMcertificatePinner
etc (if we are setting keys dynamically and not locally) how do we achieve the same with Hilt?
Ref: Similar use case to this issueSlackbot
11/07/2022, 4:36 PMSlackbot
11/08/2022, 1:53 PMJavokhir Savriev
11/08/2022, 7:40 PMdevhyeon0312
11/09/2022, 8:22 AMPradeep Magzter
11/09/2022, 9:14 AMPrasoon Agrawal
11/09/2022, 12:23 PMPrasoon Agrawal
11/09/2022, 12:23 PMPaulio.Deighton
11/09/2022, 12:38 PMPaulio.Deighton
11/09/2022, 12:39 PMPaulio.Deighton
11/09/2022, 12:40 PMPaulio.Deighton
11/09/2022, 12:43 PMDragan Vojvodić
11/10/2022, 1:22 PMgts13
11/11/2022, 10:13 AMEugene Maksymenko
11/11/2022, 10:18 AMShankar Gollakota
11/11/2022, 1:46 PMYves Kalume
11/12/2022, 8:42 PMmergeExtDexDebug
task was the one that was taking a lot of time and the reason why it runs is Value of input propertv ‘sharedParams.minSdkVersion’ has changed
is there anyone who could have the solution to this issue ? Thanks !Prateek Kumar
11/14/2022, 1:46 PMAdam Brown
11/14/2022, 11:07 PMWorkManager
, and it can potentially run for a long time, so I launch it with setExpedited
and setup the ForegroundInfo
to display a progress notification and keep it foreground. But now it fails in Android 12+ because of the new restrictions. Is there now no way to launch a long running task like this from the background? i.e. schedule a job once a week to do a data sync and have it run foreground?Kenneth Leong
11/15/2022, 5:33 PMonBackPressed()
on my activity but i am just doing something like resetting a flag, and calling super.onbackPressed()
, how can i do this while also supporting predictive back gesture? e.g. below
override fun onBackPressed() {
flag = false
super.onBackPressed()
}
Kenneth Leong
11/15/2022, 5:33 PMonBackPressed()
on my activity but i am just doing something like resetting a flag, and calling super.onbackPressed()
, how can i do this while also supporting predictive back gesture? e.g. below
override fun onBackPressed() {
flag = false
super.onBackPressed()
}