From cf768d7ffff5de6e86b58d41f8c3d0947f17160f Mon Sep 17 00:00:00 2001 From: deji Date: Mon, 25 Dec 2023 13:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E9=95=BF=E6=9D=83=E9=99=90=E6=97=B6?= =?UTF-8?q?=E9=97=B4~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 3 +-- .idea/misc.xml | 3 +-- .idea/modules.xml | 12 ++++++++--- .idea/runConfigurations.xml | 12 ----------- .../dmcbig/mediapicker/PickerActivity.java | 4 ++++ .../com/dmcbig/mediapicker/entity/Media.java | 21 ++++++++++++++++++- 6 files changed, 35 insertions(+), 20 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 54aeb3e..260bd4b 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59..bd7b6ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,5 @@ - - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 9eb0f9e..049b46d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,9 +2,15 @@ - - - + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/mediapicker/src/main/java/com/dmcbig/mediapicker/PickerActivity.java b/mediapicker/src/main/java/com/dmcbig/mediapicker/PickerActivity.java index 252edcd..24f9661 100644 --- a/mediapicker/src/main/java/com/dmcbig/mediapicker/PickerActivity.java +++ b/mediapicker/src/main/java/com/dmcbig/mediapicker/PickerActivity.java @@ -285,6 +285,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { ArrayList selects=new ArrayList<>(); for(int i=0; i= Build.VERSION_CODES.KITKAT) { + int flag = Intent.FLAG_GRANT_READ_URI_PERMISSION; + getContentResolver().takePersistableUriPermission(uri, flag); + } String[] MEDIA_PROJECTION = { MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.DISPLAY_NAME, diff --git a/mediapicker/src/main/java/com/dmcbig/mediapicker/entity/Media.java b/mediapicker/src/main/java/com/dmcbig/mediapicker/entity/Media.java index 13431e6..07ed762 100644 --- a/mediapicker/src/main/java/com/dmcbig/mediapicker/entity/Media.java +++ b/mediapicker/src/main/java/com/dmcbig/mediapicker/entity/Media.java @@ -1,5 +1,6 @@ package com.dmcbig.mediapicker.entity; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; @@ -9,6 +10,7 @@ */ public class Media implements Parcelable { + public String uri; public String path; public String name; public String extension; @@ -19,6 +21,22 @@ public class Media implements Parcelable { public String parentDir; public Media(String path, String name, long time, int mediaType, long size, int id, String parentDir) { + this.uri = ""; + this.path = path; + this.name = name; + if (!TextUtils.isEmpty(name) && name.indexOf(".") != -1) { + this.extension = name.substring(name.lastIndexOf("."), name.length()); + } else { + this.extension = "null"; + } + this.time = time; + this.mediaType = mediaType; + this.size = size; + this.id = id; + this.parentDir = parentDir; + } + public Media(String uri,String path, String name, long time, int mediaType, long size, int id, String parentDir) { + this.uri = uri; this.path = path; this.name = name; if (!TextUtils.isEmpty(name) && name.indexOf(".") != -1) { @@ -32,7 +50,6 @@ public Media(String path, String name, long time, int mediaType, long size, int this.id = id; this.parentDir = parentDir; } - @Override public int describeContents() { @@ -41,6 +58,7 @@ public int describeContents() { @Override public void writeToParcel(Parcel dest, int flags) { + dest.writeString(this.uri); dest.writeString(this.path); dest.writeString(this.name); dest.writeString(this.extension); @@ -52,6 +70,7 @@ public void writeToParcel(Parcel dest, int flags) { } protected Media(Parcel in) { + this.uri = in.readString(); this.path = in.readString(); this.name = in.readString(); this.extension = in.readString();