geometer/FBReaderJ — pull request #185 by yulin2 (2014-02-16 18:35:32+00:00)
Title: potential improvement for responsiveness in FBReaderJ

Dear developers of FBReaderJ,

I'm a Ph.D. student and I'm doing research related to Android apps'
responsiveness. I found there are some cases in FBReaderJ that the
database is queried, or bitmap is generated in UI thread. Does this
affect the responsiveness of the app? An optimization could be
extracting these operations into AsyncTask.

For example, in ImageViewActivity.java, line 78 generates a bitmap
(invokes "getImageData"), which is a long computation. Is it better to
put them into a AsyncTask, so the onCreate method won't be blocked? I
attach a sample patch here. Note that there are data races on
"myBitmap" after this change, but I think the races won't lead to bugs
because you've checked if "myBitmap" is null before use it in "onDraw"
method.

Similarly, I also transformed ZLAndroidPaintContext.java,
BookInfoActivity.java, NetworkBookInfoActivity.java, since they are
also trying to get Bitmap in UI thread.

Also, in BookInfoActivity.java and LibraryActivity.java, there are
several access to IO/database in UI Thread. E.g.,
BookInfoActivity.java line 116 invokes "myBook.reloadInfoFromFile()".
This also lead to a potential responsiveness issue. Thus, I tried to
move it into AsyncTask.	Similarly, LibraryActivity.java invokes
"myRootTree.Collection.saveBook" several times,	which executes a
database transaction.

There should be some other places that can be improved. I can't report
all of them since I checked the code manually and it takes time. However,
what do you think about these improvements? My thought is we can improve the
responsiveness if we try to avoid the access to IO/Database, computing bitmap in
UI thread.

Thanks,
Yu