Skip to content

Instantly share code, notes, and snippets.

View MichaelHackett's full-sized avatar

Michael Hackett MichaelHackett

  • Halifax, NS, Canada
View GitHub Profile
@MichaelHackett
MichaelHackett / ListPaddingDecoration.java
Created May 31, 2019 15:27 — forked from vincetreur/ListPaddingDecoration.java
A RecyclerView.ItemDecoration that adds 8 dp padding to the top of the first and bottom of the last item in a list (or RecyclerView in this case).
import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
/**
* Adds 8dp padding to the top of the first and the bottom of the last item in the list,
@MichaelHackett
MichaelHackett / NSMutableArray+Indexing.m
Created March 18, 2014 16:06
Implementation of NSArray shorthand subscripting as found in iOS 6 / OS X 10.8. (Not tested.)
@implementation NSMutableArray (Indexing)
- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index
{
if (index == [self count]) {
[self addObject:object];
} else {
[self replaceObjectAtIndex:index withObject:object];
}
}