OpenNoteScanner icon indicating copy to clipboard operation
OpenNoteScanner copied to clipboard

Inefficient API is used

Open struggggle opened this issue 8 years ago • 3 comments

Dear developers,

I found an inefficient API, setImageURI(), is used in OpenNoteScanner.

For setImageURI(), Google says this: https://developer.android.com/reference/android/widget/ImageView.html#setImageURI(android.net.Uri) " This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead. "

I noticed that in the following code, setImageURI() is used: com.todobom.opennotescanner.views.TouchImageView.java (line number: 181) https://github.com/ctodobom/OpenNoteScanner/blob/master/app/src/main/java/com/todobom/opennotescanner/views/TouchImageView.java

Do you think the use of setImageURI() will affect OpenNoteScanner's performance? If so, maybe we should move Bitmap reading and decoding to a background thread.

Thanks.

struggggle avatar Feb 19 '17 09:02 struggggle

Thank you for your report @struggggle !

This class was got from https://github.com/MikeOrtiz/TouchImageView , you can open a ticket there if there isn't any already!

allgood avatar Feb 19 '17 14:02 allgood

@ctodobom I have checked the class there, and these APIs are still used in it (the class was written 3 years ago). https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java#L175

struggggle avatar Feb 19 '17 15:02 struggggle

Can you submit a Pull Request or a patch for it? If you do and it pass on my tests, I will merge it!

allgood avatar Feb 20 '17 13:02 allgood