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
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
jmperezra / LabelledSpinner.java
Created Sep 3, 2017 — forked from paolorotolo/ LabelledSpinner.java
A Spinner component with a floating label for Android, similar to EditText components wrapped in a TextInputLayout.
View LabelledSpinner.java
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jmperezra
jmperezra / build.gradle
Created Jul 12, 2017 — forked from fabiomsr/build.gradle
dependencies.gradle example
View build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion rootProject.androidCompileSdkVersion
buildToolsVersion rootProject.androidBuildToolsVersion
defaultConfig {
minSdkVersion rootProject.androidMinSdkVersion
@jmperezra
jmperezra / NetworkModule.java
Last active Feb 22, 2017
Handler para conexión SSL y Pinning
View NetworkModule.java
/**
* Ejemplo para Dagger 2
*/
public class NetworkModule{
@Provides
@Singleton
public OkHttpClient provideOkHttpClient(final HttpLoggingInterceptor loggingInterceptor,
final HeaderInterceptor headerInterceptor,
final TokenInterceptor tokenInterceptor,
final SSLCertificateHandler sslCertificateHandler,
@jmperezra
jmperezra / SpinnerLoading.java
Last active Feb 17, 2017
[Android] Spinner Loading es un Dialogo transparente que muestra un spinner con un color configurable.
View SpinnerLoading.java
import android.support.annotation.NonNull;
public interface SpinnerLoading {
void show();
void show(@NonNull final SpinnerLoadingListener listener);
void dismiss();
void dismiss(@NonNull final SpinnerLoadingListener listener);
}
@jmperezra
jmperezra / script_export_database_realm.sh
Created Feb 14, 2017
Script para exportar una base de datos realm
View script_export_database_realm.sh
#!/bin/sh
#Ruta absoluta hasta la carpeta platform-tools del sdk de Android. Ej: /Users/josemaria/Library/Android/sdk/platform-tools
ADB_PATH=""
#Paquete de la app. Ej: com.jmperezra.appname
PACKAGE_NAME=""
#Nombre de la base de datos Realm. Ej: default.realm
DB_NAME=""
#Ruta absoluta del destino del fichero .realm. Ej: /Users/josemaria/proyecto/AppName/db/
DESTINATION_PATH=""
NOT_PRESENT="List of devices attached"
@jmperezra
jmperezra / RealmCollectionHelper.java
Last active Jun 13, 2017
Código para convertir una colección a una colección de Realm (RealmList)
View RealmCollectionHelper.java
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;
@jmperezra
jmperezra / IRealmCascade.java
Created Jun 19, 2016
Realm Delete Cascade
View IRealmCascade.java
/**
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
jmperezra / LocalJsonClient.java
Last active Jul 20, 2017 — forked from swanson/gist:7dee3f3474e30fe8f15c
Retrofit LocalJsonClient
View LocalJsonClient.java
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;
View EndlessRecyclerOnScrollListener.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
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.