Skip to content

Instantly share code, notes, and snippets.

View stephanenicolas's full-sized avatar

Stéphane Nicolas stephanenicolas

View GitHub Profile
@stephanenicolas
stephanenicolas / MainActivity.java
Created September 26, 2017 23:10
Good Old Way: MainActivity
public static class MainActivity extends Activity
implements HeadlinesFragment.HeadlineListener{
...
public void onArticleSelected(int position) {
// The user selected the headline of an article from the HeadlinesFragment
// Do something here to display that article
}
}
@stephanenicolas
stephanenicolas / Main.java
Last active May 6, 2017 07:23
Updates an adapter concurrently using Rx-managed Redux
import io.reactivex.Maybe;
import io.reactivex.MaybeSource;
import io.reactivex.Observable;
import io.reactivex.ObservableTransformer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.subjects.BehaviorSubject;
import java.util.ArrayList;
import java.util.Arrays;
@stephanenicolas
stephanenicolas / gist:8511492
Created January 19, 2014 21:55
ViewListener that filters listened classes.
/*
* Copyright 2009 Michael Burton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Override
public void onActivityCreated( Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
mainActivity = (MainActivity) getActivity();
buttonStart.setOnClickListener( new OnClickListener() {
@Override
public void onClick( View v ) {
onStart( v );
}