-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Added support for Google Drive Shortcuts #84
Conversation
@@ -196,6 +196,19 @@ class FilesFragment : BaseFragment() { | |||
findNavController().navigate(action) | |||
} else if (file.isVideoFile) { | |||
launchVideoPlayer(file) | |||
} else if (file.isShortcut) { | |||
if (file.shortcutDetails.targetMimeType == "application/vnd.google-apps.folder") { |
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.
Instead of doing this create variables such as here for cleaner code
val isVideoFile = mimeType.startsWith("video/") | |
val isFolder = mimeType == "application/vnd.google-apps.folder" |
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 suggested changes. Type safety is a bit messy I suppose, but should work fine due to the logic flow. I have never worked with kotlin or android before, feel free to suggest further changes.
@@ -5,11 +5,12 @@ import zechs.drive.stream.utils.util.Converter | |||
|
|||
@Keep | |||
data class DriveFile( | |||
val id: String, | |||
var id: String, |
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 do not understand the purpose of making it non-final.
I can see its used to handle id
for shortcuts for which you should rather use Kotlin copy() function and re-assign the id
something like file.copy(id=shortcut.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.
Made suggested edit.
@@ -21,5 +21,9 @@ data class DriveFile( | |||
|
|||
val isShortcut = mimeType == "application/vnd.google-apps.shortcut" | |||
|
|||
val isShortcutFolder = shortcutDetails.targetMimeType == "application/vnd.google-apps.folder" | |||
|
|||
val isShortcutVideo = shortcutDetails.targetMimeType?.startsWith("video/") |
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.
Pretty sure isShortcutVideo
would return Boolean?
. It can be avoided by adding a default false
using the elvis operator
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!
No description provided.