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 — chore: merge changes · anggit97/RxJava-Android-Samples@0f498c8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • README.md
  • app
    • build.gradle
    • src/main
      • java/com/morihacky/android/rxjava
        • MainActivity.java
        • MyApp.java
        • fragments
          • BaseFragment.java
          • BufferDemoFragment.java
          • ConcurrencyWithSchedulersDemoFragment.java
          • DebounceSearchEmitterFragment.java
          • DoubleBindingTextViewFragment.java
          • ExponentialBackoffFragment.java
          • FormValidationCombineLatestFragment.java
          • MainFragment.java
          • NetworkDetectorFragment.java
          • PollingFragment.java
          • PseudoCacheFragment.java
          • PseudoCacheMergeFragment.java
          • RetrofitAsyncTaskDeathFragment.java
          • RetrofitFragment.java
          • RotationPersist1Fragment.java
          • RotationPersist1WorkerFragment.java
          • RotationPersist2Fragment.java
          • RotationPersist2WorkerFragment.java
          • TimeoutDemoFragment.java
          • TimingDemoFragment.java
        • pagination
          • PaginationAdapter.java
          • PaginationAutoAdapter.java
          • PaginationAutoFragment.java
          • PaginationFragment.java
        • retrofit
          • Contributor.java
          • GithubApi.java
          • GithubService.java
          • User.java
        • rxbus
          • RxBus.java
          • RxBusDemoFragment.java
          • RxBusDemo_Bottom1Fragment.java
          • RxBusDemo_Bottom2Fragment.java
          • RxBusDemo_Bottom3Fragment.java
          • RxBusDemo_TopFragment.java
        • volley
          • MyVolley.java
          • VolleyDemoFragment.java
        • wiring
          • LogAdapter.java
      • res
        • layout
          • fragment_buffer.xml
          • fragment_concurrency_schedulers.xml
          • fragment_debounce.xml
          • fragment_demo_timing.xml
          • fragment_double_binding_textview.xml
          • fragment_exponential_backoff.xml
          • fragment_form_validation_comb_latest.xml
          • fragment_main.xml
          • fragment_network_detector.xml
          • fragment_pagination.xml
          • fragment_polling.xml
          • fragment_pseudo_cache.xml
          • fragment_pseudo_cache_concat.xml
          • fragment_retrofit.xml
          • fragment_retrofit_async_task_death.xml
          • fragment_rotation_persist.xml
          • fragment_rxbus_bottom.xml
          • fragment_rxbus_demo.xml
          • fragment_subject_timeout.xml
          • fragment_timer_demo.xml
          • fragment_volley.xml
          • item_btn.xml
          • item_log.xml
          • item_log_white.xml
        • values
          • strings.xml
  • build.gradle
  • gradlew.bat
  • gradlew
  • gradle/wrapper
    • gradle-wrapper.jar
    • gradle-wrapper.properties

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ buck-out/
2222
.buckd/
2323

2424
# Intellij project files
25+
.idea/
2526
.idea/libraries
2627
.idea/.name
2728
.idea/compiler.xml
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+17-16Lines changed: 17 additions & 16 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ I've also been giving talks about Learning Rx using many of the examples listed
1010

1111
## Examples:
1212

