Skip to content

Instantly share code, notes, and snippets.

View ivangarzab's full-sized avatar

Iván Garza Bermea ivangarzab

View GitHub Profile
public interface MixhaloError {
String getMessage();
int getErrorCode();
}
public enum ConnectionError implements MixhaloError {
INVALID_WIFI_STATE("", 1000101),
INVALID_CELLULAR_STATE("", 1000102),
INVALID_VENUE_ID("", 1000300),
INVALID_VENUE_PASSCODE("", 1000301),
@ivangarzab
ivangarzab / MixhaloError.java
Created March 5, 2024 23:18
MixhaloError enum class alternative
public enum MixhaloError {
/**
* Problem: Mixhalo was unable to login to the backend server.
* Solution: Check credentials.
*/
FAILED_AUTHENTICATION("Authentication failed", 1000400),
/**
* Problem: Failed to fetch venue list due to the required location services being disabled.
* Solution: Turn on location services for the device.
*/
@ivangarzab
ivangarzab / play-common.kt
Created October 2, 2022 16:17
Integrate Google Play Store's common library
dependencies {
...
implementation 'com.google.android.play:core-common:2.0.0'
...
}
@ivangarzab
ivangarzab / play-app-update.kt
Created October 2, 2022 16:10
Integrate Google Play Store's In-App Update library
dependencies {
...
implementation 'com.google.android.play:app-update:2.0.0'
// Kotlin users may also add the Kotlin extensions library
implementation 'com.google.android.play:app-update-ktx:2.0.0'
...
}
@ivangarzab
ivangarzab / play-review.kt
Created October 2, 2022 16:07
Integrate Google Play Store's In-App Review library
dependencies {
...
implementation 'com.google.android.play:review:2.0.0'
// Kotlin users may also add the Kotlin extensions
implementation 'com.google.android.play:review-ktx:2.0.0'
...
}
@ivangarzab
ivangarzab / play-feature-delivery.kt
Created October 2, 2022 16:03
Integrate Google Play Store's Feature Delivery library
dependencies {
...
implementation 'com.google.android.play:feature-delivery:2.0.0'
// Kotlin users may also add the Kotlin extensions library
implementation 'com.google.android.play:feature-delivery-ktx:2.0.0'
...
}
@ivangarzab
ivangarzab / play-asset-delivery.kt
Created October 2, 2022 15:59
Integrate Google Play Store's Asset Delivery dependency
dependencies {
...
implementation 'com.google.android.play:asset-delivery:2.0.0'
// Kotlin users may also add the Kotlin extensions library
implementation 'com.google.android.play:asset-delivery-ktx:2.0.0'
...
}
@ivangarzab
ivangarzab / error-play:core-duplicate-classes.kt
Last active October 2, 2022 15:46
Duplicate classes error for outdated play:core dependency.
Duplicate class com.google.android.play.core.common.IntentSenderForResultStarter found in modules jetified-core-1.10.3-runtime (com.google.android.play:core:1.10.3) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.common.LocalTestingException found in modules jetified-core-1.10.3-runtime (com.google.android.play:core:1.10.3) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.common.PlayCoreDialogWrapperActivity found in modules jetified-core-1.10.3-runtime (com.google.android.play:core:1.10.3) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.listener.StateUpdatedListener found in modules jetified-core-1.10.3-runtime (com.google.android.play:core:1.10.3) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core
@ivangarzab
ivangarzab / get-theme-attr.kt
Created September 12, 2022 22:53
Get a theme attribute programmatically
val typedValue = TypedValue()
theme.resolveAttribute(android.R.attr.textColor, typedValue, true)
val color = typedValue.data()
@ivangarzab
ivangarzab / CustomViewExtension.kt
Created September 7, 2022 01:36
Example on how to create a "custom object" in Android using Data Binding + Kotlin Extensions
fun ExampleViewBinding.bind(
resources: Resources,
onAction: (Any) -> Unit
) {
this.title = resources.getString(R.string.title)
this.setSaveClickListener {
this.subtitle = when (someData) {
true -> R.string.subtitle1
false -> R.string.subtitle2
}