In the project I'm currently working on there are plenty of caching which is done on the main thread which makes the app laggy. My plan is to make asynchronous variants of these, but still keeping the synchronous calls for easier chaining when combined in asyncTasks. The problem I have it that I want to prevent the usage of the caching functions in GUI thread in some intuitive way. Any ideas? Is it possible? Is it possible to mark a method with an annotation which prevents it from being called on the GUI thread?
http://androidannotations.org/ provides a library that leverages the use of annotations to deal with this. They have annotations such as @UiThread
and @Background
that essentially replace the need to use runOnUiThread()
and AsyncTask
respectively.
If you're interested, here's a paper discussing a similar system for dealing with the blocking of UI thread operations from non-UI threads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With