Skip to content
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

[media-library] Refactor to Kotlin 3 - Album migration #14564

Merged
merged 15 commits into from Oct 6, 2021

Conversation

barthap
Copy link
Contributor

@barthap barthap commented Sep 29, 2021

Why, How etc...

See #14562 description for details.


This is part of a PR stack:

  1. [media-library] Refactor to Kotlin 1 - Base module #14562
  2. [media-library] Refactor to Kotlin 2 - Albums #14563
  3. This PR - rewritten album migration to Kotlin, extracted it to expo.modules.medialibrary.albums.migration package
  4. [media-library] Refactor to Kotlin 4 - Asset management #14565
  5. [media-library] Refactor to Kotlin 5 - Utilities #14566
  6. Coroutines + refactor error handling (No PR yet)

@barthap barthap force-pushed the @barthap/media-lib/kotlin/pt2-albums branch from 0fe430b to aae9ecc Compare October 4, 2021 17:17
@barthap barthap force-pushed the @barthap/media-lib/kotlin/pt3-migration branch from 71e3655 to d1839c3 Compare October 5, 2021 08:21
@barthap barthap marked this pull request as ready for review October 5, 2021 08:23
Copy link
Contributor

@lukmccall lukmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job 🥇

Comment on lines +44 to +52
).use { albumCursor ->
if (albumCursor != null && albumCursor.moveToNext()) {
val dataColumnIndex = albumCursor.getColumnIndex(MediaStore.Images.Media.DATA)
val fileInAlbum = File(albumCursor.getString(dataColumnIndex))
if (fileInAlbum.isFile) {
return File(fileInAlbum.parent ?: return null)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
).use { albumCursor ->
if (albumCursor != null && albumCursor.moveToNext()) {
val dataColumnIndex = albumCursor.getColumnIndex(MediaStore.Images.Media.DATA)
val fileInAlbum = File(albumCursor.getString(dataColumnIndex))
if (fileInAlbum.isFile) {
return File(fileInAlbum.parent ?: return null)
}
}
}
)?.use { albumCursor ->
if (albumCursor.moveToNext()) {
val dataColumnIndex = albumCursor.getColumnIndex(MediaStore.Images.Media.DATA)
val fileInAlbum = File(albumCursor.getString(dataColumnIndex))
if (fileInAlbum.isFile) {
return File(fileInAlbum.parent ?: return null)
}
}
}

You can remove the null check, but I'm not sure if that looks better 🤷‍♂️

private val albumDirName: String,
private val promise: Promise
) : AsyncTask<Void?, Void?, Void?>() {
override fun doInBackground(vararg voids: Void?): Void? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do something with that type to make it looks better. If you use a different type here (Unit or Any), you don't have to return null. However, I know, you're going to rewrite that using corutines. So leave it as it's.

Copy link
Contributor

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, no objections

Base automatically changed from @barthap/media-lib/kotlin/pt2-albums to master October 6, 2021 09:33
@expo-bot
Copy link
Collaborator

expo-bot commented Oct 6, 2021

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider (it's optional) adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against fb22cdb

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Oct 6, 2021
@barthap barthap merged commit be43f19 into master Oct 6, 2021
@barthap barthap deleted the @barthap/media-lib/kotlin/pt3-migration branch October 6, 2021 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants