In this section, we are going to show a few examples based on RxJava's just()
, repeat()
, defer()
, range()
, interval()
, and timer()
methods.
Let's assume we only have three separated AppInfo
objects and we want to convert them into an Observable and populate our RecyclerView
item:
List<AppInfo> apps = ApplicationsList.getInstance().getList(); AppInfo appOne = apps.get(0); AppInfo appTwo = apps.get(10); AppInfo appThree = apps.get(24); loadApps(appOne, appTwo, appThree);
We can retrieve the list like we did in the previous example and extract only three elements. Then, we pass them to the loadApps()
function:
private void loadApps(AppInfo appOne, AppInfo appTwo, AppInfo appThree) { mRecyclerView.setVisibility(View.VISIBLE); Observable.just(appOne, appTwo, appThree) .subscribe(new Observer<AppInfo>() { @Override public void onCompleted() { mSwipeRefreshLayout.setRefreshing(false)...