Skip to content

Commit

Permalink
调整沉浸式,改为链式调用
Browse files Browse the repository at this point in the history
  • Loading branch information
暄落丶 committed May 24, 2019
1 parent 47737c6 commit ecd3642
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 72 deletions.
57 changes: 39 additions & 18 deletions app/src/main/java/com/xuanluo/kaleidoscope/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,45 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
}

private void initLKaleidoscope(){
LKaleidoscope lKaleidoscope = LKaleidoscope.getInstance();

lKaleidoscope.setImageLoader(new GlideImageLoader());//设置图片加载器
// lKaleidoscope.setThemeStyle(R.style.mainTheme);//设置样式
lKaleidoscope.setToastShow(new ToastShow());//toast 显示仪
lKaleidoscope.setSelectLimit(3);//图片最多数量//如果設置為1 則為單選
lKaleidoscope.setGifShow(true); //是否显示gif 默认显示
lKaleidoscope.setSelectMinLimit(1); //最小选择图片数量 //如果显示相机,则无法控制
lKaleidoscope.setSpanCountLimit(3);//設置圖片列數
lKaleidoscope.setShowCamera(true);//是否显示相机
lKaleidoscope.setCrop(true);//是否裁剪
lKaleidoscope.setDisplay(true); //是否预览
lKaleidoscope.setOutPutX(1);//宽高比
lKaleidoscope.setOutPutY(1);//宽高比
lKaleidoscope.setFreeStyleCrop(false);//是否能够拖动裁剪框(比例自定)
lKaleidoscope.setCompressionQuality(100); //设置裁剪的图片质量,取值0-100
lKaleidoscope.setCircleDimmed(false);//是否要圆形
lKaleidoscope.setRotate(false);//是否支持旋转
LKaleidoscope lKaleidoscope = LKaleidoscope.getInstance()
.setImageLoader(new GlideImageLoader())//设置图片加载器
.setThemeStyle(R.style.mainTheme)//设置样式
.setToastShow(new ToastShow())//toast 显示仪
.setSelectLimit(3)//图片最多数量//如果設置為1 則為單選
.setGifShow(true)//是否显示gif 默认显示
.setSelectMinLimit(1)//最小选择图片数量 //如果显示相机,则无法控制
.setSpanCountLimit(3)//設置圖片列數
.setShowCamera(true)//是否显示相机
.setCrop(true)//是否裁剪
.setDisplay(true)//是否预览
.setOutPutX(1)//宽高比
.setOutPutY(1)//宽高比
.setFreeStyleCrop(false)//是否能够拖动裁剪框(比例自定)
.setCompressionQuality(100)//设置裁剪的图片质量,取值0-100
.setCircleDimmed(false)//是否要圆形
.setRotate(false);//是否支持旋转
// .setIcCameraBack(R.mipmap.ic_launcher)//相机页面-退出拍照页面按钮
// .setIcCameraTake(R.mipmap.ic_launcher)//相机页面-拍照按钮
// .setIcCameraFlip(R.mipmap.ic_launcher)//相机页面-切换前后摄像头按钮
// .setIcCameraDisagree(R.mipmap.ic_launcher)//相机页面-预览页面-重新拍摄按钮
// .setIcCameraAgree(R.mipmap.ic_launcher);//相机页面-预览页面-保存按钮

// lKaleidoscope.setImageLoader(new GlideImageLoader());//设置图片加载器
//// lKaleidoscope.setThemeStyle(R.style.mainTheme);//设置样式
// lKaleidoscope.setToastShow(new ToastShow());//toast 显示仪
// lKaleidoscope.setSelectLimit(3);//图片最多数量//如果設置為1 則為單選
// lKaleidoscope.setGifShow(true); //是否显示gif 默认显示
// lKaleidoscope.setSelectMinLimit(1); //最小选择图片数量 //如果显示相机,则无法控制
// lKaleidoscope.setSpanCountLimit(3);//設置圖片列數
// lKaleidoscope.setShowCamera(true);//是否显示相机
// lKaleidoscope.setCrop(true);//是否裁剪
// lKaleidoscope.setDisplay(true); //是否预览
// lKaleidoscope.setOutPutX(1);//宽高比
// lKaleidoscope.setOutPutY(1);//宽高比
// lKaleidoscope.setFreeStyleCrop(false);//是否能够拖动裁剪框(比例自定)
// lKaleidoscope.setCompressionQuality(100); //设置裁剪的图片质量,取值0-100
// lKaleidoscope.setCircleDimmed(false);//是否要圆形
// lKaleidoscope.setRotate(false);//是否支持旋转

// lKaleidoscope.setIcCameraBack(R.mipmap.ic_launcher);//相机页面-退出拍照页面按钮
// lKaleidoscope.setIcCameraTake(R.mipmap.ic_launcher);//相机页面-拍照按钮
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ public String getSDPhth() {
return SDPhth;
}

public void setSDPhth(String SDPhth) {
public LKaleidoscope setSDPhth(String SDPhth) {
this.SDPhth = SDPhth;
return this;
}

public int getThemeStyle() {
return themeStyle;
}

public void setThemeStyle(@StyleRes int themeStyle) {
public LKaleidoscope setThemeStyle(@StyleRes int themeStyle) {
this.themeStyle = themeStyle;
return this;
}

public boolean isRadioMode() {
Expand All @@ -100,90 +102,101 @@ public boolean isRadioMode() {
return radioMode;
}

// public void setRadioMode(boolean radioMode) {
// this.radioMode = radioMode;
// }
public LKaleidoscope setRadioMode(boolean radioMode) {
this.radioMode = radioMode;
return this;
}


public boolean isGifShow() {
return gifShow;
}

public void setGifShow(boolean gifShow) {
public LKaleidoscope setGifShow(boolean gifShow) {
this.gifShow = gifShow;
return this;
}

public int getSelectLimit() {
return selectLimit;
}

public void setSelectLimit(int selectLimit) {
public LKaleidoscope setSelectLimit(int selectLimit) {
this.selectLimit = selectLimit;
return this;
}

public int getSelectMinLimit() {
return selectMinLimit;
}

public void setSelectMinLimit(int selectMinLimit) {
public LKaleidoscope setSelectMinLimit(int selectMinLimit) {
this.selectMinLimit = selectMinLimit;
return this;
}

public boolean getCrop() {
return crop;
}

public void setCrop(boolean crop) {
public LKaleidoscope setCrop(boolean crop) {
this.crop = crop;
return this;
}

public boolean isDisplay() {
return display;
}

public void setDisplay(boolean display) {
public LKaleidoscope setDisplay(boolean display) {
this.display = display;
return this;
}

public int getSpanCountLimit() {
return spanCountLimit;
}

public void setSpanCountLimit(int spanCountLimit) {
public LKaleidoscope setSpanCountLimit(int spanCountLimit) {
this.spanCountLimit = spanCountLimit;
return this;
}

public boolean isShowCamera() {
// TODO: 2019/4/28 多選是否還顯示相機?
return showCamera;
}

public void setShowCamera(boolean showCamera) {
public LKaleidoscope setShowCamera(boolean showCamera) {
this.showCamera = showCamera;
return this;
}

public float getOutPutX() {
return outPutX;
}

public void setOutPutX(float outPutX) {
public LKaleidoscope setOutPutX(float outPutX) {
this.outPutX = outPutX;
return this;
}

public float getOutPutY() {
return outPutY;
}

public void setOutPutY(float outPutY) {
public LKaleidoscope setOutPutY(float outPutY) {
this.outPutY = outPutY;
return this;
}

public boolean isFreeStyleCrop() {
return freeStyleCrop;
}

public void setFreeStyleCrop(boolean freeStyleCrop) {
public LKaleidoscope setFreeStyleCrop(boolean freeStyleCrop) {
this.freeStyleCrop = freeStyleCrop;
return this;
}

public int getCompressionQuality() {
Expand All @@ -196,94 +209,106 @@ public int getCompressionQuality() {
}
}

public void setCompressionQuality(int compressionQuality) {
public LKaleidoscope setCompressionQuality(int compressionQuality) {
//范围只能是0~100
if (compressionQuality <= 100 &&compressionQuality >= 0){

CompressionQuality = compressionQuality;
}else {
CompressionQuality = 100;
}

return this;
}

public boolean isCircleDimmed() {
return circleDimmed;
}

public void setCircleDimmed(boolean circleDimmed) {
public LKaleidoscope setCircleDimmed(boolean circleDimmed) {
this.circleDimmed = circleDimmed;
return this;
}

public boolean isRotate() {
return rotate;
}

public void setRotate(boolean rotate) {
public LKaleidoscope setRotate(boolean rotate) {
this.rotate = rotate;
return this;
}

public int getIcCameraBack() {
return icCameraBack;
}

public void setIcCameraBack(int icCameraBack) {
public LKaleidoscope setIcCameraBack(int icCameraBack) {
this.icCameraBack = icCameraBack;
return this;
}

public int getIcCameraTake() {
return icCameraTake;
}

public void setIcCameraTake(int icCameraTake) {
public LKaleidoscope setIcCameraTake(int icCameraTake) {
this.icCameraTake = icCameraTake;
return this;
}

public int getIcCameraFlip() {
return icCameraFlip;
}

public void setIcCameraFlip(int icCameraFlip) {
public LKaleidoscope setIcCameraFlip(int icCameraFlip) {
this.icCameraFlip = icCameraFlip;
return this;
}

public int getIcCameraDisagree() {
return icCameraDisagree;
}

public void setIcCameraDisagree(int icCameraDisagree) {
public LKaleidoscope setIcCameraDisagree(int icCameraDisagree) {
this.icCameraDisagree = icCameraDisagree;
return this;
}

public int getIcCameraAgree() {
return icCameraAgree;
}

public void setIcCameraAgree(int icCameraAgree) {
public LKaleidoscope setIcCameraAgree(int icCameraAgree) {
this.icCameraAgree = icCameraAgree;
return this;
}

public LKaleidoImageLoader getImageLoader() {
return imageLoader;
}

public void setImageLoader(LKaleidoImageLoader imageLoader) {
public LKaleidoscope setImageLoader(LKaleidoImageLoader imageLoader) {
this.imageLoader = imageLoader;
return this;
}

public LKaleidoToastShow getToastShow() {
return mToastShow;
}

public void setToastShow(LKaleidoToastShow toastShow) {
public LKaleidoscope setToastShow(LKaleidoToastShow toastShow) {
mToastShow = toastShow;
return this;
}

public List<LKaleidoImageFolder> getImageFolders() {
return mImageFolders;
}

public void setImageFolders(List<LKaleidoImageFolder> imageFolders) {
public LKaleidoscope setImageFolders(List<LKaleidoImageFolder> imageFolders) {
mImageFolders = imageFolders;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mBaseLKaleidoscope = LKaleidoscope.getInstance();
setTheme(mBaseLKaleidoscope.getThemeStyle());
initAttr();

initDrawable();

//沉浸式
setTranslucentStatus();
}


Expand All @@ -70,7 +70,7 @@ void setTranslucentStatus() {
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.setStatusBarColor(main_color);
//导航栏颜色也可以正常设置
// window.setNavigationBarColor(Color.TRANSPARENT);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Expand Down
Loading

0 comments on commit ecd3642

Please sign in to comment.