-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 2 - Albums #14563
Conversation
3113c54
to
8300f8e
Compare
7eaf56e
to
0fe430b
Compare
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.
LGTM 🚀
promise.reject(ERROR_MEDIA_LIBRARY_CORRUPTED, "Media library is corrupted") | ||
return null | ||
} | ||
return File(fileInAlbum.parent!!) |
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.
Must the parent of the fileInAlbum
exist?
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.
When it is a file (the if
above), it must have a parent directory 😉
internal fun interface AssetFileStrategy { | ||
@Throws(IOException::class) | ||
fun apply(src: File, dir: File, context: Context): File | ||
|
||
companion object { | ||
val copyStrategy = AssetFileStrategy { src, dir, _ -> MediaLibraryUtils.safeCopyFile(src, dir) } | ||
val moveStrategy = AssetFileStrategy strategy@{ src, dir, context -> | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && src is MediaLibraryUtils.AssetFile) { | ||
val assetId = src.assetId | ||
val assetUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, assetId.toLong()) | ||
val newFile = MediaLibraryUtils.safeCopyFile(src, dir) | ||
context.contentResolver.delete(assetUri, null) | ||
return@strategy newFile | ||
} | ||
val newFile = MediaLibraryUtils.safeMoveFile(src, dir) | ||
context.contentResolver.delete( | ||
MediaLibraryConstants.EXTERNAL_CONTENT, | ||
"${MediaStore.MediaColumns.DATA}=?", arrayOf(src.path) | ||
) | ||
newFile | ||
} | ||
} | ||
} |
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.
I like the idea of putting implementation in the companion object in that case 💪
return album | ||
} | ||
|
||
public override fun doInBackground(vararg params: Void?): Void? { |
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.
The type of this function looks stupid 😛 But we can't do anything with it right now.
0fe430b
to
aae9ecc
Compare
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) 👇
|
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.
Looks good 👍
Why, How etc...
See #14562 description for details.
This is part of a PR stack:
expo.modules.medialibrary.albums
package