13-
1. [Background work & concurrency (using Schedulers)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#1-background-work--concurrency-using-schedulers)
14-
2. [Accumulate calls (using buffer)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#2-accumulate-calls-using-buffer)
15-
3. [Instant/Auto searching text listeners (using Subjects & debounce)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#3-instantauto-searching-text-listeners-using-subjects--debounce)
16-
4. [Networking with Retrofit & RxJava (using zip, flatmap)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#4-networking-with-retrofit--rxjava-using-zip-flatmap)
17-
5. [Two-way data binding for TextViews (using PublishSubject)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#5-two-way-data-binding-for-textviews-using-publishsubject)
18-
6. [Simple and Advanced polling (using interval and repeatWhen)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#6-simple-and-advanced-polling-using-interval-and-repeatwhen)
19-
7. [Simple and Advanced exponential backoff (using delay and retryWhen)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#7-simple-and-advanced-exponential-backoff-using-delay-and-retrywhen)
20-
8. [Form validation (using combineLatest)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#8-form-validation-using-combinelatest)
21-
9. [Pseudo caching : retrieve data first from a cache, then a network call (using concat, concatEager, merge or publish)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#9-pseudo-caching--retrieve-data-first-from-a-cache-then-a-network-call-using-concat-concateager-merge-or-publish)
22-
10. [Simple timing demos (using timer, interval or delay)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#10-simple-timing-demos-using-timer-interval-and-delay)
23-
11. [RxBus : event bus using RxJava (using RxRelay (never terminating Subjects) and debouncedBuffer)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#11-rxbus--event-bus-using-rxjava-using-rxrelay-never-terminating-subjects-and-debouncedbuffer)
24-
12. [Persist data on Activity rotations (using Subjects and retained Fragments)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#12-persist-data-on-activity-rotations-using-subjects-and-retained-fragments)
25-
13. [Networking with Volley](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#13-networking-with-volley)
26-
14. [Pagination with Rx (using Subjects)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#14-pagination-with-rx-using-subjects)
27-
15. [Orchestrating Observable: make parallel network calls, then combine the result into a single data point (using flatmap & zip)](https://github.com/kaushikgopal/RxJava-Android-Samples/blob/master/README.md#15-orchestrating-observable-make-parallel-network-calls-then-combine-the-result-into-a-single-data-point-using-flatmap--zip)
28-
16. [Simple Timeout example (using timeout)]()
13+
1. [Background work & concurrency (using Schedulers)](#1-background-work--concurrency-using-schedulers)
14+
2. [Accumulate calls (using buffer)](#2-accumulate-calls-using-buffer)
15+
3. [Instant/Auto searching text listeners (using Subjects & debounce)](#3-instantauto-searching-text-listeners-using-subjects--debounce)
16+
4. [Networking with Retrofit & RxJava (using zip, flatmap)](#4-networking-with-retrofit--rxjava-using-zip-flatmap)
17+
5. [Two-way data binding for TextViews (using PublishSubject)](#5-two-way-data-binding-for-textviews-using-publishsubject)
18+
6. [Simple and Advanced polling (using interval and repeatWhen)](#6-simple-and-advanced-polling-using-interval-and-repeatwhen)
19+
7. [Simple and Advanced exponential backoff (using delay and retryWhen)](#7-simple-and-advanced-exponential-backoff-using-delay-and-retrywhen)
20+
8. [Form validation (using combineLatest)](#8-form-validation-using-combinelatest)
21+
9. [Pseudo caching : retrieve data first from a cache, then a network call (using concat, concatEager, merge or publish)](#9-pseudo-caching--retrieve-data-first-from-a-cache-then-a-network-call-using-concat-concateager-merge-or-publish)
22+
10. [Simple timing demos (using timer, interval or delay)](#10-simple-timing-demos-using-timer-interval-and-delay)
23+
11. [RxBus : event bus using RxJava (using RxRelay (never terminating Subjects) and debouncedBuffer)](#11-rxbus--event-bus-using-rxjava-using-rxrelay-never-terminating-subjects-and-debouncedbuffer)
24+
12. [Persist data on Activity rotations (using Subjects and retained Fragments)](#12-persist-data-on-activity-rotations-using-subjects-and-retained-fragments)
25+
13. [Networking with Volley](#13-networking-with-volley)
26+
14. [Pagination with Rx (using Subjects)](#14-pagination-with-rx-using-subjects)
27+
15. [Orchestrating Observable: make parallel network calls, then combine the result into a single data point (using flatmap & zip)](#15-orchestrating-observable-make-parallel-network-calls-then-combine-the-result-into-a-single-data-point-using-flatmap--zip)
28+
16. [Simple Timeout example (using timeout)](#16-simple-timeout-example-using-timeout)
2929

3030
## Description
3131

@@ -100,6 +100,7 @@ We simulate this behaviour using RxJava with the [`retryWhen` operator](http://r
100100

101101
* http://stackoverflow.com/a/25292833/159825
102102
* Another excellent implementation via @[sddamico](https://github.com/sddamico) : https://gist.github.com/sddamico/c45d7cdabc41e663bea1
103+
* This one includes support for jittering, by @[leandrofavarin](https://github.com/leandrofavarin) : http://leandrofavarin.com/exponential-backoff-rxjava-operator-with-jitter
103104

104105
Also look at the [Polling example](https://github.com/kaushikgopal/RxJava-Android-Samples#polling-with-schedulers) where we use a very similar Exponential backoff mechanism.
105106

Collapse file

‎app/build.gradle‎

Copy file name to clipboardExpand all lines: app/build.gradle
+8-16Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ buildscript {
44
jcenter()
55
}
66
dependencies {
7-
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
8-
// can be removed with android-gradle plugin is upgraded to 2.2
9-
// https://twitter.com/JakeWharton/status/760836175586267136
10-
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
7+
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
118
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
129
}
1310

@@ -17,6 +14,7 @@ buildscript {
1714

1815
apply plugin: 'com.android.application'
1916
apply plugin: 'me.tatarka.retrolambda'
17+
apply plugin: 'com.f2prateek.javafmt'
2018
apply plugin: 'kotlin-android'
2119

2220
dependencies {
@@ -25,8 +23,9 @@ dependencies {
2523
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
2624

2725
compile 'com.github.kaushikgopal:CoreTextUtils:c703fa12b6'
28-
compile 'com.jakewharton:butterknife:7.0.1'
29-
compile 'com.jakewharton.timber:timber:2.4.2'
26+
compile "com.jakewharton:butterknife:${butterKnifeVersion}"
27+
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
28+
compile 'com.jakewharton.timber:timber:4.5.1'
3029
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
3130
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
3231
compile "com.squareup.okhttp3:okhttp:${okhttpVersion}"
@@ -39,18 +38,15 @@ dependencies {
3938
// ----------------------------------
4039
// Rx dependencies
4140

42-
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
41+
compile 'io.reactivex.rxjava2:rxjava:2.0.7'
4342

4443
// Because RxAndroid releases are few and far between, it is recommended you also
4544
// explicitly depend on RxJava's latest version for bug fixes and new features.
4645
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
4746

48-
// libs like rxbinding + rxjava-math haven't been ported to RxJava 2.x yet, so this helps
49-
compile "com.github.akarnokd:rxjava2-interop:0.6.1"
50-
51-
compile 'io.reactivex:rxjava-math:1.0.0'
47+
compile "com.github.akarnokd:rxjava2-extensions:0.16.0"
5248
compile 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
53-
compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
49+
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
5450
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
5551

5652
// ----------------------------------
@@ -70,23 +66,19 @@ android {
7066
versionCode 2
7167
versionName "1.2"
7268
}
73-
7469
buildTypes {
7570
release {
7671
minifyEnabled true
7772
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7873
}
7974
}
80-
8175
sourceSets {
8276
main.java.srcDirs += 'src/main/kotlin'
8377
}
84-
8578
compileOptions {
8679
sourceCompatibility JavaVersion.VERSION_1_8
8780
targetCompatibility JavaVersion.VERSION_1_8
8881
}
89-
9082
packagingOptions {
9183
pickFirst 'META-INF/rxjava.properties'
9284
}
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/MainActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/MainActivity.java
+38-40Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,58 @@
22

33
import android.os.Bundle;
44
import android.support.v4.app.Fragment;
5-
import android.support.v4.app.FragmentActivity;
5+
import android.support.v7.app.AppCompatActivity;
66
import com.morihacky.android.rxjava.fragments.MainFragment;
77
import com.morihacky.android.rxjava.fragments.RotationPersist1WorkerFragment;
88
import com.morihacky.android.rxjava.fragments.RotationPersist2WorkerFragment;
99
import com.morihacky.android.rxjava.rxbus.RxBus;
1010

11-
public class MainActivity
12-
extends FragmentActivity {
11+
public class MainActivity extends AppCompatActivity {
1312

14-
private RxBus _rxBus = null;
13+
private RxBus _rxBus = null;
1514

16-
@Override
17-
public void onBackPressed() {
18-
super.onBackPressed();
19-
_removeWorkerFragments();
20-
}
15+
@Override
16+
public void onBackPressed() {
17+
super.onBackPressed();
18+
_removeWorkerFragments();
19+
}
2120

22-
@Override
23-
protected void onCreate(Bundle savedInstanceState) {
24-
super.onCreate(savedInstanceState);
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
2524

26-
if (savedInstanceState == null) {
27-
getSupportFragmentManager().beginTransaction()
28-
.replace(android.R.id.content, new MainFragment(), this.toString())
29-
.commit();
30-
}
25+
if (savedInstanceState == null) {
26+
getSupportFragmentManager()
27+
.beginTransaction()
28+
.replace(android.R.id.content, new MainFragment(), this.toString())
29+
.commit();
3130
}
31+
}
3232

33-
// This is better done with a DI Library like Dagger
34-
public RxBus getRxBusSingleton() {
35-
if (_rxBus == null) {
36-
_rxBus = new RxBus();
37-
}
38-
39-
return _rxBus;
33+
// This is better done with a DI Library like Dagger
34+
public RxBus getRxBusSingleton() {
35+
if (_rxBus == null) {
36+
_rxBus = new RxBus();
4037
}
4138

42-
private void _removeWorkerFragments() {
43-
Fragment frag = getSupportFragmentManager().findFragmentByTag(RotationPersist1WorkerFragment.class.getName());
39+
return _rxBus;
40+
}
4441

45-
if (frag != null) {
46-
getSupportFragmentManager()
47-
.beginTransaction()
48-
.remove(frag)
49-
.commit();
50-
}
42+
private void _removeWorkerFragments() {
43+
Fragment frag =
44+
getSupportFragmentManager()
45+
.findFragmentByTag(RotationPersist1WorkerFragment.class.getName());
46+
47+
if (frag != null) {
48+
getSupportFragmentManager().beginTransaction().remove(frag).commit();
49+
}
5150

52-
frag = getSupportFragmentManager().findFragmentByTag(RotationPersist2WorkerFragment.class.getName());
51+
frag =
52+
getSupportFragmentManager()
53+
.findFragmentByTag(RotationPersist2WorkerFragment.class.getName());
5354

54-
if (frag != null) {
55-
getSupportFragmentManager()
56-
.beginTransaction()
57-
.remove(frag)
58-
.commit();
59-
}
55+
if (frag != null) {
56+
getSupportFragmentManager().beginTransaction().remove(frag).commit();
6057
}
61-
}
58+
}
59+
}
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/MyApp.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/MyApp.java
+26-21Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@
66
import com.squareup.leakcanary.RefWatcher;
77
import timber.log.Timber;
88

9-
public class MyApp
10-
extends Application {
9+
public class MyApp extends Application {
1110

12-
private static MyApp _instance;
13-
private RefWatcher _refWatcher;
11+
private static MyApp _instance;
12+
private RefWatcher _refWatcher;
1413

15-
public static MyApp get() {
16-
return _instance;
17-
}
14+
public static MyApp get() {
15+
return _instance;
16+
}
1817

19-
public static RefWatcher getRefWatcher() {
20-
return MyApp.get()._refWatcher;
21-
}
18+
public static RefWatcher getRefWatcher() {
19+
return MyApp.get()._refWatcher;
20+
}
2221

23-
@Override
24-
public void onCreate() {
25-
super.onCreate();
22+
@Override
23+
public void onCreate() {
24+
super.onCreate();
2625

27-
_instance = (MyApp) getApplicationContext();
28-
_refWatcher = LeakCanary.install(this);
26+
if (LeakCanary.isInAnalyzerProcess(this)) {
27+
// This process is dedicated to LeakCanary for heap analysis.
28+
// You should not init your app in this process.
29+
return;
30+
}
2931

30-
// for better RxJava debugging
31-
//RxJavaHooks.enableAssemblyTracking();
32+
_instance = (MyApp) getApplicationContext();
33+
_refWatcher = LeakCanary.install(this);
3234

33-
// Initialize Volley
34-
MyVolley.init(this);
35+
// for better RxJava debugging
36+
//RxJavaHooks.enableAssemblyTracking();
3537

36-
Timber.plant(new Timber.DebugTree());
37-
}
38+
// Initialize Volley
39+
MyVolley.init(this);
40+
41+
Timber.plant(new Timber.DebugTree());
42+
}
3843
}
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/fragments/BaseFragment.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/BaseFragment.java
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import com.morihacky.android.rxjava.MyApp;
55
import com.squareup.leakcanary.RefWatcher;
66

7-
public class BaseFragment
8-
extends Fragment {
7+
public class BaseFragment extends Fragment {
98

10-
@Override
11-
public void onDestroy() {
12-
super.onDestroy();
13-
RefWatcher refWatcher = MyApp.getRefWatcher();
14-
refWatcher.watch(this);
15-
}
9+
@Override
10+
public void onDestroy() {
11+
super.onDestroy();
12+
RefWatcher refWatcher = MyApp.getRefWatcher();
13+
refWatcher.watch(this);
14+
}
1615
}

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.