Skip to content

Instantly share code, notes, and snippets.

@jgilfelt
jgilfelt / ScalpelDrawer.java
Last active January 28, 2017 13:09
ScalpelDrawer - A simple wrapper for Scalpel (https://github.com/JakeWharton/scalpel) that includes toggle controls accessible from a right-side navigation drawer. Call ScalpelDrawer.wrapInside() in a base Activity onPostCreate() to easily wrap all content in your app.
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
@mpost
mpost / Entry.java
Created December 12, 2013 10:27
Android application demonstrating the usage of Android 4.4 transitions to achieve animations effects.
package com.eclipsesource.overlay;
public class Entry {
private final int imageResId;
private final String title;
private final int id;
public Entry( int imageResId, String title, int id ) {
@JakeWharton
JakeWharton / HierarchyTreeChangeListener.java
Last active March 16, 2022 02:17
A hierarchy change listener which recursively monitors and entire tree of views. Apache 2.
import android.view.View;
import android.view.ViewGroup;
/**
* A {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} which recursively
* monitors an entire tree of views.
*/
public final class HierarchyTreeChangeListener implements ViewGroup.OnHierarchyChangeListener {
/**
* Wrap a regular {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} with one
@briangriffey
briangriffey / CircularDrawable.java
Last active December 25, 2015 20:29
Use this drawable to to create a circular image like the one found here: https://www.evernote.com/shard/s36/sh/9f22cbd4-9e01-4f7a-9125-2470c4f21e6c/be052171b03a4ad8dc308560971c5944 with any bitmap.
package com.sceneTap.views;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
@gabrielemariotti
gabrielemariotti / build.gradle
Last active January 12, 2024 17:41
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@orip
orip / build.gradle
Last active April 19, 2016 11:56
ProGuard rules for using Dagger 1.1.0 with gradle.
dependencies {
def dagger_version = "1.1.0"
compile "com.squareup.dagger:dagger:${dagger_version}"
compile "com.squareup.dagger:dagger-compiler:${dagger_version}"
}
@commonsguy
commonsguy / gif2animdraw
Last active May 1, 2023 14:26
Ruby script to convert animated GIF into an Android AnimationDrawable
#!/usr/bin/ruby
require 'fileutils'
require 'RMagick'
require 'slop'
require 'builder'
opts = Slop.new do
banner "gif2animdraw [options]\n"
on :i, :input=, 'path to animated GIF (or directory of GIFs)', :required => true
on :o, :outdir=, 'path to root output directory', :required => true
@aprock
aprock / RoundedTransformation.java
Created August 12, 2013 18:08
Rounded Corner Image Transformation for square's Picasso
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
// enables hardware accelerated rounded corners
// original idea here : http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/
@tyvsmith
tyvsmith / App.java
Last active October 26, 2018 19:15
If you have multiple Android apps that need to report to the same Crashlytics app endpoint. This allows overriding the package name that Crashlytics discovers and reports.
public class MyApp extends Application {
private final String PACKAGE="me.tysmith.app";
@Override
public void onCreate() {
super.onCreate();
Crashlytics.start(new CrashContextWrapper(this, PACKAGE));
}
}
@tyvsmith
tyvsmith / dex-count.sh
Created July 22, 2013 18:45
"`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH." Use this to keep track of methods and fields in your apk. They are both limited to 65536. Example use: $ source dex-count.sh; $ dex-field-count classes.dex; Original method scrip…
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)