Skip to content

Instantly share code, notes, and snippets.

@hoangchungk53qx1
hoangchungk53qx1 / TestCropImageCompose
Last active August 17, 2024 09:13
TestCropImageCompose
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
fun TestCropImage() {
val context = LocalContext.current
val cropView = remember {
CropImageView(context).apply {
isAutoZoomEnabled = false
cropShape = CropImageView.CropShape.RECTANGLE
@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;
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$)
@vganin
vganin / FlexRow.kt
Last active September 1, 2024 19:19
[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()
@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?) {
@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$
@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";

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() {
@juampynr
juampynr / CHANGELOG.md
Created March 27, 2018 09:35
Sample CHANGELOG

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[Unreleased] - yyyy-mm-dd

Here we write upgrading notes for brands. It's a team effort to make them as

@Robyer
Robyer / maven-publish-helper-usage.gradle
Last active July 31, 2024 13:18
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {