Skip to content

Instantly share code, notes, and snippets.

@NickPontiff
NickPontiff / IndexableRecyclerView.java
Created August 13, 2015 16:20
This class is a RecyclerView capable of having and indexable scroll.
public class IndexableRecyclerView extends RecyclerView implements ListIndexer.SectionCallback {
private ListIndexer indexer = null;
public IndexableRecyclerView(Context context) {
super(context);
init();
}
public IndexableRecyclerView(Context context, AttributeSet attrs) {
@NickPontiff
NickPontiff / ListIndexer.java
Created August 13, 2015 16:18
This class is draw a bar containing the alphabet and determine which section a touch event has landed on.
public class ListIndexer {
public static String[] ALPHABET = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
private Paint paint;
private float height;
private float width;
@NickPontiff
NickPontiff / PostBorderDrawable.java
Last active September 15, 2015 22:09
In an effort to make views in our RecyclerView as flat as possible, we removed the need to have nested ViewGroups with backgrounds for padding/borders. Instead, all list items are 1 ViewGroup, with borders and background painted underneath content.
/**
* @author npontiff
* @since 5/20/2015
* <p/>
* This class is used as a utility draw the backgrounds and borders underneath a {@link com.gotchosen.socialexchange.ui.recyclerviews.partdefinitions.PartDefinition}
*/
public class PostBorderDrawable extends Drawable {
@Inject
@NickPontiff
NickPontiff / VoteCountView.java
Last active August 29, 2015 14:27
This class is a view that was used to display a vote count. When the number of characters that represent the vote count is small (i.e "1") then the background should be displayed as a circle. However, as the vote count grows to a larger number (i.e. "5260"), the background must grow, in the shape of a pill.
public class VoteCountView extends View {
//color constants
private static final @ColorRes int INACTIVE_BACKGROUND_COLOR = R.color.got_chosen_vote_gray;
private static final @ColorRes int ACTIVE_BACKGROUND_COLOR = R.color.got_chosen_blue;
private static final @ColorRes int DEFAULT_TEXT_COLOR = R.color.divider_color;
//Paint objects
private Paint mTextPaint;
private Paint mBackgroundRectPaint;
@NickPontiff
NickPontiff / .bash_profile
Created July 10, 2015 15:45
Sample environment setup for Android development.
# android path
export ANDROID_SDK_ROOT=/Users/nicholaspontiff/Documents/Dev/Android/SDK/android-sdk-macosx/
export ANDROID_NDK_ROOT=/Users/nicholaspontiff/Documents/Dev/Android/NDK/android-ndk-r10e/
export PATH=${PATH}:${ANDROID_SDK_ROOT}:${ANDROID_SDK_ROOT}platform-tools/:${ANDROID_NDK_ROOT}