https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
r

rezenebe

08/29/2019, 3:18 PM
using AACs Viewmodel, Is it ok to pass an Application Context within the viewmodel. I need to access a color from resources.
m

Matthieu Coisne

08/29/2019, 3:26 PM
d

dewildte

08/29/2019, 6:31 PM
Exposing IDs is a safer approach. That said it still smells to me.
a

arekolek

08/30/2019, 6:58 AM
By the way, if you need formatted strings and would like to expose something like
Copy code
data class StringResource(val resId: Int, vararg formatArgs: Any?)
Is there any easy way to get the formatting strings lint check that is applied to
Context.getString
work on
StringResource
constructor calls?
b

bezrukov

08/30/2019, 11:03 AM
@arekolek You need to use
@StringRes
annotation for that
a

arekolek

08/30/2019, 11:24 AM
I should have been more specific, I meant the
StringFormatMatches
check
j

jalexdev

08/31/2019, 1:24 AM
Personally I prefer to expose non Android version of the state (a.k.a. Business Logic state) from my ViewModel and then my Fragment would observe and transform it with Android concerns (ex: string resources).
r

rkeazor

09/03/2019, 12:05 PM
Yea but try to reframe from bringing framework specific stuff to your viewmodel. It will be stressful during tests
d

dewildte

09/03/2019, 1:59 PM
Refrain*☝️
5 Views