Skip to content

Instantly share code, notes, and snippets.

@laurentyhuel
laurentyhuel / gist:60b1ba29b49ff29fd0d55abd138e8419
Last active March 21, 2022 11:10
2x screen : show presentation
private var presentation: DefaultPresentation? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
[...]
getCustomerDisplay(this)?.let { display ->
presentation = DefaultPresentation(display, applicationContext)
presentation?.setImage(uri)
}
}
@laurentyhuel
laurentyhuel / gist:b5b0aa1d12fa1003e6d282e7486bec25
Created March 21, 2022 11:01
2xScreen : DefaultPresentation
class DefaultPresentation(
display: Display,
context: Context
) : Presentation(context, display) {
private lateinit var binding: PresentationDefaultBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/presentation_image"
@laurentyhuel
laurentyhuel / gist:d343d6e56b65619516a8ea4103a2473a
Created March 21, 2022 10:51
2xScreen : getCustomerDisplay
fun getCustomerDisplay(context: Context): Display? {
val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
val displays = displayManager.displays
if (displays.size <= 1) {
return null
}
// We take the first additional screen
return displays[1]
}