-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: bitmap wallpaper setting on main thread #132
fix: bitmap wallpaper setting on main thread #132
Conversation
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
viewModel.downloadUUID = DownloadWorker.enqueueDownload( | ||
applicationContext, | ||
DownloadAction.WALLPAPER, url, photo.fileName, photo.id | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viewModel.downloadUUID = DownloadWorker.enqueueDownload( | |
applicationContext, | |
DownloadAction.WALLPAPER, url, photo.fileName, photo.id | |
) | |
viewModel.downloadUUID = DownloadWorker.enqueueDownload( | |
applicationContext, | |
DownloadAction.WALLPAPER, | |
url, | |
photo.fileName, | |
photo.id | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crazyhitty code formatting has been applied.
Co-authored-by: Kartik Sharma <[email protected]>
Co-authored-by: Kartik Sharma <[email protected]>
private fun setWallpaperWithBitmap(bitmap: Bitmap) { | ||
lifecycleScope.launch { | ||
withContext((Executors.newSingleThreadExecutor().asCoroutineDispatcher())) { | ||
wallpaperManager.setBitmap(bitmap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setBitmap
throws IOException in case if something goes wrong while setting wallpaper. Please handle the exception.
Reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the necessary changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great! Just left a few comments. Out of curiosity, is there a specific reason that you wanted to fix this?
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/b_lam/resplash/ui/photo/detail/PhotoDetailActivity.kt
Outdated
Show resolved
Hide resolved
Yes, I can see the freezing of the main thread when were preparing bitmap from URI and then setting it as wallpaper. |
Awesome work, thanks for doing this! If you're interested in working on other parts of Resplash just let me know :) |
sure, @b-lam. Do we have any pending features or existing tasks? |
Currently I'm working on implementing the new-ish topics endpoint (https://unsplash.com/documentation#list-topics). The work I've done so far is on this branch https://github.com/b-lam/Resplash/tree/add-topics. Some of the other things I have on my list of things to do is migrating from Paging 2 to Paging 3, fixing a lockscreen wallpaper issue that some users have mentioned, adding support for auto wallpaper intervals less than 15 minutes. I should probably start adding some of my pending work to the Github issues section. If you are a user of Resplash, feel free to do anything that you think would make the app better! |
Presently, when the
Wallapaper Manager
is unable to find the crop and set activity. App decodes the image and sets the bitmap on the main thread which should be avoided.