GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: remove silly comment style helpers · linuxgg/RxJava-Android-Samples@5585bba

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main/java/com/morihacky/android/rxjava/pagination
    • PaginationAutoFragment.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java
+32-31Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,38 @@ public void onStart() {
6565
super.onStart();
6666
_subscriptions = new CompositeSubscription();
6767

68-
Subscription s2 =//
69-
_paginator.onBackpressureDrop()
70-
.doOnNext(i -> {
71-
_requestUnderWay = true;
72-
_progressBar.setVisibility(View.VISIBLE);
73-
})
74-
.concatMap(this::_itemsFromNetworkCall)
75-
.observeOn(AndroidSchedulers.mainThread())
76-
.map(items -> {
77-
_adapter.addItems(items);
78-
_adapter.notifyDataSetChanged();
79-
return null;
80-
})
81-
.doOnNext(i -> {
82-
_requestUnderWay = false;
83-
_progressBar.setVisibility(View.INVISIBLE);
84-
})
85-
.subscribe();
68+
Subscription s2 = _paginator
69+
.onBackpressureDrop()
70+
.doOnNext(i -> {
71+
_requestUnderWay = true;
72+
_progressBar.setVisibility(View.VISIBLE);
73+
})
74+
.concatMap(this::_itemsFromNetworkCall)
75+
.observeOn(AndroidSchedulers.mainThread())
76+
.map(items -> {
77+
_adapter.addItems(items);
78+
_adapter.notifyDataSetChanged();
79+
return null;
80+
})
81+
.doOnNext(i -> {
82+
_requestUnderWay = false;
83+
_progressBar.setVisibility(View.INVISIBLE);
84+
})
85+
.subscribe();
8686

8787
// I'm using an RxBus purely to hear from a nested button click
8888
// we don't really need Rx for this part. it's just easy ¯\_(ツ)_/¯
89-
Subscription s1 =//
90-
_bus.asObservable()//
91-
.filter(o -> !_requestUnderWay)//
92-
.subscribe(event -> {
93-
if (event instanceof PaginationAutoAdapter.PageEvent) {
94-
95-
// trigger the paginator for the next event
96-
int nextPage = _adapter.getItemCount();
97-
_paginator.onNext(nextPage);
98-
}
99-
});
89+
Subscription s1 = _bus
90+
.asObservable()
91+
.filter(o -> !_requestUnderWay)
92+
.subscribe(event -> {
93+
if (event instanceof PaginationAutoAdapter.PageEvent) {
94+
95+
// trigger the paginator for the next event
96+
int nextPage = _adapter.getItemCount();
97+
_paginator.onNext(nextPage);
98+
}
99+
});
100100

101101
_subscriptions.add(s1);
102102
_subscriptions.add(s2);
@@ -114,8 +114,9 @@ public void onStop() {
114114
* Fake Observable that simulates a network call and then sends down a list of items
115115
*/
116116
private Observable<List<String>> _itemsFromNetworkCall(int pageStart) {
117-
return Observable.just(true)//
118-
.observeOn(AndroidSchedulers.mainThread())//
117+
return Observable
118+
.just(true)
119+
.observeOn(AndroidSchedulers.mainThread())
119120
.delay(2, TimeUnit.SECONDS)
120121
.map(dummy -> {
121122
List<String> items = new ArrayList<>();

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.