Click here to Skip to main content
14,299,664 members

Adding Loader/Progress to your xamarin App using Postsharp.

Rate this:
5.00 (1 vote)
Please Sign up or sign in to vote.
5.00 (1 vote)
26 Aug 2019CPOL
Jakob Nielsen’s 10 heuristics for design are considered the bible of user experience, they are designated “heuristics” since they are wide general guidelines and not explicit ease of use rules..
Image 1

Jakob Nielsen’s 10 heuristics for design are considered the bible of user experience, they are designated “heuristics” since they are wide general guidelines and not explicit ease of use rules.

If you are interested to see some examples of Nielsen heuristics in mobile apps Bharti Bhagtani has an awesome post showing them.

In this series i will show how you can satisfy all Nielsen 10 heuristics by investing maximum 10 minutes extra in your application.

1- Visibility of system status

In a lot of cases you will have to deal with async methods that will take quite time for action completeness. In this case you must show the user a progress indicator to tell him that his action is in progress.

We will do this simply by implementing a Progress Advice and use it on the async methods in our viewmodel.

<a href="https://medium.com/media/9094cd190d5bb438383ff503d2904f7d/href">https://medium.com/media/9094cd190d5bb438383ff503d2904f7d/href</a>

And you can use it simply by decorating the async method

If the method is not taking any Progress<Int> or cancellation Token parameter , the progress will be indeterminate and without a cancellation button.

[ShowProgress("Downloading")]
public async Task TestLoader()
{
await Task.Delay(1000);
}

If the method use has a IProgress<int> parameter the progress will be determined and you can report from your method the effective progress.

make sure the progress parameter has default value null as it will be injected from the the aspect.

[ShowProgress("Downloading")]
public async Task TestLoader(IProgress<int> progress=null)
{
await Task.Delay(1000);
progress.Report(50);
await Task.Delay(1000);
progress.Report(1000);
}

and you can also use a CancellationToken to allow the user to cancel the operation.

[ShowProgress("Downloading")]
public async Task TestLoader(CancellationToken cancellationToken=default(CancellationToken))
{
await Task.Delay(1000,cancellationToken);
}

you will need to get Postsharp installed in your machine and this 2 nuggets

Image 2

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

DotnetShtien
Austria Austria
I am a software engineer at PlanRadar currently living in Vienna, Austria. My interests range from technology to web development. I am also interested in programming, xamarin, and mobile development.

Comments and Discussions

 
-- There are no messages in this forum --
Technical Blog
Posted 26 Aug 2019

Tagged as

Stats

1.6K views
2 bookmarked