Mini-Ware / Quoting-Words

Android app that gives random quotes with background images
https://github.com/Mini-Ware/Quoting-Words/releases
Apache License 2.0
3 stars 1 forks source link

Optimise image loading #1

Closed Mini-Ware closed 1 year ago

Mini-Ware commented 2 years ago

App crashes on phones with lower memory

czlucius commented 2 years ago

You can store the files in mipmap in res, and access them through R.mipmap.(image name) I see that you use https://github.com/Mini-Ware/Quoting-Words/blob/5edfca6deef38175d59ee65667d2f65430e750e9/app/src/main/java/com/github/miniware/quotingwords/Generator.java#L84-L98 to load the images, and add @drawable in Feed.java, which is not the recommended way of loading images. (You should use R.drawable.(image name) instead, it will return the same thing.)

I can make a PR if you want (will be doing this soon)

If the problem persists, can try doing:

Mini-Ware commented 2 years ago

Oh I didn't know about that, I will try it and yeah sure you can make a PR too

czlucius commented 2 years ago

For conversion of images, you should try right-clicking them in Android Studio and selecting "Convert to WebP". Depending on your application needs, you may opt for a more lossy encoding, which reduces space and memory usage but may cause reduced clarity. With lossless conversion to WebP, there are no space savings hence I did not convert them.

Mini-Ware commented 2 years ago

I see, thanks for letting me know. I am reviewing the PR now.

czlucius commented 2 years ago

By the way, I don't know how the application performs on low memory devices, you should test for that(perhaps with an Android emulator)

You may want to keep this open until that is resolved.

But there are some things I see that can be improved(unrelated to image loading):

Mini-Ware commented 2 years ago

Alright, thanks for bringing those up too. Will work on them.