How to implement pagination or infinite scroll in FirebaseRecyclerAdapater - firebase-realtime-database

I am using RecyclerView to show search result. Everything works perfectly fine. The RecyclerView is implemented with FirebaseRecyclerAdapter.
Now, I want to implement pagination/infinite scroll in RecyclerView on scroll down.
Initial number of data on RecyclerView has to be 10 items, even though there are 100 items in the database.
When user swipe from bottom to top, RecyclerView has to add more data at the bottom of that 10th item.
RecyclerView has to load 10 more items every time it loads more data.
The Application must use FirebaseRecyclerAdapter.
Please let me know if there is anything you don't understand and please help me.

To implement infinite scroll with FirebaseUI use the FirebaseRecyclerPagingAdapter. You can configure page size there, and it will auto-load data in increments of that page size.

Related

UICollectionView list of visible cells wrong under VoiceOver mode

I have a vertically scrolling UICollectionView.
Nested into this list is another horizontally paging UICollectonView, which takes up the whole width of the screen.
On top of it I layered a UIPageControl element to show num of pages / current page and so on.
I am updating the page control index in the UICollectionViews willDisplay cell: UICollectionViewCell delegate.
It all works perfectly well until however I turn on the Voice Over mode in the phone settings.
The pagination still works without problems using the right gestures (three finger swipe), but the PageControl does not show the correct current page. Its most of the time off by +1. But when skimming a bit through the list there can appear all kinds of strange current page indices (off by 2 or 3)
What is interesting: The screenreader internally knows the right index. Because it reads it before entering a new page. But I don't know where it got this information and how to read out.
I tried to find out what is going on and found, that the UICollectionViews visible cells array is not maintained correctly. Instead of containing the real cell on screen it contains the next cell that is upcoming.
Is there anything I can do about it. Is seems to be a system issue as it is working in non voice over mode. I was wondering that I couldn't find anything related to this topic already on the web.

How to recreate this iOS application view and animations?

I am new to iOS development and unable to identify how Google/YouTube built this view in the YouTubeTV app. Is this built using an UITableView?
Essentially, the top row is selectable (Pre-animation). As you scroll up, the top row gets pushed up and out of view (Mid-animation), while the second row fades and grows into, and replaces, the top row). I've included screenshots of the animation in-progress. Thanks for the info and assistance.
This would be done with a UITableView or a UICollectionView. What you would do is enable paging on the Table/Collection view, so that it only ever displays entire cells in the visible area of the view. You can then manipulate the height use the heightForCellAtIndexPath: function - as an example of how it could be done on a tableview.
There is actually a really good example on github - typically we try to give more full answers on SO, but in this case, this could be relevant to you just starting out. Not affiliated in anyway, but it's a really good example.
https://github.com/aslanyanhaik/youtube-iOS

Create a listing inside of a ScrollView

I am writing a Swift app, and on my main screen I have a long scrollview with several regions of content in it (upcoming events, announcements, and then featured products, and finally some basic info). So it's this really long scroll, and you can swipe down to the bottom.
So visualize 4 boxes, if you will, stacked vertically.
The 3rd box shows featured products. This can be anywhere from 1 to 30 items, depending upon any filters the user has in their settings.
My first try was using a UITableView for region#3 inside of this parent scrollview, but the problem is it only shows the first few items/rows and then the rest you scroll inside the table (which is the default/natural behavior of a table, right?). Unfortunately, the requirement I have is that the inner table can't scroll - it needs to display everything at once and you have to scroll (in the main UIScrollView) to get to the bottom (not scroll inside the inner uitableview scroll). Also, everyone seems to say don't use UITableView inside of a scroll.
So how do I create some sort of list where I create one template (like how you would in a xib/tablecell, and then assign a data source to it, and then repeat down without scrolling? Should I use a tableview after all, and just make the height of it very high and turn scrolling off?
Do I somehow instantiate xibs in a for loop and assign them dynamically to some view?
Thanks so much!
Sounds like you want a Table View with Grouped style. That would make it fairly easy to keep your "4 boxes" segregated, and your "3rd box" would simply be 1 to 30 rows in that section.
On note: you don't want to have a "very tall" table view - or any other type of view, for that matter. You want to allow iOS to manage memory for you, and to load and display only those parts of your content that is visible at any one time.
In other words, use a table view like its designed to be used :)

Swift ios app : sidebar menu, several pages containing table views with pull refresh

I'm trying to build an iOS app in Swift which looks like the schema below.
I handles a list of channels, and displays a list of items for each channel.
The main view display the list of items for the current channel.
One can go to the next / previous channel by swiping left or right.
One can also display the whole list of channel by opening the sidebar menu, and have a random access to the channel he chooses in the list.
I thought it would be so simple ! But...
I use :
a table view to display the list of items
a page view controller to display the channels
a navigation controller on top to display the name of the app
SWRevealViewController to have the sidebar menu
Everything is implemented, but I can't get ride of certain bugs nor figure out where those come from :
the pull & refresh spinner in table view bugs (never stops) from time to time
page views are rebuilt all the time, they are never cached => I can't initialize a view once for good (and I guess it induces poor performance)
page views animation behave a weird way : when they appear, they are below the navigation bar (no matter what constraint I set in the storyboard), and return to their right position after a short delay (or sometimes it needs a touch event)
So, I was wondering : isn't their a better way to do all of that ? I feel like I'm just not going the right direction to achieve this. At the beginning, I needed the app to run on iOS 7. It turns out that iOS 8 will be fine.
Thanks for your help !

ios - Making UIScrollView scroll smoothly

In my iPad application, i've a scroll view that lists images of 20 video albums. The list of 20 images will be sent by server.
Now when the user reaches end of scroll view, i've to send a request to get next 10 videos details.
After fetching the data, i want to add them to the scroll view at the end. But I want to delete the 10 videos at the beginning. So that at a time scroll view will show only 20 video details all the time.
When user scrolls again to the end, i'll send request to server, get next 10 video details and add them to the scroll view, remove 10 beginning video details from scroll view...... and similarly when user scrolls to the beginning i'll fetch 10 previous videos and repeat the same.
Here i want to make sure the scrolling must be smooth and don't want to have flickers in scroll view. can some one suggest to have better scroll view coding to achieve my requirements please?
If your code contains scroll.pagingEnabled = YES; Then please remove this part of code.
It will surely work.
The real problem here will be in setting up cell recycling. It's not that hard to do, I have a couple examples of which you can look at, one being here. You'll need to make some changes to that code of course, it is set up in "pages" — Only one view on screen at any one time, and I don't think that's what you want.
Aside from that...
Your critical part here will be in designing your data source in a way that allows removing of old items, and adding new items, without skipping items.
For instance, the way I might approach this is to render the "last" item in your scroll view, the same as you want the first item in the scrollview to be. When the user gets to the last item, set your content offset to the start of the scrollview without animation (haven't actually tried this, so there may be a jolt that you don't want, test it and see). This will give the appearance of endless scrolling. Your data source would simply overwrite old indexes when adding new items, instead of adding to the end of an array for instance.
If you are presenting then in the form of a grid view, I suggest you take a look at AQGridView. That grid view supports cell queueing and dequeueing, which does exactly what you describe.
You can also use the delegate method scrollViewDidScroll: to determine if you're at the bottom of the scrollview and trigger the download of the next set of albums.

Resources