I have an App with retrofit and I make some calls to an Api (like a LogIn in this case), some of them take a few seconds to load, so I want to know when I should make a loading screen and lock the interaction with the user. I see that ProgressDialog is deprecated now, and they don't display it but they lock the interaction with the view. What should be better?
First of all it is not ProgressBar but it is ProgressDialog because it locks down user interaction until it hides.
You can use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.Here
A skeleton screen helps load a user interface gradually, a little at a time. This means that the barebones UI displays first. Then the loaded content is gradually populated on-screen.
Shimmer effect was created by Facebook to indicate a loading status, so instead of using ProgressBar or usual loader use Shimmer for a better design and user interface.
Related
This question already has an answer here:
How can I display a Progress at start up application in android
(1 answer)
Closed 5 years ago.
I have a heavy user interface that can delay the application load. I want to show an preloader before the UI of activity loaded. note that my ui is in xml file
EDIT:
If you want to load 10 tabs in a view pager, use a FragmentStatePagerAdapter which only loads neighboring tabs(default behavior).
If the heavy UI you specify is only the UI elements, then the app must freeze while loading it. So you'd better show a non-cancelable dialog(without animation) with loading message and after a few moment (like 200ms) load up your UI and explicitly dismiss the dialog.
But if the heavy stuffs is not just UI, maybe some calculations or image processing, just do it in a background thread while showing a dialog with progress and cancel the dialog when the task is done.
#Hassan according to me if on clicking the launcher icon if it takes sometime for your application to render the first screen(perhaps giving a black screen in between). This needs to be corrected in your application.
On the contrary if your applications main screen requires population/retrieval of certain resources for effectively engaging the users, You can possibly do something like a splash screen(outdated) where you do all "population/retrieval" and then simply pass data to your heavy UI.
Now regarding the progress bar if this fetching of data is small, you can give an indeterminate "custom"(some moving animation that would suite your app) progress bar,else if its something like a download you can easily track its progress and show in a horizontal progressbar
You sure can! You are describing a preloader. Here is a nice example of one https://github.com/rtheunissen/md-preloader
You'll have to add more info to your question to get a specific answer, but there are a few basic principles.
You make your life a lot easier if you use a preloader which doesn't show progress of the load, it just goes round and round, because the speed of some load processes can't be measured.
If its a data-load which is taking the time (such as a call to an API), you might want to set a variable for "loading" to true at the top of your script, then when the data has resolved, set it to "false". In your view, have a state or a conditional element which hides / unhides the preloader.
If lots of images are slowing down the page, you might want to look into "lazy-loading" or using "infinite scroll" to only show content when the UI needs to display it on screen.
Thats all the info I can give without more information on the code you have so far. Hope that helps!
I have an app where an action by the user sometimes causes the app to get data from the server before it can be displayed, like getting detail info for an item (the info is too large to preload it for all items) or refreshing all data.
While this is in process i don't want the user to do anything else. What is the guideline to display a "please wait" message? Ideally it should be possible for the user to cancel the request if he wants to.
I can do it with an alert dialog, but the operation usually takes just half a second to a second, and imo it looks really strange for an alert dialog to pop up just for a moment, maybe not even long enough to be able to read the message.
Another option i see is the snack bar, but it doesn't prevent the user from doing anything else or navigate away.
Is there a guideline or best practice what to do in this scenario?
I'm using Xamarin.Android, but i don't think that matters.
You can show a loading circle in place where the content being loaded will be displayed like this. When it finishes, replace the loading circle with the content.
Actually "i don't want the user to do anything else" is not acceptable in most Android design patterns. Android app should allow the user to take control of the app.
About canceling the request, you can add a cancel button near the loading circle, or add a cross inside the circle which will stop the process when being pressed. The latter is preferred.
For more patterns see this.
About progress dialog
As far as I know, progress dialog which block the user interaction is discouraged in the new Android. But I am sorry that I cannot find the reference yet, maybe somewhere in Material Design guidelines document. However, because you are the developer, it's all up to you :D.
Check out the documentation on AsyncTask.
I would do the long running task in an AsyncTask, show a ProgressDialog in it's onPreExecute method and hide it after it finised, in onPostExecute.
To prevent the user from closing the dialog you can use the Dialog.setCancelable() method.
You can define a custom layout for your Dialog and set it via the setContentView() method.
I'd like to start my app and show the main screen instantly. Half of the info on the screen will be loaded form local storage and the other half will be from a web service. Each of these will be on two different fragments. I'd like to display a loading indeterminate progress bar while the data is being fetch from the webservice, similar to how the Google Play Store loads it's app date as shown below by the two states below:
My thoughts on implementing it are as follows:
Load the fragment in with the progress bar & the normal screen (hidden) in one layout. Once the data from the web service has been collected, populate the normal screen, then hide the view group containing the progress bar and show the viewgroup with the data.
Is this best practice? Are the better ways to do it than this?
Thanks in advance.
You can implement it yourself but you can also use a simple library called ProgressFragment
avalaible on github
I have searched everywhere and read the official doc of Google. But I still don't see the difference between them.
When should we use ProgressBar and when should we use ProgressDialog?
ProgressBar:
ProgressDialog:
The ProgressBar is a View, ProgressDialog is a Dialog.
While the answers here are informative, none really address the question.
Use a ProgressDialog when you want to prevent the user from
interacting with the application while waiting. The Dialog aspect
freezes the user from doing anything until it is dismissed. Note how the UI behind the ProgressDialog is grayed-out and inaccessible.
Use a ProgressBar to indicate that something in your app is still
waiting (loading, thinking, etc.) while the user may still interact with
other parts. In this image, the user can still fill out forms while waiting for the gps to respond.
(Thanks to Johnny S for the image of the ProgressDialog.)
ProgressBar is a View (like TextView, ImageView, Button, etc..), which can be used in your layout to show some progress.
ProgressDialog is a Dialog with 'built-in' ProgressBar. Dialogs can be used to make user wait while something is being computed. ProgressDialog makes it easier to show progress of your computation in dialog.
In addition to the differences pointed out in the rest of answers, you should take into account the following recommendation from Dialogs # Android Developer:
Avoid ProgressDialog
Android includes another dialog class called ProgressDialog that shows
a dialog with a progress bar. However, if you need to indicate loading
or indeterminate progress, you should instead follow the design
guidelines for Progress & Activity and use a ProgressBar in your
layout.
It may be also usefull to consider the following answers:
https://stackoverflow.com/a/12559601/2482894
How to avoid ProgressDialog in Android
When your iterations is countable (doing operations in loop, executing code x times etc.) use ProgressBar, if task is not countable status (like invoking web service) use ProgressDialog
From the android documentation
ProgressBar:Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has
progressed; the application can change the amount of progress
(modifying the length of the bar) as it moves forward. There is also a
secondary progress displayable on a progress bar which is useful for
displaying intermediate progress, such as the buffer level during a
streaming playback progress bar.
ProgressDialog:A dialog showing a progress indicator and an optional
text message or view. Only a text message or a view can be used at the
same time.
I have code that reloads images via HTTP from the main thread and displays them, right after setting up the layout.
This is now deprecated since network access must no longer be done from the main thread.
At first, I changed it to load the images from a a background thread and then update the ImageViews. But, the user experience changed since the images now "pop out."
Is it possible to make the images load seamlessly?
Or, should I display a progress bar or status message while the images reload.
Seamless loading would require to delay to display your entire ui which is probably not what you want. You could use an animation to fade in your images once they are loaded.