dima.avdeev
2 years ago
committed by
GitHub
5 changed files with 42 additions and 15 deletions
@ -1,15 +1,29 @@ |
|||||||
package example.imageviewer |
package example.imageviewer |
||||||
|
|
||||||
import android.os.Bundle |
import android.os.Bundle |
||||||
|
import androidx.activity.addCallback |
||||||
import androidx.activity.compose.setContent |
import androidx.activity.compose.setContent |
||||||
import androidx.appcompat.app.AppCompatActivity |
import androidx.appcompat.app.AppCompatActivity |
||||||
import example.imageviewer.view.ImageViewerAndroid |
import example.imageviewer.view.ImageViewerAndroid |
||||||
|
import kotlinx.coroutines.channels.BufferOverflow |
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow |
||||||
|
|
||||||
class MainActivity : AppCompatActivity() { |
class MainActivity : AppCompatActivity() { |
||||||
|
|
||||||
|
val externalEvents = MutableSharedFlow<ExternalImageViewerEvent>( |
||||||
|
replay = 0, |
||||||
|
extraBufferCapacity = 1, |
||||||
|
onBufferOverflow = BufferOverflow.DROP_OLDEST, |
||||||
|
) |
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) { |
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
super.onCreate(savedInstanceState) |
super.onCreate(savedInstanceState) |
||||||
setContent { |
setContent { |
||||||
ImageViewerAndroid() |
ImageViewerAndroid(externalEvents) |
||||||
} |
} |
||||||
|
onBackPressedDispatcher.addCallback { |
||||||
|
externalEvents.tryEmit(ExternalImageViewerEvent.ReturnBack) |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
} |
||||||
|
Loading…
Reference in new issue