This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Based on alloy's built-in sqlite adapter from alloy v1.5.1 | |
//https://github.com/appcelerator/alloy/blob/1.5.1/Alloy/lib/alloy/sync/sql.js | |
var _ = require('alloy/underscore')._; | |
// The database name used when none is specified in the | |
// model configuration. | |
var ALLOY_DB_DEFAULT = '_alloy_'; | |
var ALLOY_ID_DEFAULT = 'alloy_id'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.motion.widget.MotionLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/activity_container" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:focusableInTouchMode="true" | |
app:layoutDescription="@xml/main_activity_motion_scene" | |
app:currentState="@id/video_state_embedded_stopped"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:motion="http://schemas.android.com/apk/res-auto"> | |
<ConstraintSet android:id="@+id/video_state_embedded_playing"> | |
<Constraint | |
android:id="@+id/video_player" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="0dp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityViewModel: ViewModel() { | |
//... | |
private fun setOrientation(requestedOrientation: Int = -1) { | |
val newOrientation = requestedOrientation.takeUnless { it == -1 } ?: currentOrientation | |
_layoutState.value = when (newOrientation) { | |
Configuration.ORIENTATION_LANDSCAPE -> VideoLayoutState.FULLSCREEN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
title = getString(R.string.app_name) | |
setupVideo() | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
lateinit var orientationListener: OrientationEventListener | |
override fun onCreate(savedInstanceState: Bundle?) { | |
orientationListener = object: OrientationEventListener(this) { | |
override fun onOrientationChanged(orientation: Int) { | |
viewModel.onOrientationChange(orientation, resources.configuration.orientation) | |
} | |
}.apply { disable() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityViewModel: ViewModel() { | |
private val orientationHandler = Handler() | |
private var orientationLock: Int = Configuration.ORIENTATION_UNDEFINED | |
fun onDeviceOrientationChange(deviceOrientation: Int, activityOrientation: Int?) { | |
currentOrientation = when (deviceOrientation) { | |
in 0..20, in 160..200, in 340..359 -> Configuration.ORIENTATION_PORTRAIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityViewModel: ViewModel() { | |
val videoUrl = "https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8" | |
enum class VideoPlaybackState { | |
STOPPED, | |
PLAYING | |
} | |
enum class VideoLayoutState { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
private val viewModel: MainActivityViewModel by viewModels() | |
private val videoPlayerCallbacks = object: ControlledVideoView.IVideoListener { | |
override fun onPipToggleClicked() { | |
viewModel.onPipToggled() | |
} | |
override fun onVideoCloseClicked() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
private var currentPlaybackState: MainActivityViewModel.VideoPlaybackState? = null | |
private var currentLayoutState: MainActivityViewModel.VideoLayoutState? = null | |
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | |
super.onCreateOptionsMenu(menu) | |
menuInflater.inflate(R.menu.options_menu, menu) | |
return true | |
} |
OlderNewer