Skip to content

Instantly share code, notes, and snippets.

View robotrory's full-sized avatar

Rory Smith robotrory

View GitHub Profile
@robotrory
robotrory / ImageAdapter
Created May 25, 2015 13:56
An ImageAdapter that takes in a directory of image files, loops through them and displays them in ImageViews
public class ImageAdapter extends BaseAdapter {
private Context mContext;
private File[] filesArray;
public ImageAdapter(Context c, File dir) {
mContext = c;
//get the contents of the directory that you pass in through the constructor
filesArray = new dir.listFiles();
}
@robotrory
robotrory / MediaSessionHelper
Last active August 29, 2015 14:18
A helper class to apply playback states to MediaSessions, applying the transport controls too, which seems to be broken in the latest Android Support library.
import android.media.RemoteControlClient;
import android.os.Build;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
public class MediaSessionHelper {
public static void applyState(MediaSessionCompat session, PlaybackStateCompat playbackState) {
session.setPlaybackState(playbackState);