Skip to content
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

增加是否显示不符合时长要求的视频的设置项 #1777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1465,4 +1465,14 @@ public void externalPictureVideo(String path) {
throw new NullPointerException("This PictureSelector is Null");
}
}

/**
* @param show whether to show too long and too short videos
* @return
*/
public PictureSelectionModel isShowOutLengthVideos(boolean show) {
selectionConfig.showOutLengthVideos = show;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public final class PictureSelectionConfig implements Parcelable {
public boolean isAndroidQChangeWH;
public boolean isAndroidQChangeVideoWH;
public boolean isQuickCapture;
public boolean showOutLengthVideos;
/**
* 内测专用###########
*/
Expand Down Expand Up @@ -265,6 +266,7 @@ protected void initDefaultValue() {
isAndroidQChangeWH = true;
isAndroidQChangeVideoWH = false;
isQuickCapture = true;
showOutLengthVideos = false;
}

public static PictureSelectionConfig getInstance() {
Expand Down Expand Up @@ -404,6 +406,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte(this.isFallbackVersion ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFallbackVersion2 ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFallbackVersion3 ? (byte) 1 : (byte) 0);
dest.writeByte(this.showOutLengthVideos ? (byte) 1 : (byte) 0);
}

protected PictureSelectionConfig(Parcel in) {
Expand Down Expand Up @@ -508,6 +511,7 @@ protected PictureSelectionConfig(Parcel in) {
this.isFallbackVersion = in.readByte() != 0;
this.isFallbackVersion2 = in.readByte() != 0;
this.isFallbackVersion3 = in.readByte() != 0;
this.showOutLengthVideos = in.readByte() != 0;
}

public static final Creator<PictureSelectionConfig> CREATOR = new Creator<PictureSelectionConfig>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,14 @@ private LocalMediaFolder getImageFolder(String path, String folderName, List<Loc
* @return
*/
private String getDurationCondition(long exMaxLimit, long exMinLimit) {
long maxS = config.videoMaxSecond == 0 ? Long.MAX_VALUE : config.videoMaxSecond;
long maxS = config.videoMaxSecond;
maxS = ( maxS == 0 || (maxS != 0 && config.showOutLengthVideos)) ? Long.MAX_VALUE : config.videoMaxSecond;
if (exMaxLimit != 0) {
maxS = Math.min(maxS, exMaxLimit);
}
return String.format(Locale.CHINA, "%d <%s " + MediaStore.MediaColumns.DURATION + " and " + MediaStore.MediaColumns.DURATION + " <= %d",
Math.max(exMinLimit, config.videoMinSecond),
Math.max(exMinLimit, config.videoMinSecond) == 0 ? "" : "=",
config.showOutLengthVideos? 0:Math.max(exMinLimit, config.videoMinSecond),
Math.max(exMinLimit, config.videoMinSecond) == 0 || (Math.max(exMinLimit, config.videoMinSecond) != 0 && config.showOutLengthVideos) ? "" : "=",
maxS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ public MediaData doInBackground() {
}
}
if (PictureMimeType.isHasVideo(mimeType)) {
if (config.videoMinSecond > 0 && duration < config.videoMinSecond) {
if (config.videoMinSecond > 0 && duration < config.videoMinSecond && !config.showOutLengthVideos) {
// If you set the minimum number of seconds of video to display
continue;
}
if (config.videoMaxSecond > 0 && duration > config.videoMaxSecond) {
if (config.videoMaxSecond > 0 && duration > config.videoMaxSecond && !config.showOutLengthVideos) {
// If you set the maximum number of seconds of video to display
continue;
}
Expand Down Expand Up @@ -697,13 +697,15 @@ private static String getRealPathAndroid_Q(long id) {
* @return
*/
private String getDurationCondition(long exMaxLimit, long exMinLimit) {
long maxS = config.videoMaxSecond == 0 ? Long.MAX_VALUE : config.videoMaxSecond;
long maxS = config.videoMaxSecond;
maxS = ( maxS == 0 || (maxS != 0 && config.showOutLengthVideos)) ? Long.MAX_VALUE : config.videoMaxSecond;
if (exMaxLimit != 0) {
maxS = Math.min(maxS, exMaxLimit);
}

return String.format(Locale.CHINA, "%d <%s " + MediaStore.MediaColumns.DURATION + " and " + MediaStore.MediaColumns.DURATION + " <= %d",
Math.max(exMinLimit, config.videoMinSecond),
Math.max(exMinLimit, config.videoMinSecond) == 0 ? "" : "=",
config.showOutLengthVideos? 0:Math.max(exMinLimit, config.videoMinSecond),
Math.max(exMinLimit, config.videoMinSecond) == 0 || (Math.max(exMinLimit, config.videoMinSecond) != 0 && config.showOutLengthVideos) ? "" : "=",
maxS);
}

Expand Down