amitshekhariitbhu / rxjava2-android-samples Goto Github PK
View Code? Open in Web Editor NEWRxJava 2 Android Examples - How to use RxJava 2 in Android
Home Page: https://amitshekhar.me
License: Apache License 2.0
RxJava 2 Android Examples - How to use RxJava 2 in Android
Home Page: https://amitshekhar.me
License: Apache License 2.0
Hi
Great work you have done here. If possible can you include a real-world app example for clearer picture of RXJava2 can do? News feed reader maybe?
Thanks
private Observable getObservable() {
return Observable.create(new ObservableOnSubscribe() {
@OverRide
public void subscribe(ObservableEmitter emitter) throws Exception {
// send events with simulated time wait
//下面的注释是作者原注释,我觉得不太对,因为这个运行的结果是1,3,7被发送出来了
Thread.sleep(0);
emitter.onNext(1); // skip
emitter.onNext(2); // deliver
Thread.sleep(505);
emitter.onNext(3); // skip
Thread.sleep(99);
emitter.onNext(4); // skip
Thread.sleep(100);
emitter.onNext(5); // skip
emitter.onNext(6); // deliver
Thread.sleep(305);
emitter.onNext(7); // deliver
Thread.sleep(510);
emitter.onComplete();
}
});
}
下面的注释应该是ThrottleLast的结果,和ThrottleFirst的不符
Please add this sample operators. Thankyou :)
The title is wrong for the async example. It is just due to a typo in the manifest. I have patched it and will make a pull request.
-- Kyle
Any idea how to handle "thread interrupted"?
This happens due to calling the instant search api!
Thank you.
When I click on keyboard button "actionSearch" observer call "onComplete" and observable do not react on text changed event.
how can get responses headers for RxAndroid
Hi, what are the best practice to dispose subscriber? In my application in few places memory is getting leak because of late dispose (ex: disposing only in onDestroy)
The log is :
First onSubscribe : false
First onNext value : 1
First onNext value : 2
First onNext value : 3
First onNext value : 4
First onComplete
Second onSubscribe : false
Second onNext value : 1
Second onNext value : 2
Second onNext value : 3
Second onNext value : 4
Second onComplete
It is different from the comment "it will emit 2, 3, 4 as (count = 3), retains the 3 values for replay"
Hello, thank you for your perfect repo, but I have a question about Flowable, why did you use SingleObserver with Flowable maybe there is no error but I think logically is not correct because Flowable introduced for supporting backpressure and singleObserver introduced for single observable.Do you agree?
Hi @amitshekhariitbhu !
i want to use pagination example with Fast Networking. but it does not work.could you create an example for this demo.thanks
this is my code:
private void subscribeForData() {
Disposable disposable = paginator
.onBackpressureDrop()
.concatMap(new Function<Integer, Publisher<List>>() {
@OverRide
public Publisher<List> apply(@nonnull final Integer page) {
loading = true;
progressBar.setVisibility(View.VISIBLE);
return dataFromNetwork(page);
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<List>() {
@OverRide
public void accept(@nonnull List items) {
paginationAdapter.addItems(items);
paginationAdapter.notifyDataSetChanged();
loading = false;
progressBar.setVisibility(View.GONE);
}
});
compositeDisposable.add(disposable);
paginator.onNext(pageNumber);
}
private Flowable<List> dataFromNetwork(int page) {
return Rx2AndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}")
.addPathParameter("pageNumber", String.valueOf(page))
.addQueryParameter("limit", "10")
.build()
.getObjectListFlowable(User.class);
}
Like Music Player
steps:
step1(listen to audio headphone jack plug in/plug out by system broadcast receiver)
step2(open Music Player Activity/view when head jack plugged in)
step3.1(listen to Play Button to Play Music | change to play UI(set textview1 to "play music"))
step3.2(listen to Pause Button to Pause Music | change to pause UI (set textview2 to "pause music"))
step4(when headphone jack plug out to Stop Music | change to stop UI (set textview3 to "stop music"))
Error:(26, 13) Failed to resolve: io.reactivex.rxjava2:rxandroid:2.0.0 Show in File
Show in Project Structure dialog
Not able to see the Activity code properly in GitHub source code viewer, Somethings wrong with codes formatting.
disposables.clear()
is invoked in onStop()
But in the comment and also Github
disposables.clear()
is invoked in onDestroy()
BTW, there are several typos on the page Using Disposable in RxJava:
Let**'s** say there is an observable which emits some values, but while emitting values, the user presses back button, then it must stop emitting values.
Hey
Thank you for this awesome examples :)
I am trying to implement the optimized cache method using takeUntil
in my app. I am using a Gson model to parse the JSON response from the API .
I've been testing several methods but didn't succeed to get it right.am beginner in RxJava .
My code
https://gist.github.com/alouanemed/6b5f4d5d3623ae69331de25c12dd5b98
Thanks :) .
I want to show priogressDialog in the "search" implementation. But, Not finding where to put the "showProgressDialog()" method.
This error is coming when trying to build.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.