File tree Expand file tree Collapse file tree 4 files changed +13
-23
lines changed
java/com/github/file_picker Expand file tree Collapse file tree 4 files changed +13
-23
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ afterEvaluate {
5858 from components. release
5959 groupId = ' com.github.majidarabi'
6060 artifactId = ' file-picker'
61- version = ' 0.0.9 '
61+ version = ' 0.1.0 '
6262 }
6363 }
6464 }
Original file line number Diff line number Diff line change 33 package =" ir.one_developer.file_picker" >
44
55 <uses-permission android : name =" android.permission.READ_EXTERNAL_STORAGE" />
6+ <application android : requestLegacyExternalStorage =" true" />
67
78</manifest >
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import com.bumptech.glide.request.RequestListener
1212import com.bumptech.glide.request.target.Target
1313import com.github.file_picker.FileType
1414import com.github.file_picker.extension.getMusicCoverArt
15- import com.github.file_picker.extension.pathName
15+ import com.github.file_picker.extension.lastPathTitle
1616import com.github.file_picker.extension.size
1717import com.github.file_picker.model.Media
1818import ir.one_developer.file_picker.R
@@ -50,12 +50,12 @@ internal class ItemVH(
5050 item.file.getMusicCoverArt()
5151 }
5252 FileType .IMAGE -> {
53- tvPath.text = item.file.pathName ()
53+ tvPath.text = item.file.lastPathTitle ()
5454 ivMediaIcon.setImageResource(R .drawable.ic_image)
5555 item.file
5656 }
5757 FileType .VIDEO -> {
58- tvPath.text = item.file.pathName ()
58+ tvPath.text = item.file.lastPathTitle ()
5959 ivMediaIcon.setImageResource(R .drawable.ic_play)
6060 item.file
6161 }
Original file line number Diff line number Diff line change @@ -29,34 +29,23 @@ internal fun File.size(): String = when {
2929 *
3030 * @return
3131 */
32- internal fun File.pathName (): CharSequence {
32+ internal fun File.lastPathTitle (): CharSequence {
3333 val paths = path.split(" /" )
34- paths.forEachIndexed { index, title ->
35- if (index == paths.lastIndex - 1 ) {
36- return title
37- }
38- }
34+ val titleIndex = paths.lastIndex - 1
35+ if (titleIndex >= 0 ) return paths[titleIndex]
3936 return " "
4037}
4138
42- /* *
43- * Is video
44- */
45- internal val File .isVideo
46- get() = this .name.isVideo()
47-
4839/* *
4940 * Get music cover art
5041 *
5142 * @return
5243 */
53- internal fun File.getMusicCoverArt (): Bitmap ? {
44+ internal fun File.getMusicCoverArt (): Bitmap ? = try {
5445 val mData = MediaMetadataRetriever ()
5546 mData.setDataSource(path)
56- return try {
57- val art = mData.embeddedPicture
58- BitmapFactory .decodeByteArray(art, 0 , art?.size ? : 0 )
59- } catch (e: Exception ) {
60- null
61- }
47+ val art = mData.embeddedPicture
48+ BitmapFactory .decodeByteArray(art, 0 , art?.size ? : 0 )
49+ } catch (e: Exception ) {
50+ null
6251}
You can’t perform that action at this time.
0 commit comments