This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the below is command line output generated from the (further below) main method | |
Factorial of '31' is '738197504' | |
Factorial of '10' is '3628800' | |
Factorial of '5' is '120' | |
Factorial of '4' is '24' | |
Factorial of '3' is '6' | |
Factorial of '2' is '2' | |
Factorial of '1' is '1' | |
Factorial of '0' is '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected AsyncTaskResult<String> doInBackground(User... users) { | |
int userCount = users.length; | |
if(apiService == null) { // Only do this once | |
UserApi.Builder builder = new UserApi.Builder(AndroidHttp.newCompatibleTransport(), | |
new AndroidJsonFactory(), null) | |
// options for running against local devappserver | |
.setRootUrl("http://" + ServerUtil.getHost() + ":8080/_ah/api/"); | |
//turn off compression when running against local devappserver | |
Utility.compressTrafficIfNecessary(builder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BaseButton(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
TypedArray a = context.getTheme().obtainStyledAttributes( | |
attrs, | |
R.styleable.MaterialButton, | |
0, 0); | |
try { | |
colorButtonNormal = a.getInteger(R.styleable.MaterialButton_mbColorButtonNormal, Color.CYAN); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomePresenter extends BasePresenter<HomeView> { | |
ArticleRepo articleRepo; | |
@Inject | |
public HomePresenter(ArticleRepo articleRepo) { | |
this.articleRepo = articleRepo; | |
} | |
@Override | |
public void onCreate(@Nullable PresenterBundle bundle) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Integer> coolList = new ArrayList<Integer>(); | |
coolList.add(1); | |
coolList.add(2); | |
coolList.add(3); | |
Observable.from(coolList).map(new Func1<Integer, Long>() { | |
@Override | |
public Long call(Integer integer) { | |
//runs on the IO background thread because we specify `Schedulers.io()` | |
return integer * 10000000000L; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A repository to store someone's favorite color. | |
*/ | |
public interface FavoriteColorRepo { | |
/** | |
* Loads the user's favorite color. | |
* @return ex- "blue" | |
*/ | |
public Observable<String> getFavoriteColor(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handles getting a user. | |
*/ | |
public interface UserModel { | |
/** | |
* @return the currently logged in user, or null if the user is not logged in | |
*/ | |
Single<User> getUser(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build.gradle for "server" module | |
buildscript { | |
repositories { | |
maven { | |
url "https://plugins.gradle.org/m2/" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A reactive map implementation that allows you to observe a key and its value. | |
*/ | |
class RxMap<K, V>( | |
private val map: AbstractMap<K, V> = HashMap(), | |
private val rxMap: AbstractMap<K, Relay<V, V>> = HashMap() | |
) : Map<K, V> { | |
/** | |
* @return a hot observable that emits the value for the specified key. When you subscribe, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Observe the activity events! | |
*/ | |
class RxActivityDelegate : RxActivity { | |
private val relay = BehaviorRelay.create<ActivityLifecycleEvent>().toSerialized() | |
fun onCreate() { | |
relay.call(CREATE) | |
log("onCreate") |
OlderNewer