Skip to content

Instantly share code, notes, and snippets.

View moizest89's full-sized avatar
🎯
Focusing

Moises Portillo moizest89

🎯
Focusing
View GitHub Profile
@AradiPatrik
AradiPatrik / activity_main.xml
Created December 27, 2020 09:27
The View gets pushed up by the RecyclerView but never out of screen
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layoutDescription="@xml/motion_scene"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<View
android:id="@+id/header"
@Falciighol
Falciighol / svMunicipalities.json
Created October 30, 2019 15:47
[El Salvador Municipalities] El Salvador municipalities list #json #list #bp
[
{
"DESCIUDAD": "AHUACHAPAN",
"CODDEPTO": 1,
"CODCIUDAD": 1
},
{
"DESCIUDAD": "APANECA",
"CODDEPTO": 1,
"CODCIUDAD": 2
@Falciighol
Falciighol / svDepartments.json
Created October 30, 2019 15:42
[El Salvador Departments] El Salvador departments list #json #list #bp
[
{
"DESDEPTO": "AHUACHAPAN",
"CODDEPTO": 1
},
{
"DESDEPTO": "SANTA ANA",
"CODDEPTO": 2
},
{
class ChangeOutlineRadiusTransition(
private val startRadius: Int,
private val endRadius: Int
) : Transition() {
private companion object {
/**
* Unique key for start and end values to be kept in [TransitionValues] [TransitionValues]
*/
private const val RADIUS = "ChangeOutlineRadiusTransition:outlineRadius"
@quentin41500
quentin41500 / CartManager.kt
Last active June 8, 2021 12:28
Using Sealed class and LiveData to handle network request through the repository layer.
/**
* Observable manager for saving the [Cart]'s resource information.
*/
class CartManager : LiveData<Resource<Cart?>>() {
init {
value = Success(null)
}
/**
@iamnaran
iamnaran / activity_layout.xml
Last active July 30, 2024 12:55
Layout And RecyclerView Animation Android (Made Simple with XML only)
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation"
android:orientation="vertical">
</ScrollView>
@michaelbukachi
michaelbukachi / realm.kt
Last active May 24, 2022 04:31
Realm Coroutines
import io.realm.*
import io.realm.kotlin.where
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
private suspend fun <T: RealmObject, S: RealmQuery<T>> findAllAwait(query: S): RealmResults<T> = suspendCancellableCoroutine { continuation ->
val listener = RealmChangeListener<RealmResults<T>> { t -> continuation.resume(t) }
@mroczis
mroczis / SupportMapCallback.java
Last active December 6, 2019 13:21
SupportMapFragment from Google Maps which will work with AndroidX
import android.os.RemoteException;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.internal.IGoogleMapDelegate;
import com.google.android.gms.maps.internal.zzaq;
final class SupportMapCallback extends zzaq {
private OnMapReadyCallback mMapCallback;
@michaeltys
michaeltys / ShareFileToInstagram
Created October 10, 2018 15:13
Sharing an image to instagram stories or create a post
private void shareFileToInstagram(Uri uri, boolean isVideo, Post post) {
Intent feedIntent = new Intent(Intent.ACTION_SEND);
feedIntent.setType(isVideo ? "video/*" : "image/*");
feedIntent.putExtra(Intent.EXTRA_STREAM, uri);
feedIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
Intent storiesIntent = new Intent("com.instagram.share.ADD_TO_STORY");
storiesIntent.setDataAndType(uri, isVideo ? "mp4" : "jpg");
storiesIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
storiesIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
@Grohden
Grohden / BundleEnumExtension.kt
Created August 23, 2018 03:58
Android Bundle enum support using kotlin extension methods
import android.os.Bundle
// Dunno if there's a better way to extend both bundle and intents, but
// you probably can extend intents in the same way
fun Bundle.putEnum(key:String, enum: Enum<*>){
putString(key, enum.name)
}
inline fun <reified T: Enum<T>> Bundle.getEnum(key:String): T {