I have a Recycler Viewer that displays data from Fire Base db, but the source list contains about 4k items. I am trying to show only the first 15 elements instead of waiting for the full list to load, but am not sure how to do this.
I am trying to take (x) elements through Subscriber, however it does not improve read performance (it is still waiting for 4k elements from Firebase DB). How to speed it up?
Subscriber - Lead
@Override public void onBindViewHolder(final ListContentFragment.ViewHolder holder, int position) { modelInterface.getDataFromFireBase("FinalSymbols") .take(15) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer<DataSnapshot>() { @Override public void accept(DataSnapshot dataFromDb) throws Exception {
Publisher - Data Source (FireBase db)
@Override public Flowable<DataSnapshot> getDataFromFireBase(final String childName) { return Flowable.create(new FlowableOnSubscribe<DataSnapshot>() { @Override public void subscribe(final FlowableEmitter<DataSnapshot> e) throws Exception { databaseReference.child(childName).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { e.onNext(dataSnapshot); e.onComplete(); } @Override public void onCancelled(DatabaseError databaseError) { } }); } }, BackpressureStrategy.BUFFER);
source share