Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example using window layout info to be notified when user changes foldable screen state
windowInfoRepository
.windowLayoutInfoObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribe{ windowLayoutInfo ->
windowLayoutInfo.displayFeatures.filterIsInstance(FoldingFeature::class.java)
.firstOrNull ()?.let { foldingFeature ->
if (foldingFeature.state == FoldingFeature.State.HALF_OPENED) {
recyclerView.layoutManager = LinearLayoutManager(
context,
LinearLayoutManager.HORIZONTAL,
false
)
} else {
recyclerView.layoutManager = GridLayoutManager(
context,
3,
LinearLayoutManager.VERTICAL,
false
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment