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
// Copyright 2024 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@OptIn(ExperimentalFoundationApi::class) | |
@Composable | |
fun PositionFocusedItemInLazyLayout( | |
parentFraction: Float = 0.3f, | |
childFraction: Float = 0f, | |
content: @Composable () -> Unit, | |
) { |
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
// Copyright 2024 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun SampleImmersiveList(movies: List<Movie>, modifier = Modifier) { | |
val selectedMovie = remember { mutableStateOf<Movie?>(movies.firstOrNull()) } | |
// Container | |
Box( | |
modifier = Modifier |
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
/* Copyright 2021 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
val params: WindowManager.LayoutParams = window.attributes | |
if (requestedMode.modeId !== params.preferredDisplayModeId) { | |
params.preferredDisplayModeId = requestedMode.modeId | |
window.attributes = params | |
} |
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
/* Copyright 2021 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Determine whether the transition will be seamless. | |
// Non-seamless transitions may cause a 1-2 second black screen. | |
val refreshRates = display?.mode?.alternativeRefreshRates | |
val willBeSeamless = Arrays.asList<FloatArray>(refreshRates).contains(newRefreshRate) | |
if (willBeSeamless) { | |
// Set the frame rate, but only if the transition will be seamless. | |
surface.setFrameRate(newRefreshRate, |
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
/* Copyright 2021 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
implementation 'androidx.draganddrop:draganddrop:1.0.0-alpha02' |
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
/* Copyright 2021 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
DropHelper.configureView( | |
// Activity that will handle the drop | |
this, | |
// Target drop view to be highlighted | |
outerDropTarget, | |
// Supported MIME types | |
arrayOf(MIMETYPE_TEXT_PLAIN, "image/*"), | |
// Options for configuring drop targets |
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
/* Copyright 2021 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Make a view draggable to share a file. DragStartHelper takes care of | |
// intercepting drag gestures and attaching the listener. | |
DragStartHelper(draggableView) { view, _ -> | |
// Sets the appropriate MIME types automatically. | |
val dragClipData = ClipData.newUri(contentResolver, "File", fileUri) | |
// Set the visual look of the dragged object. | |
// Can be extended and customized; we use the default here. |
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
setHeaderPresenterSelector(object : PresenterSelector() { | |
override fun getPresenter(item: Any?) = IconHeaderItemPresenter() | |
}) |
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
override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any) { | |
val headerItem = (item as ListRow).headerItem | |
viewHolder.view.apply { | |
(findViewById<View>(R.id.header_icon) as ImageView).apply { | |
val drawableResId = when (headerItem.id) { | |
ID_POPULAR -> R.drawable.ic_popular | |
ID_EDITOR_PICKS -> R.drawable.ic_editor_picks | |
... | |
} | |
setImageDrawable(resources.getDrawable(drawableResId, null)) |
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
<androidx.leanback.widget.NonOverlappingLinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="horizontal"> | |
<ImageView | |
android:id="@+id/header_icon" | |
android:layout_width="32dp" | |
android:layout_height="32dp" |
NewerOlder