Sergio C.
10/31/2021, 3:04 PMursus
11/07/2021, 12:36 PMHakob Astvacatryan
11/10/2021, 3:30 PMvesp
11/11/2021, 7:11 PMLilly
11/15/2021, 5:44 PMAlex C
11/17/2021, 3:37 AMmattinger
11/17/2021, 9:27 PMursus
11/25/2021, 1:03 AMursus
11/27/2021, 3:27 AMpsk
12/01/2021, 1:29 AMLilly
12/04/2021, 3:10 PMFacade
. Any ideas?mattinger
12/08/2021, 7:38 PMNacho Ruiz Martin
12/18/2021, 6:47 PMViewModel
, how would you share some logic between different ViewModels
? I have a 1:1 relationship between screens and VM and the latest is in charge of any change to the state. So a lot of logic may be shared, for example the management of a textfield with value update, validation, error setting and such.mattinger
12/21/2021, 3:01 AMSergio C.
12/25/2021, 11:00 PM이준학
12/28/2021, 2:50 PMI am currently developing an android service app. A problem arose while developing a foreground service app. This is the situation when the activity gets data from the service. One way is to use a bind service and call a method from the service instance.
Another way is to get data using intents.
I've searched a lot, but almost all of them are using intents. If the lifecycle fits well, isn't it convenient and good to call a function as a bind service? I'd like to hear your opinion.
(In the service, it does not actually work, but creates and manages a working thread.)
Sanendak
12/29/2021, 4:19 PMursus
01/05/2022, 4:54 AMursus
01/07/2022, 4:16 PMdave08
01/09/2022, 12:45 PMArpan Sarkar
01/12/2022, 2:27 PMclass App : Application() {
private var baseCtx: Context? = null
private var appCtx: Context? = null
private var baseRes: Resources? = null
override fun attachBaseContext(base: Context) {
val ctx = baseCtx ?: base.createLocalizedContext(Locale.ENGLISH).also {
baseCtx = it
}
super.attachBaseContext(ctx)
}
override fun getApplicationContext(): Context {
return appCtx ?: super.getApplicationContext().createLocalizedContext(Locale.ENGLISH).also {
appCtx = it
}
}
override fun getResources(): Resources {
return baseRes ?: baseContext.createLocalizedContext(Locale.ENGLISH).resources.also {
baseRes = it
}
}
}
I am planing to do some thing like this for fragments which requires translation not sure if its a good idea or not
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val themedContext = ContextThemeWrapper(
inflater.context,
R.style.Theme_LocalizedFragment_Green // apply brand them green
)
val local = getLocal() // get local from local storage
if (requiredTranslation) {
themedContext.applyOverrideConfiguration(
requireContext().createLocalizedConfiguration(local)
)
}
val themedInflater = inflater.cloneInContext(themedContext)
return super.onCreateView(themedInflater, container, savedInstanceState).apply {
// adjust layout direction as per local
ViewCompat.setLayoutDirection(this, TextUtilsCompat.getLayoutDirectionFromLocale(local))
}
}
Cicero
01/16/2022, 5:20 PMHey Cicero,
Using interface is a matter of Clean Code Architecture, so yes we are using interfaces with UseCases. Please whenever you need to add a new one make sure that you do an interface for.
This project is intended to be big and continues project, so if we are going to support Unit test in future then we need to make sure that we can test each part separately.
The ViewModel is the only exception at the moment because Koin does not accept interfaces when we define the ViewModel. If we you know a way then please tell me to add interfaces to ViewModels.
So, I understand why I would use interfaces in repositories, right, mocking and what not, but aren't use cases supposed to represent business rules that will shape the information in your view? And aren't this business rules supposed to be prime to the functionality of your viewmodel?
Also, what about adding interfaces everywhere when no code is tested or "it's going to be teste in the future"?
This kind of discussion eat me inside last year.luke_c
01/22/2022, 10:59 PMtakahirom
01/28/2022, 1:33 AMsuspend fun fetch(): List<Item>
2. The advantage of using Result is that you can specify the type of error and ensure that the API user can handle it.
suspend fun fetch(): Result<List<Item>, FetchError>
In the architecture guide, there is a statement that you should use Kotlin's error mechanism. Is it to take advantage of this?
For coroutines and flows, you should use Kotlin's built-in error-handling mechanism.https://developer.android.com/jetpack/guide/data-layer?hl=en#expose-errors
Colton Idle
01/28/2022, 6:18 PMCan Korkmaz
02/06/2022, 6:24 PM@Preview
@Composable
fun LoginScreenPreview(){
val navController = rememberNavController()
val main: MainActivity = MainActivity()
val myfactory = MainViewModelFactory(Database.getInstance(main.applicationContext).Dao, main.application)
val viewModel: MainViewModel = viewModel(
factory =myfactory
)
//TextField(value ="xxx", onValueChange ={} )
LoginScreen(navController, viewmodel = viewModel)
}
and viewmodel factory:
class MainViewModelFactory(
private val dataSource: Dao,
private val application: Application
): ViewModelProvider.Factory{
@Suppress("unchecked_cast")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(MainViewModel::class.java)) {
return MainViewModel(dataSource, application) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
}
The login screen only has basic fields such as textfields and a button, but uses data from viewmodel. Can't preview anything as of this state.Lokik Soni
02/07/2022, 7:53 AMCan Korkmaz
02/15/2022, 2:31 PMArun Joseph
02/15/2022, 8:53 PMGomathi Gms
02/16/2022, 4:30 PMGomathi Gms
02/16/2022, 4:30 PMStuie
02/16/2022, 6:03 PMdependencies
block.
You can get more information by running Gradle's dependencies
task via Ctrl
Ctrl
gradle dependencies
Gomathi Gms
02/16/2022, 6:04 PMStuie
02/16/2022, 6:08 PMGomathi Gms
02/16/2022, 6:13 PM