Skip to content

Commit

Permalink
延长权限时间~
Browse files Browse the repository at this point in the history
  • Loading branch information
DmcSDK committed Dec 25, 2023
1 parent 59c80c8 commit cf768d7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ArrayList<Media> selects=new ArrayList<>();
for(int i=0; i<count;i++){
Uri uri = data.getClipData().getItemAt(i).getUri();
if (Build.VERSION.SDK_INT >= 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,7 @@
*/

public class Media implements Parcelable {
public String uri;
public String path;
public String name;
public String extension;
Expand All @@ -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) {
Expand All @@ -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() {
Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit cf768d7

Please sign in to comment.