Skip to content

Instantly share code, notes, and snippets.

Preps

Once No-SQL (Dynamo) is integrated in your Mobile Hub project, update your awsconfiguration.json and implemented data models, which are mapped objects, proceed to make a CRUD.

As DynamoDB calls are synchronous and they don't belong to the main UI Thread of the Activity, then all operations directed to your Dynamo Tables gotta be inside an asynchronous method like Runnable

Runnable runnable = new Runnable() {
@luckenzo
luckenzo / PinManager.java
Created November 29, 2018 11:53
Sample code for TLS implementation on Android apps
public class PinManager implements X509TrustManager {
/* Get a default keystore instance or specify your keystore type e.g., BKS */
KeyStore ks = KeyStore.getInstance(KeyStore. getDefaultType());
private String keyAlgorithm;
private PublicKey storedPubKey;
private String serial;
String alias = "myCert";
@Kaspic
Kaspic / mutable-live-data-live-template
Last active August 24, 2023 10:29
Android Studio Kotlin LiveData Function Templates
private val _$NAME$ = MutableLiveData<$PARAM_TYPE$>()
val $NAME$ : LiveData<$PARAM_TYPE$> = _$NAME$
@fergusonm
fergusonm / gist:88a728eb543c7f6727a7cc473671befc
Last active October 28, 2023 20:01
launchWhenX dropping events
class MainFragment : Fragment(R.layout.main_fragment) {
companion object {
fun newInstance() = MainFragment()
}
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
@vganin
vganin / FlexRow.kt
Last active June 30, 2025 05:06
[DEPRECATED, use official FlowRow instead] Jetpack Compose simple flex-wrap container
@Composable
fun FlowRow(
horizontalGap: Dp = 0.dp,
verticalGap: Dp = 0.dp,
alignment: Alignment.Horizontal = Alignment.Start,
content: @Composable () -> Unit,
) = Layout(content = content) { measurables, constraints ->
val horizontalGapPx = horizontalGap.toPx().roundToInt()
val verticalGapPx = verticalGap.toPx().roundToInt()
1. hiltvm (applicable in top-level)
@dagger.hilt.android.lifecycle.HiltViewModel
class $NAME$ @javax.inject.Inject constructor(
$PARAM$
) : androidx.lifecycle.ViewModel() {
$END$
}
2. vmstatefunc (applicable in class)
private val _$NAME$ = androidx.compose.runtime.mutableStateOf<$TYPE$>($INITIAL_VALUE$)
@electricbolt
electricbolt / FirebaseResourcesWrapper.java
Last active February 5, 2023 01:45
Subclass of android.content.res.Resources that is used to capture Firebase Analytics initialization process to return the "google_app_id" string that we require, programmatically, rather than it being embedded into strings.xml. See https://github.com/firebase/firebase-android-sdk/issues/66
package nz.co.electricbolt.firebase;
import android.content.res.AssetFileDescriptor;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Movie;
import android.graphics.Typeface;
package com.example.myapp.animation
import androidx.compose.animation.core.*
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
@nhcodes
nhcodes / Picker.kt
Created May 17, 2023 11:19
Android NumberPicker for Jetpack Compose
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Divider
import androidx.compose.material3.LocalContentColor
@f2janyway
f2janyway / ScrollBar.kt
Last active June 3, 2025 13:01
ScrollBar for LazyColumn; if there is wrapper to LazyColumn(ex;Column), just use with Box() as direct above wrapper with ScrollBar and LazyColumn
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue