Skip to content

Instantly share code, notes, and snippets.

@mkuprionis
mkuprionis / DebugApiModule.java
Last active February 3, 2016 16:07
Retrofit API wrapper to be used when testing with Espresso
@Module(
complete = false,
library = true,
overrides = true
)
public final class DebugApiModule {
@Provides @Singleton ApiEndpoint provideApiEndpoint(Locale locale, @ApiEndpointMarker StringPreference apiEndpoint,
@NetworkIgnoreLocale BooleanPreference ignoreLocale) {
return (ignoreLocale.get())
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active September 4, 2024 05:58
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* 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
@vinc3m1
vinc3m1 / AutoFitTextUtil.java
Last active September 28, 2017 07:23
AutoFitTextUtil
package com.example;
import android.text.Editable;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
@dallasgutauckis
dallasgutauckis / listDevices.sh
Created April 9, 2014 19:42
Lists connected Android devices (via adb) and the device's corresponding model and OS version - See http://dallasgutauckis.com/2014/04/09/listing-connected-android-devices-with-os-version-and-model/
#!/bin/bash
if [[ ! $PATH_TO_ADB ]]; then
PATH_TO_ADB=`which adb`
fi
if [[ ! $PATH_TO_ADB ]]; then
if [[ ! $ANDROID_HOME ]]; then
echo "Failed to determine path to adb; consider setting ANDROID_HOME to your SDK directory or PATH_TO_ADB to the path to ADB"
exit 1
fi
@antoniolg
antoniolg / SwipeRefreshActivity.java
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* 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
@GrahamLea
GrahamLea / AutoConnectingObservableExample.java
Created March 26, 2014 11:11
An example of an RxJava Observable decorator that automatically connect()s a ConnectableObservable after a prescribed number of Subscribers have subscribed
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.functions.Func2;
import rx.observables.ConnectableObservable;
import java.util.ArrayList;
import java.util.List;
@lucasr
lucasr / AnimatedLinearLayout.java
Last active December 16, 2022 19:58
Animated LinearLayout
package com.example.android_transition_samples.app;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
@wbroek
wbroek / genymotionwithplay.txt
Last active February 13, 2025 09:37
Genymotion with Google Play Services for ARM
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)
@swanson
swanson / gist:7dee3f3474e30fe8f15c
Last active January 11, 2024 16:42
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;
@romannurik
romannurik / DrawInsetsFrameLayout.java
Created February 10, 2014 16:28
DrawInsetsFrameLayout — adding additional background protection for system UI chrome when using KitKat’s translucent decor flags.
/*
* Copyright 2014 Google Inc.
*
* 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