I build an android app in which i have a large customer list.It receive data from server in JSON from and I show this JSON in Custom List view. But it take lot of time when Internet show cause of large list of customer.
I want to use Auto Update List when i scroll list it receive next JSON list from server and show it in list view like android mail app.
i am totally new in this so i want help in section from beginning.
You will need to implement pagination on server side. In your original request the server will send you a list of customers (say 20), and total no. of pages (considering each page has 20 customers) or total no. of customers. Based on this data, you can request for the next list of customers once your scroll hits the end, send another request with the page_no or whatever logic you implement to request the next list. Add the next list of customers into your adapter's data.
You can find many code snippets on how to figure out if your scroll has reached the end of list. Here is a guide on how to implement EndLess scroll in your listview.
Related
Hi to all Android heroes out there, I have been facing this interesting problem which I am trying to explain here
I have a simple requirement of showing a large amount of data in recycler view in a grid view which I am achieving using the Paging library provided by Android Jetpack.
I am using Single Source Of Truth pattern in which data fetched from the server is stored in Room DB first and then the database is observed for any changes.
The data I am fetching is sorted. It starts with A then B and so on as I scroll down
Now the requirement is there is a scroller besides the recycler view which contains all the alphabet listed down in vertical fashion giving the user the functionality
to jump to any alphabet directly instead of scrolling down to reach it.
The total rows of data starting from A to Z are around 100,000.
Now suppose the user is scrolling in normal fashion and is on the data starting with A letter, suddenly he taps on P alphabet from the scroller then the app
should show the data starting with P and then it should resume it's the behavior of scrolling i.e if user scrolls up then he should see data starting from O and
if he scrolls down then he should start seeing data with Q and so on.
The next requirement is since I am using local DB via Room then I should update data only when it gets updated saving the hits to the server.
What should be the ideal way to sync data with server considering the fact that minimum hits go to the server and we do not have old data in local DB
How can I achieve above-mentioned functionalities in an optimized way
I'm developing an android app, which will fetch data from my webservice and display it to user. I have a confusion in deciding where to keep pagination(in client side or server side)
My scenario is, I ll take input from the user and make a call to my webservice, to fetch all the data available for the input(response is in Json format) and then, display the data fetched in Recyclerview. I want to display only 50 records initially, then when "show more" button is clicked, the next 50 is displayed.
My data(reponse from webservice) range varies from 0 to 15000 , based on the input from user. And I have other filtering parameters in UI, which will change the rendered data when selected.
So, is it good to fetch all the 15000 records at once and do all kind of processing in client side?
or to fetch 50 records each time when "show more" button is clicked? and to fire new API call whenever filter is changed?
Thanks.
You should never try to fetch such a large number of records in one go, because : 1) your app would have a very slow FRT (First Response Time) 2) the user is unlikely to view more than a couple hundred records at any given time. 3) If the user data (2G/3G/4G) is paid, the user ends up paying for data that he would never see.
So, you should always have pagination on the server side and then your client can request subsequent records as and when needed.
Having said that, network requests would take time and waiting for response every time user clicks on "Show More" would be bad UX as well. So, you need to consider batching requests together and even pre-fetching some data. Here is a nice video for you to see before changing your architecture : https://www.youtube.com/watch?v=3kOx-IPqtqA
Hai I'm developing an application which will show some data in recycler view by parsing JSON.
For example if I have very large JSON response, I need my application to fetch only first 10 objects of JSON. When user scrolls down, I need to send request again to server to show 10 more.
Same like Facebook comments. It shows more comments when user scrolls down. How can I go this?
It is not best practice to do so you have to get that webservice in paging.
Other than that you can limit the iteration of for loop that you are using to parse JSON. And when the scroll is at the end Load more using this How to implement endless list with RecyclerView?
Give the following scenario. I have a mobile App on iOS/Android which is connected to a server backend via REST. Within the app you can display news items. These items can be created, edited and deleted of you are the creator of the item. On one page in the app there is a news feed where you can see an overview of news items created by other app users. The iOS/Android app stores the data of these news items in a local sqlite database. When the user scrolls down the list of items further items should be loaded if there are any.
The task I want to solve is how the items will be cached in the SQLite database to work with pagination. The cache must be updated sometimes when items are deleted or reordered on the server. This must be taken into account when working with pagination.
Here is the algorithm I've used so far:
if the feed page opens check if there are any items to display in the
sqlite database
if true retrieve p items with offset offset=0 from the database and contact the server to check if the first p items should be updated or deleted
if items should be updated or deleted perform these operations on the items in display
else contact the server for p items with offset offset=0 and display them
if the user scrolls down start 1. again with offset = offset + p
How does caching data for mobile apps work with pagination?
The question is how long you want to store data. You can store every data you get in part:
"else contact the server for p items with offset offset=0 and display them"
And set some time stamp to data. When time stamp expires you delete data ( in background ). In this way you save a lot of requests and also you don't waste with memory.
Hope this helps you with your problem.
I can't seem to find exactly what I'm looking for after a few day's worth of hunting, so if anyone has seen exactly what I'm trying to do elsewhere, I'd love a link or two.
Anyway, I'm trying to build an app to connect into an ERP system that returns user access information in JSON format via REST request using an e-mail address and password. Most users of the system only have a singular access role, so no big deal for them, but others have multiple roles. The trouble I'm having is taking these multiple access roles and adding them into a ListView where they can select the role with which they wish to use to gain access.
Trouble is, I need a display that uses two lines per selection (to properly display all user-pertinent data) and some way to record the user selection. The data useful in the background for the selection would not be displayed, as it would not mean anything to the user. I've been able to take the JSON response and map it to a custom class I designed for it without any problems (not actually all that useful, mostly only helps for discerning the results count prior to displaying multiple results to the ListView). But I can't figure out how to properly build the ListView layout and map the data to the layout. I'm having trouble understanding how to build the view and insert data into new list items.
The best I figure, if I can get the results to display in a ListView and then record the selection in the shared preferences, I'll be golden.
If the listview items being populated from some JSONArray then you could use listview.setOnItemClickListener to get the position of the selected item and match it from the array.Your question seems a little vague. Can you post some code of what you've tried so that it becomes a little clearer?