Skip to content

Instantly share code, notes, and snippets.

View jpardogo's full-sized avatar
:octocat:

JPARDOGO jpardogo

:octocat:
View GitHub Profile
package com.facebook.rebound.origami;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
package com.homeaway.floatlabel.library;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
@regisd
regisd / AndroidUtils.java
Created February 8, 2012 21:06
Intent to open the twitter client
public Intent findTwitterClient() {
final String[] twitterApps = {
// package // name - nb installs (thousands)
"com.twitter.android", // official - 10 000
"com.twidroid", // twidroyd - 5 000
"com.handmark.tweetcaster", // Tweecaster - 5 000
"com.thedeck.android" // TweetDeck - 5 000 };
Intent tweetIntent = new Intent();
tweetIntent.setType("text/plain");
final PackageManager packageManager = getPackageManager();
@slightfoot
slightfoot / AddFragment.java
Created May 16, 2014 22:02
Example of https://gist.github.com/devunwired/ccc6487a1e3fed9c79e0 except uses Animation instances for compatibility with the support-v4 library.
public void addFragment(Fragment frag)
{
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(
R.anim.slide_in_right, R.anim.slide_out_left,
R.anim.slide_in_left, R.anim.slide_out_right)
.replace(R.id.content_frame, frag)
.addToBackStack(null)
.commit();
}
@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;
@briangriffey
briangriffey / CuttingOffTextView.java
Created November 13, 2013 22:14
Makes sure text doesn't go beyond the boundaries of its measured height and adjusts itself to the maximum appropriate lines.
package com.vice.viceforandroid.views;
import android.content.Context;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* Created by briangriffey on 11/13/13.
@mttkay
mttkay / gist:3851440
Created October 8, 2012 08:40
Testing if an Android app is installed on the SD card
private boolean isAppInstalledToSDCard(Context context) {
PackageManager pm = context.getPackageManager();
try {
int extStorage = ApplicationInfo.FLAG_EXTERNAL_STORAGE;
String package = context.getPackageName();
ApplicationInfo appInfo = pm.getApplicationInfo(package, extStorage);
return extStorage == (extStorage & appInfo.flags);
} catch (NameNotFoundException e) {
e.printStackTrace();
return false;
@brocoo
brocoo / Swift NSNotification extension
Last active May 13, 2016 09:51
Extension of NSNotification to use a key enum as the notification name.
public enum NotificationKey: String {
case UserSignedIn = "UserSignedInNotification"
case UserSignedOut = "UserSignedOutNotification"
case SomeOtherEvent = "SomeOtherEventNotification"
}
extension NSNotificationCenter {
func addObserver(observer: AnyObject, selector aSelector: Selector, key aKey: NotificationKey) {
self.addObserver(observer, selector: aSelector, name: aKey.rawValue, object: nil)

Make your multiple type view adapter with annotations!

Gist for Making a Multiple View Types Adapter With Annotations

Pretty easy to use.

  1. Create your delegate adapters, implementing DelegateAdapter, and with the annotation DelegateAdapterType. e.g:
@DelegateAdapterType(itemType = 0)
@cnnrhill
cnnrhill / ListViewScrollTracker.java
Created September 24, 2013 04:24
Helper class for calculating relative scroll offsets in a ListView or GridView by tracking the position of child views.
import android.util.SparseArray;
import android.widget.AbsListView;
/**
* Helper class for calculating relative scroll offsets in a ListView or GridView by tracking the
* position of child views.
*/
public class ListViewScrollTracker {
private AbsListView mListView;
private SparseArray<Integer> mPositions;