Skip to content

Commit

Permalink
优化 isCoverEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYanCoding committed Aug 3, 2020
1 parent d3d4afc commit cd568cf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,6 @@ public PictureSelectionModel minSelectNum(int minSelectNum) {
return this;
}

/**
* @param isCoverEnabled PictureSelector cover tab
* @return
*/
public PictureSelectionModel isCoverEnabled(boolean isCoverEnabled) {
selectionConfig.isCoverEnabled = isCoverEnabled;
return this;
}

/**
* @param maxVideoSelectNum PictureSelector video max selection
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public final class PictureSelectionConfig implements Parcelable {
public boolean isAndroidQChangeWH;
public boolean isAndroidQChangeVideoWH;
public boolean isQuickCapture;
public boolean isCoverEnabled;
/**
* 内测专用###########
*/
Expand Down Expand Up @@ -264,8 +263,6 @@ protected void initDefaultValue() {
isAndroidQChangeWH = true;
isAndroidQChangeVideoWH = false;
isQuickCapture = true;
isCoverEnabled = true;

}

public static PictureSelectionConfig getInstance() {
Expand Down Expand Up @@ -404,7 +401,6 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte(this.isAndroidQChangeWH ? (byte) 1 : (byte) 0);
dest.writeByte(this.isAndroidQChangeVideoWH ? (byte) 1 : (byte) 0);
dest.writeByte(this.isQuickCapture ? (byte) 1 : (byte) 0);
dest.writeByte(this.isCoverEnabled ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFallbackVersion ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFallbackVersion2 ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFallbackVersion3 ? (byte) 1 : (byte) 0);
Expand Down Expand Up @@ -511,7 +507,6 @@ protected PictureSelectionConfig(Parcel in) {
this.isAndroidQChangeWH = in.readByte() != 0;
this.isAndroidQChangeVideoWH = in.readByte() != 0;
this.isQuickCapture = in.readByte() != 0;
this.isCoverEnabled = in.readByte() != 0;
this.isFallbackVersion = in.readByte() != 0;
this.isFallbackVersion2 = in.readByte() != 0;
this.isFallbackVersion3 = in.readByte() != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public static PictureSelectionModel applyInstagramOptions(Context context, Insta
.isWithVideoImage(false)// 图片和视频是否可以同选,只在ofAll模式下有效
.maxSelectNum(9)// 最大图片选择数量
.minSelectNum(1)// 最小选择数量
//.isCoverEnabled(false)
.maxVideoSelectNum(1) // 视频最大选择数量,如果没有单独设置的需求则可以不设置,同用maxSelectNum字段
//.minVideoSelectNum(1)// 视频最小选择数量,如果没有单独设置的需求则可以不设置,同用minSelectNum字段
.imageSpanCount(4)// 每行显示个数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
public final class InstagramSelectionConfig implements Parcelable {
private int currentTheme = InsGallery.THEME_STYLE_DEFAULT;
private boolean enableCropVideo = true;
private boolean cropVideoEnabled = true;
private boolean coverEnabled = true;

public static InstagramSelectionConfig createConfig() {
return new InstagramSelectionConfig();
Expand All @@ -40,11 +41,20 @@ public int getCurrentTheme() {
}

public boolean isCropVideo() {
return enableCropVideo;
return cropVideoEnabled;
}

public InstagramSelectionConfig setCropVideo(boolean enableCropVideo) {
this.enableCropVideo = enableCropVideo;
public InstagramSelectionConfig setCropVideoEnabled(boolean enableCropVideo) {
this.cropVideoEnabled = enableCropVideo;
return this;
}

public boolean haveCover() {
return coverEnabled;
}

public InstagramSelectionConfig setCoverEnabled(boolean coverEnabled) {
this.coverEnabled = coverEnabled;
return this;
}

Expand All @@ -56,15 +66,17 @@ public int describeContents() {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.currentTheme);
dest.writeByte(this.enableCropVideo ? (byte) 1 : (byte) 0);
dest.writeByte(this.cropVideoEnabled ? (byte) 1 : (byte) 0);
dest.writeByte(this.coverEnabled ? (byte) 1 : (byte) 0);
}

private InstagramSelectionConfig() {
}

private InstagramSelectionConfig(Parcel in) {
this.currentTheme = in.readInt();
this.enableCropVideo = in.readByte() != 0;
this.cropVideoEnabled = in.readByte() != 0;
this.coverEnabled = in.readByte() != 0;
}

public static final Parcelable.Creator<InstagramSelectionConfig> CREATOR = new Parcelable.Creator<InstagramSelectionConfig>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void onVideoPause() {
}
}));

if (config.isCoverEnabled) {
if (config.instagramSelectionConfig.haveCover()) {
mList.add(new PageCover(config, media));
((PageCover) mList.get(1)).setOnSeekListener(new CoverContainer.onSeekListener() {
@Override
Expand All @@ -182,7 +182,7 @@ public void onSeekEnd() {
}

mInstagramViewPager = new InstagramViewPager(getContext(), mList, config);
mInstagramViewPager.displayTabLayout(config.isCoverEnabled);
mInstagramViewPager.displayTabLayout(config.instagramSelectionConfig.haveCover());
mInstagramViewPager.setScrollEnable(false);
addView(mInstagramViewPager);
mInstagramViewPager.setOnPageChangeListener(new OnPageChangeListener() {
Expand Down Expand Up @@ -318,12 +318,12 @@ public void onCenterFeature(InstagramMediaProcessActivity activity, ImageView vi
@Override
public void onProcess(InstagramMediaProcessActivity activity) {
int c = 1;
if (mConfig.isCoverEnabled) {
if (mConfig.instagramSelectionConfig.haveCover()) {
c++;
}
CountDownLatch count = new CountDownLatch(c);
((PageTrim) mList.get(0)).trimVideo(activity, count);
if (mConfig.isCoverEnabled) {
if (mConfig.instagramSelectionConfig.haveCover()) {
((PageCover) mList.get(1)).cropCover(count);
}
}
Expand Down

1 comment on commit cd568cf

@tallot13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Please sign in to comment.