Learning RxJava for Android by example

Overview

Learning RxJava for Android by example

This is a repository with real-world useful examples of using RxJava with Android. It usually will be in a constant state of "Work in Progress" (WIP).

I've also been giving talks about Learning Rx using many of the examples listed in this repo.

Examples:

  1. Background work & concurrency (using Schedulers)
  2. Accumulate calls (using buffer)
  3. Instant/Auto searching text listeners (using Subjects & debounce)
  4. Networking with Retrofit & RxJava (using zip, flatmap)
  5. Two-way data binding for TextViews (using PublishSubject)
  6. Simple and Advanced polling (using interval and repeatWhen)
  7. Simple and Advanced exponential backoff (using delay and retryWhen)
  8. Form validation (using combineLatest)
  9. Pseudo caching : retrieve data first from a cache, then a network call (using concat, concatEager, merge or publish)
  10. Simple timing demos (using timer, interval or delay)
  11. RxBus : event bus using RxJava (using RxRelay (never terminating Subjects) and debouncedBuffer)
  12. Persist data on Activity rotations (using Subjects and retained Fragments)
  13. Networking with Volley
  14. Pagination with Rx (using Subjects)
  15. Orchestrating Observable: make parallel network calls, then combine the result into a single data point (using flatmap & zip)
  16. Simple Timeout example (using timeout)
  17. Setup and teardown resources (using using)
  18. Multicast playground

Description

1. Background work & concurrency (using Schedulers)

A common requirement is to offload lengthy heavy I/O intensive operations to a background thread (non-UI thread) and feed the results back to the UI/main thread, on completion. This is a demo of how long-running operations can be offloaded to a background thread. After the operation is done, we resume back on the main thread. All using RxJava! Think of this as a replacement to AsyncTasks.

The long operation is simulated by a blocking Thread.sleep call (since this is done in a background thread, our UI is never interrupted).

To really see this example shine. Hit the button multiple times and see how the button click (which is a UI operation) is never blocked because the long operation only runs in the background.

2. Accumulate calls (using buffer)

This is a demo of how events can be accumulated using the "buffer" operation.

A button is provided and we accumulate the number of clicks on that button, over a span of time and then spit out the final results.

If you hit the button once, you'll get a message saying the button was hit once. If you hit it 5 times continuously within a span of 2 seconds, then you get a single log, saying you hit that button 5 times (vs 5 individual logs saying "Button hit once").

Note:

If you're looking for a more foolproof solution that accumulates "continuous" taps vs just the number of taps within a time span, look at the EventBus Demo where a combo of the publish and buffer operators is used. For a more detailed explanation, you can also have a look at this blog post.

3. Instant/Auto searching text listeners (using Subjects & debounce)

This is a demo of how events can be swallowed in a way that only the last one is respected. A typical example of this is instant search result boxes. As you type the word "Bruce Lee", you don't want to execute searches for B, Br, Bru, Bruce, Bruce, Bruce L ... etc. But rather intelligently wait for a couple of moments, make sure the user has finished typing the whole word, and then shoot out a single call for "Bruce Lee".

As you type in the input box, it will not shoot out log messages at every single input character change, but rather only pick the lastly emitted event (i.e. input) and log that.

This is the debounce/throttleWithTimeout method in RxJava.

4. Networking with Retrofit & RxJava (using zip, flatmap)

