Showing
1 changed file
with
19 additions
and
0 deletions
| 1 | +package dev.steenbakker.mobile_scanner | ||
| 2 | + | ||
| 3 | +import android.hardware.display.DisplayManager | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * This class will listen for display changes | ||
| 7 | + * and executes `onUpdateResolution` when that happens. | ||
| 8 | + */ | ||
| 9 | +class MobileScannerDisplayListener( | ||
| 10 | + private val onUpdateResolution: () -> Unit | ||
| 11 | +) : DisplayManager.DisplayListener { | ||
| 12 | + override fun onDisplayAdded(displayId: Int) {} | ||
| 13 | + | ||
| 14 | + override fun onDisplayRemoved(displayId: Int) {} | ||
| 15 | + | ||
| 16 | + override fun onDisplayChanged(displayId: Int) { | ||
| 17 | + onUpdateResolution() | ||
| 18 | + } | ||
| 19 | +} |
-
Please register or login to post a comment