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) } } |
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 |
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 |
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, |
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); | |
} |
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" |
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; |
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 { | |
} |
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; |
NewerOlder