Search in sources :

Example 1 with GithubApi

use of com.morihacky.android.rxjava.retrofit.GithubApi in project RxJava-Android-Samples by kaushikgopal.

the class PseudoCacheMergeFragment method _getFreshData.

private Observable<Pair<Contributor, Long>> _getFreshData() {
    String githubToken = getResources().getString(R.string.github_oauth_token);
    GithubApi githubService = GithubService.createGithubService(githubToken);
    return githubService.contributors("square", "retrofit").flatMap(Observable::fromIterable).map(contributor -> new Pair<>(contributor, System.currentTimeMillis()));
}
Also used : GithubApi(com.morihacky.android.rxjava.retrofit.GithubApi)

Example 2 with GithubApi

use of com.morihacky.android.rxjava.retrofit.GithubApi in project RxJava-Android-Samples by kaushikgopal.

the class PseudoCacheFragment method getFreshNetworkData.

private Observable<Contributor> getFreshNetworkData() {
    String githubToken = getResources().getString(R.string.github_oauth_token);
    GithubApi githubService = GithubService.createGithubService(githubToken);
    return githubService.contributors("square", "retrofit").flatMap(Observable::fromIterable).doOnSubscribe((data) -> //
    new Handler(Looper.getMainLooper()).post(//
    () -> adapterSubscriptionInfo.add("(network) subscribed"))).doOnComplete(() -> //
    new Handler(Looper.getMainLooper()).post(() -> adapterSubscriptionInfo.add("(network) completed")));
}
Also used : Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) HashMap(java.util.HashMap) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) R(com.morihacky.android.rxjava.R) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) Handler(android.os.Handler) Looper(android.os.Looper) Map(java.util.Map) View(android.view.View) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) Unbinder(butterknife.Unbinder) Contributor(com.morihacky.android.rxjava.retrofit.Contributor) GithubApi(com.morihacky.android.rxjava.retrofit.GithubApi) LayoutInflater(android.view.LayoutInflater) GithubService(com.morihacky.android.rxjava.retrofit.GithubService) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) TimeUnit(java.util.concurrent.TimeUnit) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) TextView(android.widget.TextView) DisposableObserver(io.reactivex.observers.DisposableObserver) ListView(android.widget.ListView) Nullable(android.support.annotation.Nullable) GithubApi(com.morihacky.android.rxjava.retrofit.GithubApi) Handler(android.os.Handler) Observable(io.reactivex.Observable)

Aggregations

GithubApi (com.morihacky.android.rxjava.retrofit.GithubApi)2 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Nullable (android.support.annotation.Nullable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 OnClick (butterknife.OnClick)1 Unbinder (butterknife.Unbinder)1 R (com.morihacky.android.rxjava.R)1 Contributor (com.morihacky.android.rxjava.retrofit.Contributor)1 GithubService (com.morihacky.android.rxjava.retrofit.GithubService)1 Observable (io.reactivex.Observable)1 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)1