Retrofit from Square is an amazing library that helps with easy networking (even if you haven't made the jump to RxJava just yet, you really should check it out). It works even better with RxJava and these are examples hitting the GitHub API, taken straight up from the android demigod-developer Jake Wharton's talk at Netflix. You can watch the talk at this link. Incidentally, my motivation to use RxJava was from attending this talk at Netflix.

(Note: you're most likely to hit the GitHub API quota pretty fast so send in an OAuth-token as a parameter if you want to keep running these examples often).

5. Two-way data binding for TextViews (using PublishSubject)

Auto-updating views are a pretty cool thing. If you've dealt with Angular JS before, they have a pretty nifty concept called "two-way data binding", so when an HTML element is bound to a model/entity object, it constantly "listens" to changes on that entity and auto-updates its state based on the model. Using the technique in this example, you could potentially use a pattern like the Presentation View Model pattern with great ease.

While the example here is pretty rudimentary, the technique used to achieve the double binding using a Publish Subject is much more interesting.

6. Simple and Advanced polling (using interval and repeatWhen)

This is an example of polling using RxJava Schedulers. This is useful in cases, where you want to constantly poll a server and possibly get new data. The network call is "simulated" so it forces a delay before return a resultant string.

There are two variants for this:

  1. Simple Polling: say when you want to execute a certain task every 5 seconds
  2. Increasing Delayed Polling: say when you want to execute a task first in 1 second, then in 2 seconds, then 3 and so on.

The second example is basically a variant of Exponential Backoff.

Instead of using a RetryWithDelay, we use a RepeatWithDelay here. To understand the difference between Retry(When) and Repeat(When) I wouuld suggest Dan's fantastic post on the subject.

An alternative approach to delayed polling without the use of repeatWhen would be using chained nested delay observables. See startExecutingWithExponentialBackoffDelay in the ExponentialBackOffFragment example.

7. Simple and Advanced exponential backoff (using delay and retryWhen)

Exponential backoff is a strategy where based on feedback from a certain output, we alter the rate of a process (usually reducing the number of retries or increasing the wait time before retrying or re-executing a certain process).

The concept makes more sense with examples. RxJava makes it (relatively) simple to implement such a strategy. My thanks to Mike for suggesting the idea.

Retry (if error) with exponential backoff

Say you have a network failure. A sensible strategy would be to NOT keep retrying your network call every 1 second. It would be smart instead (nay... elegant!) to retry with increasing delays. So you try at second 1 to execute the network call, no dice? try after 10 seconds... negatory? try after 20 seconds, no cookie? try after 1 minute. If this thing is still failing, you got to give up on the network yo!

We simulate this behaviour using RxJava with the retryWhen operator.

RetryWithDelay code snippet courtesy:

Also look at the Polling example where we use a very similar Exponential backoff mechanism.

"Repeat" with exponential backoff

Another variant of the exponential backoff strategy is to execute an operation for a given number of times but with delayed intervals. So you execute a certain operation 1 second from now, then you execute it again 10 seconds from now, then you execute the operation 20 seconds from now. After a grand total of 3 times you stop executing.

Simulating this behavior is actually way more simpler than the prevoius retry mechanism. You can use a variant of the delay operator to achieve this.

8. Form validation (using .combineLatest)

Thanks to Dan Lew for giving me this idea in the fragmented podcast - episode #4 (around the 4:30 mark).

.combineLatest allows you to monitor the state of multiple observables at once compactly at a single location. The example demonstrated shows how you can use .combineLatest to validate a basic form. There are 3 primary inputs for this form to be considered "valid" (an email, a password and a number). The form will turn valid (the text below turns blue :P) once all the inputs are valid. If they are not, an error is shown against the invalid inputs.

We have 3 independent observables that track the text/input changes for each of the form fields (RxAndroid's WidgetObservable comes in handy to monitor the text changes). After an event change is noticed from all 3 inputs, the result is "combined" and the form is evaluated for validity.

Note that the Func3 function that checks for validity, kicks in only after ALL 3 inputs have received a text change event.

The value of this technique becomes more apparent when you have more number of input fields in a form. Handling it otherwise with a bunch of booleans makes the code cluttered and kind of difficult to follow. But using .combineLatest all that logic is concentrated in a nice compact block of code (I still use booleans but that was to make the example more readable).

9. Pseudo caching : retrieve data first from a cache, then a network call (using concat, concatEager, merge or publish)

We have two source Observables: a disk (fast) cache and a network (fresh) call. Typically the disk Observable is much faster than the network Observable. But in order to demonstrate the working, we've also used a fake "slower" disk cache just to see how the operators behave.

This is demonstrated using 4 techniques:

  1. .concat
  2. .concatEager
  3. .merge
  4. .publish selector + merge + takeUntil

The 4th technique is probably what you want to use eventually but it's interesting to go through the progression of techniques, to understand why.

concat is great. It retrieves information from the first Observable (disk cache in our case) and then the subsequent network Observable. Since the disk cache is presumably faster, all appears well and the disk cache is loaded up fast, and once the network call finishes we swap out the "fresh" results.

The problem with concat is that the subsequent observable doesn't even start until the first Observable completes. That can be a problem. We want all observables to start simultaneously but produce the results in a way we expect. Thankfully RxJava introduced concatEager which does exactly that. It starts both observables but buffers the result from the latter one until the former Observable finishes. This is a completely viable option.

Sometimes though, you just want to start showing the results immediately. Assuming the first observable (for some strange reason) takes really long to run through all its items, even if the first few items from the second observable have come down the wire it will forcibly be queued. You don't necessarily want to "wait" on any Observable. In these situations, we could use the merge operator. It interleaves items as they are emitted. This works great and starts to spit out the results as soon as they're shown.

Similar to the concat operator, if your first Observable is always faster than the second Observable you won't run into any problems. However the problem with merge is: if for some strange reason an item is emitted by the cache or slower observable after the newer/fresher observable, it will overwrite the newer content. Click the "MERGE (SLOWER DISK)" button in the example to see this problem in action. @JakeWharton and @swankjesse contributions go to 0! In the real world this could be bad, as it would mean the fresh data would get overridden by stale disk data.

To solve this problem you can use merge in combination with the super nifty publish operator which takes in a "selector". I wrote about this usage in a blog post but I have Jedi JW to thank for reminding of this technique. We publish the network observable and provide it a selector which starts emitting from the disk cache, up until the point that the network observable starts emitting. Once the network observable starts emitting, it ignores all results from the disk observable. This is perfect and handles any problems we might have.

Previously, I was using the merge operator but overcoming the problem of results being overwritten by monitoring the "resultAge". See the old PseudoCacheMergeFragment example if you're curious to see this old implementation.

10. Simple timing demos (using timer, interval and delay)

This is a super simple and straightforward example which shows you how to use RxJava's timer, interval and delay operators to handle a bunch of cases where you want to run a task at specific intervals. Basically say NO to Android TimerTasks.

Cases demonstrated here:

  1. run a single task after a delay of 2s, then complete
  2. run a task constantly every 1s (there's a delay of 1s before the first task fires off)
  3. run a task constantly every 1s (same as above but there's no delay before the first task fires off)
  4. run a task constantly every 3s, but after running it 5 times, terminate automatically
  5. run a task A, pause for sometime, then execute Task B, then terminate

11. RxBus : event bus using RxJava (using RxRelay (never terminating Subjects) and debouncedBuffer)

There are accompanying blog posts that do a much better job of explaining the details on this demo:

  1. Implementing an event bus with RxJava
  2. DebouncedBuffer used for the fancier variant of the demo
  3. share/publish/refcount

12. Persist data on Activity rotations (using Subjects and retained Fragments)

A common question that's asked when using RxJava in Android is, "how do i resume the work of an observable if a configuration change occurs (activity rotation, language locale change etc.)?".

This example shows you one strategy viz. using retained Fragments. I started using retained fragments as "worker fragments" after reading this fantastic post by Alex Lockwood quite sometime back.

Hit the start button and rotate the screen to your heart's content; you'll see the observable continue from where it left off.

There are certain quirks about the "hotness" of the source observable used in this example. Check my blog post out where I explain the specifics.

I have since rewritten this example using an alternative approach. While the ConnectedObservable approach worked it enters the lands of "multicasting" which can be tricky (thread-safety, .refcount etc.). Subjects on the other hand are far more simple. You can see it rewritten using a Subject here.

I wrote another blog post on how to think about Subjects where I go into some specifics.

13. Networking with Volley

Volley is another networking library introduced by Google at IO '13. A kind citizen of github contributed this example so we know how to integrate Volley with RxJava.

14. Pagination with Rx (using Subjects)

I leverage the simple use of a Subject here. Honestly, if you don't have your items coming down via an Observable already (like through Retrofit or a network request), there's no good reason to use Rx and complicate things.

This example basically sends the page number to a Subject, and the subject handles adding the items. Notice the use of concatMap and the return of an Observable<List> from _itemsFromNetworkCall.

For kicks, I've also included a PaginationAutoFragment example, this "auto-paginates" without us requiring to hit a button. It should be simple to follow if you got how the previous example works.

Here are some other fancy implementations (while i enjoyed reading them, i didn't land up using them for my real world app cause personally i don't think it's necessary):

15. Orchestrating Observable: make parallel network calls, then combine the result into a single data point (using flatmap & zip)

The below ascii diagram expresses the intention of our next example with panache. f1,f2,f3,f4,f5 are essentially network calls that when made, give back a result that's needed for a future calculation.

         (flatmap)
f1 ___________________ f3 _______
         (flatmap)               |    (zip)
f2 ___________________ f4 _______| ___________  final output
        \                        |
         \____________ f5 _______|

The code for this example has already been written by one Mr.skehlet in the interwebs. Head over to the gist for the code. It's written in pure Java (6) so it's pretty comprehensible if you've understood the previous examples. I'll flush it out here again when time permits or I've run out of other compelling examples.

16. Simple Timeout example (using timeout)

This is a simple example demonstrating the use of the .timeout operator. Button 1 will complete the task before the timeout constraint, while Button 2 will force a timeout error.

Notice how we can provide a custom Observable that indicates how to react under a timeout Exception.

17. Setup and teardown resources (using using)

The operator using is relatively less known and notoriously hard to Google. It's a beautiful API that helps to setup a (costly) resource, use it and then dispose off in a clean way.

The nice thing about this operator is that it provides a mechansim to use potentially costly resources in a tightly scoped manner. using -> setup, use and dispose. Think DB connections (like Realm instances), socket connections, thread locks etc.

18. Multicast Playground

Multicasting in Rx is like a dark art. Not too many folks know how to pull it off without concern. This example condiers two subscribers (in the forms of buttons) and allows you to add/remove subscribers at different points of time and see how the different operators behave under those circumstances.

The source observale is a timer (interval) observable and the reason this was chosen was to intentionally pick a non-terminating observable, so you can test/confirm if your multicast experiment will leak.

I also gave a talk about Multicasting in detail at 360|Andev. If you have the inclination and time, I highly suggest watching that talk first (specifically the Multicast operator permutation segment) and then messing around with the example here.

Rx 2.x

All the examples here have been migrated to use RxJava 2.X.

We use David Karnok's Interop library in some cases as certain libraries like RxBindings, RxRelays, RxJava-Math etc. have not been ported yet to 2.x.

Contributing:

I try to ensure the examples are not overly contrived but reflect a real-world usecase. If you have similar useful examples demonstrating the use of RxJava, feel free to send in a pull request.

I'm wrapping my head around RxJava too so if you feel there's a better way of doing one of the examples mentioned above, open up an issue explaining how. Even better, send a pull request.

License

Licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You agree that all contributions to this repository, in the form of fixes, pull-requests, new examples etc. follow the above-mentioned license.

Comments
  • Tests

    Tests

    Would you be interested in me writing at least a few tests to confirm RxJava samples provide expected behaviour? Once we have tests in place, we can make other changes, such updating to latest dependencies, with much greater confidence.

    This would probably require some refactoring of existing code. I can start with just one example to check if you are happy with the approach.

    enhancement 
    opened by EGecius 16
  • Can not subscribe to observable again once the app is unsubscribed with FormValidationCombineLatestFragment

    Can not subscribe to observable again once the app is unsubscribed with FormValidationCombineLatestFragment

    Hi,

    First of all, thank you for the great samples, Kaushik. Very useful for RxJava beginners.

    I have questions about the title. I found out that in Form Validation with CombineLatest sample (FormValidationCombineLatestFragment.java), observer can not subscribe to observable again once the app goes into background by pressing "HOME" button and then returns to foreground.

    I thought this is because _subscription.unsubscribe() is call at onPause() and _combineLatestEvents() is called at onCreateView(). So, I changed the code as below so that observer are subscribed again when the app comes to foreground.

    // FormValidationCombineLatestFragment.java
    @Override
    public void onResume() {
        super.onResume();
        _combineLatestEvents();
    }
    
    @Override
    public void onPause() {
        super.onPause();
        if (_subscription != null) {
            _subscription.unsubscribe();
        }
    }
    

    However, this did not work. Then, I changed the code to call _subscription.unsubscribe() at onDestroy(), and finally it worked as I expected.

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (_subscription != null) {
            _subscription.unsubscribe();
        }
    }
    

    So my question is,

    1. Is calling _subscription.unsubscribe() at onDestroy() a right decision?
    2. Why calling _combineLatestEvents() at onResume() can not re-subscribe to observable?

    It would be helpful if anyone has solution for these questions. Thank you

    opened by tomoima525 7
  • finish activity: Long running save/send data to server

    finish activity: Long running save/send data to server

    Do you have any suggestions for such a usecase with rxjava?

    1. user: backpress/leaves activity
    2. save/send data to server -> potentially long running task
    opened by Rainer-Lang 5
  • AndroidObservable

    AndroidObservable

    You should always use AndroidObservable to bind the source sequence to the activity/fragment. This way you ensure that if the activity is scheduled to finish no notifications will be forwarded, plus it already observes on Android UI main thread.

    for example:

    subscription = AndroidObservable.bindActivity(this, YourObservable).subscribe();
    

    AndroidObservable bindActivity() or bindFragment() both return an observable product of yours, so you can treat it normally as any observable. AndroidObservable has other interesting methods such as fromBroadcast() which creates an observable that wraps a BroadcastReceiver and emit received intents.

    opened by mradzinski 5
  • Does RotationPersist leak the Activity?

    Does RotationPersist leak the Activity?

    If I add LeakCanary by just putting

        LeakCanary.install(getApplication());
    

    in the MainActivity's onCreate(), then

        debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' 
        releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' 
    

    to the build.gradle dependencies, I find that hitting BACK during the counter increment reports a "suspected leak" in the log and the LeakCanary "Brr..." screen comes up. In fact, you also get it if you just rotate a few times when the counter is running but exit after it has completed normally. Is this a real leak?

    01-15 16:37:53.960 4308-4324/com.morihacky.android.rxjava I/art: hprof: heap dump "/storage/sdcard/Download/leakcanary/suspected_leak_heapdump.hprof" starting...
    

    image

    opened by otamate 4
  • Memory leak

    Memory leak

    Hi Kaushik, thanks for yours examples about RxJava. I`ve just started learning it. I investigated RxJava with Retrofit, and found an issue. When the request being done to server, an exception is thrown with 403 error. onError called, an exception logged. looks Ok. The issue is - when I close the app with back button, and open again, and do the request again, exception is thrown, and 2 errors was logged. Do the same steps, onError was called, 3 erros was logged, etc. Memory leak occurs.

    Firstly - it seems strange, the Observable finished with an error, onError was called, app was closed with back button, onDestroy was called, all objects should be garbage collected.Isn't it ?

    Ok, I tried to call unsubscribe on OnDestroy, the issue still reproduce. I googled the issue and found workaround using WeakReference. It looks awkwardly.

    What is your opinion about this ? Or, I did something wrong ?

    opened by supervital 4
  • feat: port to RxJava 2.X

    feat: port to RxJava 2.X

    See #82 for thought process behind how this is being done.

    RxJava 2.0 has hit stable, so it is time to port these. Here's what's different in 2.0. For a lazy quick helpful summary, you can check the fragmented episode with Jake.

    Both 1.x and 2.x will coexist temporarily until we're done with the migration. After that all references to 1.x can be removed.


    thanks @marukami + @marcinkunert for lighting the fire on this

    enhancement 
    opened by kaushikgopal 3
  • Minor refactoring

    Minor refactoring

    Removed instances of observeOn() where ViewObservables and bindActivity/bindFragment have been used since the observable they return already have this functionality

    opened by ghost 3
  • refactored combineLatest example to introduce

    refactored combineLatest example to introduce "*valid" Observables.

    I revisited the combineLatest example.

    I created "fieldIsValid" observables for each of the EditText views (as opposed to determining which view is valid inside the combineLatest call). My reasoning behind it was mainly due to the presence of setError() calls inside the combineLatest() operator, which IMHO should be regarded as a side effect and must be in their own subscribe(), where the subscriber reacts to an observable that only determines whether the text inside a particular view is valid or not.

    In addition, This pull request fixes a small bug where validation is not performed anymore. You can reproduce it by going first to the combineLatest example, tap on the home button, go back to the app, then you'll notice that no validation is performed anymore. This was due to the fact that subscriptions were made in onCreateView() but the un-subscriptions were performed in OnPause(). My fix was simply to move the subscription step to onResume().

    opened by rz-robsn 3
  • Simplified BufferDemoFragment

    Simplified BufferDemoFragment

    I'm also right now just beginning to learn Rx but it came to my attention that this can be improved.

    According to the documentation of Observable.create:

     * Write the function you pass to {@code create} so that it behaves as an Observable: It should invoke the
     * Subscriber's {@link Subscriber#onNext onNext}, {@link Subscriber#onError onError}, and
     * {@link Subscriber#onCompleted onCompleted} methods appropriately.
    

    Since this was not done, I changed that. Also we don't really care about onError and onCompleted hence I changed it to Action1.

    I am still not happy about the fact that we have this _tabCount variable since the data is more or less duplicated (the list of integers in call contains the data that we actually need).

    Do you know how to solve this one?

    opened by vanniktech 3
  • Rxbus + Sticky Events?

    Rxbus + Sticky Events?

    What about making the events sticky?

    If I use rxbus with android's sharing mechnism how will I get the event in the activity where the shared info is received.

    The event will be sent before the activity is opened...do I have to persist the event? would'nt that make a bus irrelevant?

    opened by sirvon 3
  • Wrapping an Android Method that requires return value

    Wrapping an Android Method that requires return value

    Hey

    Thanks for all the useful examples. I'm just picking up Android and RxJava2, coming from a Javascript background, and they have been very instructive.

    I have a question regarding the transmission of return values in an Observable.

    I’ve come up against a particular problem, with the WebView.ShouldInterceptRequest function. I’ve managed to port all the WebView events into an Observable but I’m facing the problem of needing to return a resource or null value to the Observable at some point down the chain.

    In JS, I got round this by using Rx.Observable.fromEventPattern. I had a wrapper function around the equivalent of WebView.ShouldInterceptRequest, and returned a resource or null to the wrapper function when required. Is this a valid approach?

    If you could point me in the right direction, I’d be very appreciative.

    opened by tomgallagher 0
  • Corrected method name typo

    Corrected method name typo

    A small fix of method name typo.

    from -> btn5_RunTask5Times_IntervalOf3s() to -> btn5_RunTaskA_Pause_ThenRunTaskB()

    As btn4 has the same name as btn4_RunTask5Times_IntervalOf3s()

    opened by Tobibur 0
  • memory leak

    memory leak

    i got memory leak report on DebounceSearchEmitterFragment.

    the log info: 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: In com.morihacky.android.rxjava:1.2:2. 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * com.morihacky.android.rxjava.fragments.DebounceSearchEmitterFragment has leaked: 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * GC ROOT thread java.lang.Thread. (named 'Thread-10') 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references com.android.tools.profiler.support.event.InputConnectionWrapper.mTarget 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references com.android.internal.widget.EditableInputConnection.mTextView 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references android.support.v7.widget.AppCompatEditText.mParent 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references android.widget.LinearLayout.mParent 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references android.widget.LinearLayout.mChildren 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references array android.view.View[].[2] 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references android.widget.ListView.mAdapter 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * references com.morihacky.android.rxjava.fragments.DebounceSearchEmitterFragment$LogAdapter.this$0 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * leaks com.morihacky.android.rxjava.fragments.DebounceSearchEmitterFragment instance 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * Retaining: 1.2 kB. 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * Reference Key: 7ba3dadc-f535-4747-b4ec-ee266c90ebe6 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * Device: Google google Pixel sailfish 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * Android Version: 8.0.0 API: 26 LeakCanary: 1.5.1 1be44b3 01-08 11:55:57.399 544-3247/com.morihacky.android.rxjava D/LeakCanary: * Durations: watch=5445ms, gc=194ms, heap dump=2190ms, analysis=96209ms

    opened by aprz512 0
  • gc overhead limit exceeded?

    gc overhead limit exceeded?

    Hi, I just want to see your example however I am having an error when running your example. here it is.

    Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
    Error:	at java.util.Arrays.copyOfRange(Arrays.java:3664)
    Error:	at java.lang.String.<init>(String.java:207)
    Error:	at java.lang.StringBuilder.toString(StringBuilder.java:407)
    Error:	at com.android.dx.rop.type.Prototype.withFirstParameter(Prototype.java:370)
    Error:	at com.android.dx.rop.type.Prototype.intern(Prototype.java:180)
    Error:	at com.android.dx.cf.iface.StdMethod.<init>(StdMethod.java:46)
    Error:	at com.android.dx.cf.direct.MethodListParser.set(MethodListParser.java:81)
    Error:	at com.android.dx.cf.direct.MemberListParser.parse(MemberListParser.java:217)
    Error:	at com.android.dx.cf.direct.MemberListParser.parseIfNecessary(MemberListParser.java:108)
    Error:	at com.android.dx.cf.direct.MethodListParser.getList(MethodListParser.java:54)
    Error:	at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:551)
    Error:	at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    Error:	at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    Error:	at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    Error:	at com.android.dx.command.dexer.Main.parseClass(Main.java:772)
    Error:	at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
    Error:	at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1700)
    Error:	at com.android.dx.command.dexer.Main.processClass(Main.java:755)
    Error:	at com.android.dx.command.dexer.Main.processFileBytes(Main.java:723)
    Error:	at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
    Error:	at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1653)
    Error:	at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    Error:	at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    Error:	at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    Error:	at com.android.dx.command.dexer.Main.processOne(Main.java:677)
    Error:	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)
    Error:	at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
    Error:	at com.android.dx.command.dexer.Main.run(Main.java:275)
    Error:	at com.android.dx.command.dexer.Main.main(Main.java:245)
    Error:	at com.android.dx.command.Main.main(Main.java:106)
    
    opened by NelzkieCoder 0
  • fix: Forbid the addition of 0 to 9 items

    fix: Forbid the addition of 0 to 9 items

    If you turn the screen off during pagination and turn it on for a while, the item is added from 0 to 9. Like this,

    Item 0 Item 1 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9 Item 0 Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9 Item 20 Item 21 Item 22 Item 23 Item 24 Item 25 Item 26 Item 27 Item 28 Item 29

    The reason is that _paginator.onNext(0) is called in onStart when the screen is on. If emit the number of the list in onStart, it display normally.

    opened by amuyu 0
Owner
Kaushik Gopal
Kaushik Gopal
An example that demonstrates how to integrate a learning app with the EIDU platform

EIDU Sample Learning App This app is an example of how to create a learning app that integrates with the EIDU platform. Please consult dev.eidu.com fo

null 0 Dec 17, 2021
RxJava architecture library for Android

Reference Architecture for Android using RxJava This is an ambitious reference project of what can be done with RxJava to create an app based on strea

Reark 2.1k Dec 17, 2022
RxJava architecture library for Android

Reference Architecture for Android using RxJava This is an ambitious reference project of what can be done with RxJava to create an app based on strea

Reark 2.1k Dec 17, 2022
Viacheslav Veselov 0 Jul 8, 2022
Movie discovery app showcasing MVP, RxJava, Dagger 2 and Clean Architecture

MovieGuide ?? Refactoring in progress ??‍♀️ ⛏ ?? ??️ ?? ?? ?? Comments and new issues are welcome. ?? Currently not accepting external PRs that touch

Arun Sasidharan 2.6k Dec 25, 2022
This repo is to document my learning about Custom views in android

Custom-Views This repo is to document my learning about Custom views in android Note: If you are trying to understand Custom views, go in order: Custo

Kshitij Kumar 7 Feb 24, 2022
This is a simple example of Aspect Oriented Programming in Android

Android-AOPExample This is a simple example of Aspect Oriented Programming in Android as part of a blog post I have written. The idea was to measure h

Fernando Cejas 422 Nov 25, 2022
This repo contains example code for O'Reilly's "Programming Android" by Zigured Mednieks, Laird Dornin, Blake Meike and Masumi Nakamura

This repo contains working code for the example in O'Reilly's _Programming Android, 2nd Edition_; Mednieks, Dornin, Meike, Nakamura (http://shop.orei

G. Blake Meike 214 Nov 25, 2022
This repo contains example code for O'Reilly's "Programming Android" by Zigured Mednieks, Laird Dornin, Blake Meike and Masumi Nakamura

This repo contains working code for the example in O'Reilly's _Programming Android, 2nd Edition_; Mednieks, Dornin, Meike, Nakamura (http://shop.orei

G. Blake Meike 165 Nov 11, 2022
The example Android project of animated menu items in toolbar

Android Animated Menu Items The example Android project of animated menu items in toolbar. Thanks Srikant Shetty for idea of this animation. Cut: Copy

Ilya Fomenko 922 Nov 23, 2022
Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView.

Another drag and swipe library? This project is an example of basic drag & drop and swipe-to-dismiss with RecyclerView using ItemTouchHelper. It corre

Paul Burke 2.5k Dec 24, 2022
Example app for shortcuts

Android Shortcuts Example app for shortcuts in design library v25 Demo Manifest Add meta-data before </activity> tag in Manifest.xml <meta-data androi

Pamir Cevikogullari 334 Nov 29, 2022
Minimal example of how to safely share a file produced by a task in one project, with a task in another project.

How to share files across Gradle subprojects: A minimal example This is the Gradle project: . ├── producer │ └── build.gradle.kts ├── consumer │ └

Rob Moore 2 Dec 17, 2021
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

Stéphane Nicolas 1.3k Dec 27, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
simple android grocery app using kotlin and android studio

Project Idea The idea of this project is to make a grocery android app that users can use to order the groceries they want. It doesn't contain any bac

null 0 Nov 29, 2021
Beetlebug is an open source insecure Android application with CTF challenges built for Android Penetration Testers and Bug Bounty hunters.

Beetlebug Beetlebug is a beginner-friendly Capture the Flag Android application that aims to inspire interest in Mobile Application Security. It is ge

Hafiz Abdulaziz 60 Oct 11, 2022