Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Carlos M. carlosmuvi

🏠
Working from home
View GitHub Profile
@ferrerojosh
ferrerojosh / AndroidWorkerInjection.kt
Created May 30, 2018
androidx workmanager injector temporary impl
View AndroidWorkerInjection.kt
import androidx.work.Worker
object AndroidWorkerInjection {
fun inject(worker: Worker) {
checkNotNull(worker, { "worker" })
val application = worker.applicationContext
if (application !is HasWorkerInjector) {
throw RuntimeException("${application.javaClass.canonicalName} does not implement ${HasWorkerInjector::class.java.canonicalName}")
}
@JakeWharton
JakeWharton / Java6.java
Last active Feb 17, 2020
A comparison between non-capturing and capturing expressions across Java 6, Java 8, Java 8 with Retrolambda, Kotlin with native function expressions, and Kotlin with Java SAM expression.
View Java6.java
import java.util.Arrays;
class NonCapturing {
public static void main(String... args) {
run(new Runnable() {
@Override public void run() {
System.out.println("Hey!");
}
});
}
@alex-shpak
alex-shpak / Interceptor.java
Last active Aug 3, 2020
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
View Interceptor.java
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active Jul 16, 2020
Endless RecyclerView OnScrollListener
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;
@jmlweb
jmlweb / validnif.js
Created Nov 22, 2014
Directiva Angular para validación de NIF/NIE españoles | Angular directive for spanish NIF/NIE validation
View validnif.js
'use strict';
/**
* @ngdoc directive
* @name directive:validnif
* @description
* # validnif
*/
angular.module()
.directive('validnif', function () {
@samkirton
samkirton / gist:0242ba81d7ca00b475b9
Last active Feb 28, 2020
Fixed a bug where images added to the MediaStore are not inserted at the front of the gallery
View gist:0242ba81d7ca00b475b9
package com.memtrip;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
@MostafaGazar
MostafaGazar / SvgMaskedImageView.java
Last active Oct 24, 2017
Based on https://github.com/MostafaGazar/CustomShapeImageView, Custom shape ImageView using PorterDuffXfermode and SVGs as masks
View SvgMaskedImageView.java
/*
* Copyright 2014 Mostafa Gazar
*
* 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
@wbroek
wbroek / genymotionwithplay.txt
Last active Jul 26, 2020
Genymotion with Google Play Services for ARM
View genymotionwithplay.txt
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
You can’t perform that action at this time.