-
Notifications
You must be signed in to change notification settings - Fork 181
put disk access into background thread? #649
base: master
Are you sure you want to change the base?
Conversation
put bitmap decode from file into background thread.
put bitmap decode from file into background thread.
put bitmap decode from file into background thread.
put write to files into background thread.
Hi, Yes these requests should not be on the UI thread, I guess they aren't impacting performance through which is why it's been left. Unfortunately your approach with an anonymous async task would not handle activity recreation due to say orientation changes. We could either refine this pr or maybe just use something like Picasso (overkill?) to avoid having to write to the boilerplate code. Pull requests should also be made against the dev branch. |
Also you don't really want to introduce threads in utility classes (like FileUtils), the user of such classes is responsible to call them in the proper way (background thread, etc). BTW, stating an anonymous background thread that you have no way of controlling is rarely a a good idea. |
writeToFile is already invoked in background thread.
Thanks for the comments. I found you use "DetachableAsyncTask" instead of AsyncTask to handle activity recreation, so I refactored the two cases to use DetachableAsyncTask. But there're two problems:
p.s., for NotificationHandler and FileUtils, I remove thread because the disk operations are already invoked in background threads. |
For this to work, you need to actually call attach()/detach() in onCreate()/onRetainNonConfigurationInstance(), etc. Check Before making major changes, please discuss first. Using a library that all of this easier might be the right choice. I haven't used Picasso but it might worth looking at, at least for loading app icons, (To clarify: changing a couple of activities to use detachable tasks is not a major change. Changing how the whole app handles background tasks is. Also do make you PR to the dev branch.) |
Hi, I'm doing research on performance for Android apps. I found some event handlers access disk (read/write files, decode bitmap) from UI thread, but Android docs suggest us to avoid such blocking calls in UI thread. Do they lead to any responsiveness issues?
I tried to refactoring by putting them into background tasks. Looking forward to see your comments.