This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Add Video Thumbnail preview and set default theme to light #53
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
14e8572
- Update Glide Version
alishari 6ffc7c2
Set Default theme to Light
alishari 245eba2
Showing Preview of Multimedia
alishari dbe476a
- Update Glide Version
alishari 7926060
Merge remote-tracking branch 'origin/master'
alishari bf35ea6
Showing Preview of Multimedia
alishari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,16 +28,16 @@ | |
/** | ||
* A sample which demonstrates how appropriate methods | ||
* can be overwritten in order to enable enhanced | ||
* capabilities, in this case showing thumbnails of images. | ||
* capabilities, in this case showing thumbnails of images and thumbnail of videos. | ||
* <p/> | ||
* I am still listing all files, so I extend from the ready made | ||
* SD-card browser classes. This allows this class to focus | ||
* entirely on the image side of things. | ||
* | ||
* <p/> | ||
* To load the image I am using the super great Glide library | ||
* which only requires a single line of code in this file. | ||
*/ | ||
public class ImagePickerFragment extends FilePickerFragment { | ||
public class MultimediaPickerFragment extends FilePickerFragment { | ||
|
||
/** | ||
* An extremely simple method for identifying images. This | ||
|
@@ -60,7 +60,22 @@ protected boolean isImage(File file) { | |
} | ||
|
||
/** | ||
* Overriding this method allows us to inject a preview image | ||
* An extremely simple method for identifying videos. This | ||
* could be improved, but it's good enough for this example. | ||
* | ||
* @param file which could be an video | ||
* @return true if the file can be previewed, false otherwise | ||
*/ | ||
private boolean isVideo(File file) { | ||
if (isDir(file)) { | ||
return false; | ||
} | ||
return file.getPath().endsWith(".mp4")|| | ||
file.getPath().endsWith(".MP4"); | ||
} | ||
|
||
/** | ||
* Overriding this method allows us to inject a preview image and thumbnail of videos | ||
* in the layout | ||
* | ||
* @param vh to bind data from either a file or directory | ||
|
@@ -78,6 +93,10 @@ public void onBindViewHolder(DirViewHolder vh, int position, File file) { | |
if (isImage(file)) { | ||
vh.icon.setVisibility(View.VISIBLE); | ||
Glide.with(this).load(file).centerCrop().into((ImageView) vh.icon); | ||
} else if (isVideo(file)) { | ||
vh.icon.setVisibility(View.VISIBLE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not much point in having to blocks with the exact same code. Would make sense to unify them I think, something like if (isMultimedia(file)) {
//...
} or if (isPreviewable(file)) {
//...
} |
||
Glide.with(this).load(file).centerCrop().into((ImageView) vh.icon); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Yup this naming makes sense now