Skip to content

Instantly share code, notes, and snippets.

Chema Pramos jmperezra

Block or report user

Report or block jmperezra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jmperezra / Coroutine_scope_functions.kt
Created Jul 10, 2019 — forked from pablisco/Coroutine_scope_functions.kt
Simple way to jump into a separate context
View Coroutine_scope_functions.kt
suspend fun <T, R> T.letOn(
context: CoroutineContext,
block: suspend CoroutineScope.(T) -> R
): R = withContext(context) { block(this@letOn) }
suspend fun <T> T.alsoOn(
context: CoroutineContext,
block: suspend CoroutineScope.(T) -> Unit
): T = also { withContext(context) { block(this@alsoOn) } }
jmperezra /
Created Sep 3, 2017 — forked from paolorotolo/
A Spinner component with a floating label for Android, similar to EditText components wrapped in a TextInputLayout.
* Copyright 2015 Farbod Salamat-Zadeh
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
jmperezra / build.gradle
Created Jul 12, 2017 — forked from fabiomsr/build.gradle
dependencies.gradle example
View build.gradle
apply plugin: ''
apply plugin: ''
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion rootProject.androidCompileSdkVersion
buildToolsVersion rootProject.androidBuildToolsVersion
defaultConfig {
minSdkVersion rootProject.androidMinSdkVersion
jmperezra /
Last active Feb 22, 2017
Handler para conexión SSL y Pinning
* Ejemplo para Dagger 2
public class NetworkModule{
public OkHttpClient provideOkHttpClient(final HttpLoggingInterceptor loggingInterceptor,
final HeaderInterceptor headerInterceptor,
final TokenInterceptor tokenInterceptor,
final SSLCertificateHandler sslCertificateHandler,
jmperezra /
Last active Feb 17, 2017
[Android] Spinner Loading es un Dialogo transparente que muestra un spinner con un color configurable.
public interface SpinnerLoading {
void show();
void show(@NonNull final SpinnerLoadingListener listener);
void dismiss();
void dismiss(@NonNull final SpinnerLoadingListener listener);
jmperezra /
Created Feb 14, 2017
Script para exportar una base de datos realm
#Ruta absoluta hasta la carpeta platform-tools del sdk de Android. Ej: /Users/josemaria/Library/Android/sdk/platform-tools
#Paquete de la app. Ej: com.jmperezra.appname
#Nombre de la base de datos Realm. Ej: default.realm
#Ruta absoluta del destino del fichero .realm. Ej: /Users/josemaria/proyecto/AppName/db/
NOT_PRESENT="List of devices attached"
jmperezra /
Last active Jun 13, 2017
Código para convertir una colección a una colección de Realm (RealmList)
import java.util.Collection;
import io.realm.RealmList;
import io.realm.RealmModel;
public class RealmCollectionHelper {
public static <C extends RealmModel> RealmList<C> mapperCollectionToRealmList(Collection<C> objects){
if (objects == null){
return null;
2) Add interface to your project. If your Realm object implement this interface all child objects will be deleted
after call deleteCascade. If interface not implemented this function delete Realm object but don't delete child objects.
public interface IRealmCascade {
jmperezra /
Last active Jul 20, 2017 — forked from swanson/gist:7dee3f3474e30fe8f15c
Retrofit LocalJsonClient
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import retrofit.client.Client;
import retrofit.client.Header;
import retrofit.client.Request;
import retrofit.client.Response;
import retrofit.mime.TypedInput;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
You can’t perform that action at this time.