Why does Facebook's Android app scroll so smoothly - android

Facebook has the most smooth UI in my Android Phone, and I am wondering how can they do that.
While I am writing my demo, ListView with images always seems to be laggy, while facebook's new feed activity behaviors so amazing.
Anyone can tell me whether the Facebook App uses native ListView but with some improvement, or just rewrite the whole view for better performance?
EDIT: I have already used the caching strategy such as using async threads, caching ViewHolder as tag and storing images in memory for acceleration, while I still feel laggy. I do really want to know how did facebook engineers do that, they are really brilliant

Try hooking the device up to adb, open DDMS and press the method profiling button, then start scrolling a bunch for a few seconds. Traceview will open and you see what is using up all the CPU time.

I've never used a ListView before, but if I had to guess maybe they are retrieving the results and then caching them, whereas you're querying for the results everytime and not caching them.

Related

Manage memory in mobile apps that have infinite scrolling with images and real-time interaction

I'm designing a mobile app which will contain a list of images and videos which will be loaded from a server, this list will be very big and the user will scroll through many pages.
I'm afraid that loading all these images and videos might cause memory leaks and the app might crash due to low memory.
So how should I manage the memory for such an app? what is the best practice to manage the memory of images and have a very smooth scrolling experience without having any memory warnings on both iOS and Android? What techniques should I use in my app (images caching for example)
Also, the app will have real-time interactions, each time a user add an image or a video the data will be refreshed. And I need to have a scalable app that could eventually have millions of users.
I already searched and found PubNub and Google's FireBase that could really help in implementing such an experience, but do you have any other suggestions?
I need to know about best practices for such an app, I already searched a lot and couldn't find a complete answer.
Please advise.
Thanks in advance.
I always use Kingfisher. its the best for image caching. See also TableView and collection view prefetching delegate functions

Always connect to Webservice or local storage Android?

I'm developing a personal project with Android and struggling here with some doubts about the better way to develop it.
Well, my project consists of my app consuming a Rest Webservice (which I already developed with Java and Spring) and showing up a list of places on it. The thing is: This list could be huge, something like 2000- 3000 records with description and picture of each place.
I'm using volley and OKHttp to take care of my networking stuff, so far my list of places isn't that long, so everything is alright, but I'm afraid when the list starting to get big, I don't know how my app will handle this.
My questions would be:
1- Should I store the that list on my device and update the list every time I connect to the webservice?
2 - Am I doing correct, retrieving the entire list with just one request? If not, how's the best way to do it?
Thank you guys, I'm new to android stuff, and I'm developing everything by myself, don't have anyone experience around to ask that.
Cheers!
As mentioned in comments You need your app to do "paging" and to load some of the content every time you scroll down.
For example if you will open Facebook app and go over photos you will notice that the first ones always loading the fastest and as you keep scrolling some will be left blank for few moments, thats what paging is all about.
Make sure though not to overload the app with info, specially if you use bitmaps
You can read some good tutorials here

Android Best approach when handling a lot of images

Recently I dug into mobile development. I started with Android native, as it will probably be the first mobile OS the application will be published to, but after some struggles learning a new language, and trying to get used to new a IDE and API, I switched to PhoneGap, as it was always the plan to have the application on more than one OS. Additionally, I have years of experience with web development.
So now I come the issue I was facing, as my application will be handling a LOT of images, is how to store all these images.
I have couple of ideas of what could be done:
Have some sort of cloud storage which hosts the images, and then when application is run it would download all the images to the device, but that would take a lot of storage on the device and it might take too long.
Cloud storage, but when application is run it downloads them into a cache to just use the ones that are currently needed and then discard them after user is done with them, maybe even try to download just one by one when needed.
The 2nd approach makes the most sense to me regarding performance and device storage, but it would force the application to always be online. In the 1st example that would not be necessary. I can't help but think there is a better way to tackle this.
Also what would be the best path here to go native, which means tighter control of the native API, but losing the functionality of being generic and have to do the same thing for different OS in each language separately or in a ways stay somehow in hybrid environment?
My app does something similar to this, but we do it all in Java, so if you do decide to go back down that route, this could help. We have a large amount of images (more than 30,000) hosted in the cloud. The user can browse through these images (and we have pre-generated thumbnails of each) and on the client we have the following:
Placeholder image that is a subclass of ImageView, which also handles performing an asynchronous task of downloading the image.
Memory cache of images using Android's LRUCache class. The cache is initialized at startup to be about 1/8th of the available memory.
A DiskLRU Cache to store images on the phone's SD card. I'm currently using Jake Wharton's DiskLRUCache
This does a decent job, but you'll also want to look at Google's Managing Bitmaps article, and figure out how you're going to recycle bitmaps if you're running on Gingerbread or earlier.
Oh and I almost forgot, you might also want to look into Picasso
Phonegap/cordova apps are just native apps with most functionality in a webview, so you could leverage both the picasso code (via a native plugin) and use phonegap.
That said, I'd probably do what Carl does, but write a plugin for PhoneGap that calls into different native code for each platform.
Since you know the app is going to be cross platform, it makes sense to trial PhoneGap to see if it can perform well enough.
You could also look at doing the caching in js, leveraging some of the ideas here: https://github.com/bperin/imageCache

Making an android app with 365 imageviews

I need help understanding how I would approach making an Android application that allows the user to scroll through 365 different bitmaps. I'm worried that I will go outside of the memory limits that android allows. I've tried googling, but haven't been able to understand how to approach the problem. Could someone write a very brief hint at where i can start researching this?
It depens on the source of those. I think you would like to use "lazy load ListView".
Checkout this
how about using any class that extends from AdapterView (like listView, gridView,...) ?
the idea is that since the user doesn't really see all of the views at the same time , you can re-use views that are being disappeared when scrolling , and show them as new ones .
watch the video of google called "the world of listView" .
anyway , if you don't wish to use this solution , consider being very "cheap" on the memory , as you are correct - android will kill your app if you use too much RAM .
you can read about handling bitmaps here .

Android: Which is a better design choice? Lazy Loading or Initial Waiting Time?

I have been an avid fan of lazy loading but yesterday I was talking with a fellow programmer who showed me another application and expressed how happy he was about the initial waiting time that the application takes (Android Marketplace to be precise) to load up the list and allow him to scroll smoothly than implement lazy loading and make his life miserable...
Though I can get lazy loading to work using background downloading of images to make the whole feel uninterrupted, I still am not sure which is the preferred design methodology... Any suggestions?
A major component of UI design is to make the UI feel response. Now, realistically, there is always going to be waiting time - applications have to load, data needs to be populated, etc. The trick here is to always give the user feedback that something is being accomplished and, of course, to not spend too much time at loading screens (I'm looking at you PS1!).
In the case of your application, I would concur with your friend that lazy loading can be somewhat annoying. Nobody wants the screen to stutter/pause as they scroll (as an example). In addition to this, people have become accustomed to some waiting time for applications to load a computer. But, there is a fine line between "I'm willing to wait" and "screw this, I'm not using this app."
Of course, at some point, it does become personal preference of the way of doing this. This is where receiving feedback from your users is a necessity (it's not called user interface design for nothing).
I am in favor of a hybrid. The information needed for a user interface can often be separated in two:
Textual information.
Visual information.
I always try to preload the textual information, so that I get a user interface that the user can begin interacting with. And then I begin lazily loading visual information on background threads.
If the user interface needs to be stalled, always show a progress indicator, even if it is an determined indicator. The placebo effect of a user interface that is at least moving can not be underestimated. Perceived responsiveness can even be better than actual responsiveness.

Categories

Resources