This file contains 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
// Create a listener with a callback invoked when a gesture event has occurred | |
val listener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() { | |
override fun onScale(detector: ScaleGestureDetector): Boolean { | |
// Get the current camera zoom ratio | |
val currentZoomRatio: Float = cameraInfo.zoomRatio.value ?: 1F | |
// Get by how much the scale has changed due to the user's pinch gesture | |
val delta = detector.scaleFactor | |
// Update the camera's zoom ratio |
This file contains 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
// Listen to pinch gestures | |
val listener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() { | |
override fun onScale(detector: ScaleGestureDetector): Boolean { | |
// Get the camera's current zoom ratio | |
val currentZoomRatio = cameraInfo.zoomState.value?.zoomRatio ?: 0F | |
// Get the pinch gesture's scaling factor | |
val delta = detector.scaleFactor | |
// Update the camera's zoom ratio. This is an asynchronous operation that returns |
This file contains 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"?> | |
<resources xmlns:window="http://schemas.android.com/apk/res-auto"> | |
<SplitPairRule | |
window:splitRatio="0.4"> | |
<SplitPairFilter | |
window:primaryActivityName=".list.ListActivity" | |
window:secondaryActivityName=".details.DetailsActivity" /> | |
</SplitPairRule> | |
</resources> |
This file contains 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"?> | |
<resources xmlns:window="http://schemas.android.com/apk/res-auto"> | |
<!-- Other rules --> | |
<SplitPlaceholderRule | |
window:placeholderActivityName=".details.DetailsPlaceholderActivity" | |
window:splitRatio="0.4"> | |
<ActivityFilter window:activityName=".list.ListActivity" /> | |
</SplitPlaceholderRule> | |
</resources> |
This file contains 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
<resources xmlns:window="http://schemas.android.com/apk/res-auto"> | |
<SplitPairRule | |
<!-- split rule config option --> | |
> | |
<SplitPairFilter | |
window:primaryActivityName=".list.ListActivity" | |
window:secondaryActivityName=".details.DetailsActivity" /> | |
<SplitPairFilter | |
window:primaryActivityName=".details.DetailsActivity" | |
window:secondaryActivityName=".share.ShareActivity" /> |
This file contains 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
<resources xmlns:window="http://schemas.android.com/apk/res-auto"> | |
<SplitPairRule | |
window:finishPrimaryWithSecondary="true" | |
window:finishSecondaryWithPrimary="true" | |
window:splitRatio="0.4"> | |
<SplitPairFilter | |
window:primaryActivityName=".list.ListActivity" | |
window:secondaryActivityName=".details.DetailsActivity" /> | |
</SplitPairRule> | |
</resources> |
This file contains 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 ListActivity : AppCompatActivity() { | |
private val splitListener = Consumer<List<SplitInfo>> { splitInfoList -> | |
// React to a split change | |
} | |
override fun onStart() { | |
super.onStart() | |
SplitController | |
.getInstance() |
This file contains 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
val splitController = SplitController.getInstance() | |
if (!splitController.isSplitSupported()) { | |
// Split is not supported on this device | |
} |
This file contains 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
dependencies { | |
// Other app dependencies | |
implementation "androidx.window:window:1.0.0" | |
} |
This file contains 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 ActivityEmbeddingSampleApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
SplitController.initialize(this, R.xml.split_configuration) | |
} | |
} |
NewerOlder