https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
b

Bruce Xia

11/10/2020, 7:53 PM
Any advice how to deal with screen configurations with Contour? Trying to use Contour on one of our screen that has different layout and text colors on mobile portrait, landscape mode and TV screens. I created something like to return screen config but it still seems pretty tedius to check the config and return different values in every child layout
Copy code
class LayoutConfigResolver @Inject constructor(private val context: Context, private val deviceInfo: DeviceInfo) {
    fun currentConfig() = when {
        deviceInfo.isTv -> TV
        else -> if (context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) PHONE_PORTRAIT else PHONE_LAND
    }
}