Skip to content

Instantly share code, notes, and snippets.

View billy-bacon's full-sized avatar

Billy Bacon billy-bacon

View GitHub Profile
@Override
public void setMediaPlayer(final MediaPlayerControl player) {
Log.d(TAG, "setMediaPlayer called with " + player);
super.setMediaPlayer(new MediaPlayerControl() {
@Override
public void start() {
player.start();
}
private MediaController getMediaController() {
MediaController mediaController = new MediaController(this, false) {
@Override
public void hide() {
super.hide();
onMediaControllerHide();
}
@Override
@Override
public MediaController getMediaController(Context context) {
MediaController mediaController = new MediaController(context) {
@Override
public void setMediaPlayer(MediaPlayerControl player) {
super.setMediaPlayer(player);
//todo: this causes things to blow up since the Activity is not initialized yet when this is called?
//show(0);
}
// this is the service that plays the audio
private ServiceConnection audioServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName componentName, IBinder binder) {
mediaController = getMediaController(view.getApplicationContext());
Log.d(TAG, "audio service connected");
//noinspection unchecked
audioService = ((SimpleBinder<AudioService>) binder).getService();
@Override
protected PlaylistInfo doInBackground(AudioTrack... params) {
// pull the track out of the single element array...
final AudioTrack audioTrack = params[0];
// get the content and segment index
final Content content = audioTrack.getContent();
final int segment = audioTrack.getSegment();
@Override
protected PlaylistInfo doInBackground(AudioTrack... params) {
// pull the track out of the single element array...
final AudioTrack audioTrack = params[0];
// get the content and segment index
final Content content = audioTrack.getContent();
final int segment = audioTrack.getSegment();
var carousel_${carouselName} = $('#${carouselName}').bxSlider({
minSlides: 7,
maxSlides: 7,
slideWidth: 120,
slideMargin: 10,
pager: false,
infiniteLoop: false,
controls: true,
onSlideNext: function(){
@billy-bacon
billy-bacon / BaseModule.java
Created October 9, 2013 20:35
Guice Names.bindProperties
public void bindProperties(Binder binder, String propertiesFile) {
log.info("binding {}", propertiesFile);
try {
final Properties props = new Properties();
props.load(this.getClass().getClassLoader().getResourceAsStream(propertiesFile));
Names.bindProperties(binder, props);
} catch (IOException e) {
throw new RuntimeException("Could not load " + propertiesFile, e);
}
@Test
public void should_throw_exception_for_configure() throws Exception {
// setup test
module = new AWSModule();
final Binder binder = mock(Binder.class);
when(binder.skipSources(any(Class.class))).thenThrow(new IOException("WTF"));
try {
module.configure(binder);
@billy-bacon
billy-bacon / KindService.java
Created October 22, 2013 22:11
KindService with static cache
public class KindService extends BaseCacheService {
public static final String LIST = "/browse/kinds/list";
private Logger log = LoggerFactory.getLogger(KindService.class);
static List<Kind> cachedList;
@Inject
public KindService(CacheWrapper<String, Object> cache,
HttpExecutor httpExecutor,