Skip to content

Instantly share code, notes, and snippets.

View arriolac's full-sized avatar
🌍

Chris Arriola arriolac

🌍
View GitHub Profile
@arriolac
arriolac / Android Studio Tricks.md
Last active January 28, 2022 02:40
Some Android Studio Tricks.

Android Studio Notes

Android Studio keyboard shortcuts I use often.

Keyboard Shortcuts for Mac

  • SHIFT + F6 to refactor methods, classes, and variable names
  • CTRL + O to override methods
  • COMMAND + N
    • Generate getter, setter, and constructor method for a class (when in editor pane)
@arriolac
arriolac / GoogleMapAnimate.kt
Created May 16, 2022 16:47
Maps Compose Snippets
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
val singapore = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(singapore, 11f)
}
Box(Modifier.fillMaxSize()) {
GoogleMap(
modifier = Modifier.matchParentSize(),
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
GoogleMap(
uiSettings = MapUiSettings(compassEnabled = false, mapToolbarEnabled = true)
// …
)
@arriolac
arriolac / GoogleMapProperties.kt
Created June 1, 2022 19:33
GoogleMapProperties.kt
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
GoogleMap(
properties = MapProperties(isBuildingEnabled = true)
// …
)
@arriolac
arriolac / GoogleMapMarker.kt
Created June 1, 2022 19:34
GoogleMapMarker.kt
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
GoogleMap(modifier = Modifier.fillMaxSize()) {
Marker(
state = MarkerState(LatLng(1.35, 103.87)),
title = "Marker in Singapore",
onClick = { Log.d("Marker", "Marker was clicked") }
)
}
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
val singapore = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(singapore, 11f)
}
Box(Modifier.fillMaxSize()) {
GoogleMap(
modifier = Modifier.matchParentSize(),
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
MyAppTheme {
GoogleMap(
//…
) {
Circle(
center = singapore,
fillColor = MaterialTheme.colors.primary
@arriolac
arriolac / RvComposePrePoolingContainer.kt
Created June 27, 2022 20:48
Example of using Compose in RecyclerView before pooling container was introduced.
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
import androidx.compose.ui.platform.ComposeView
class MyComposeAdapter : RecyclerView.Adapter<MyComposeViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
class ComposeItemRow @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : AbstractComposeView(context, attrs, defStyle) {
// …
@arriolac
arriolac / ItemRow.kt
Last active July 11, 2022 17:02
A Composable within an RV
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
@Composable
fun ItemRow(index: Int, state: LazyListState) {
DisposableEffect(Unit) {
println("ItemRow $index composed")
onDispose { println("ItemRow $index DISPOSED") }
}
Column(Modifier.fillMaxWidth()) {