mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-17 04:31:16 +08:00
feat:QMUIBottomSheet support modify contentView
This commit is contained in:
@@ -13,7 +13,7 @@ object Dep {
|
||||
|
||||
object QMUI {
|
||||
const val group = "com.qmuiteam"
|
||||
const val qmuiVer = "2.1.0.27"
|
||||
const val qmuiVer = "2.1.0.29"
|
||||
const val archVer = "2.1.0.4"
|
||||
const val typeVer = "0.1.0.8"
|
||||
|
||||
|
||||
@@ -302,6 +302,12 @@ public class QMUIBottomSheet extends QMUIBaseDialog {
|
||||
mRootView.addView(view, lp);
|
||||
}
|
||||
|
||||
public void removeContentView(View view) {
|
||||
if (view != null) {
|
||||
mRootView.removeView(view);
|
||||
}
|
||||
}
|
||||
|
||||
public void addContentView(int layoutResId) {
|
||||
LayoutInflater.from(mRootView.getContext()).inflate(layoutResId, mRootView, true);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public abstract class QMUIBottomSheetBaseBuilder<T extends QMUIBottomSheetBaseBu
|
||||
private CharSequence mTitle;
|
||||
private boolean mAddCancelBtn;
|
||||
private String mCancelText;
|
||||
private View mContentView;
|
||||
private DialogInterface.OnDismissListener mOnBottomDialogDismissListener;
|
||||
private int mRadius = -1;
|
||||
private boolean mAllowDrag = false;
|
||||
@@ -109,11 +110,21 @@ public abstract class QMUIBottomSheetBaseBuilder<T extends QMUIBottomSheetBaseBu
|
||||
}
|
||||
|
||||
public QMUIBottomSheet build() {
|
||||
return build(R.style.QMUI_BottomSheet);
|
||||
return build(R.style.QMUI_BottomSheet, false);
|
||||
}
|
||||
|
||||
public QMUIBottomSheet build(boolean refresh) {
|
||||
return build(R.style.QMUI_BottomSheet, refresh);
|
||||
}
|
||||
|
||||
public QMUIBottomSheet build(int style) {
|
||||
mDialog = createBottomSheet(style);
|
||||
return build(style, false);
|
||||
}
|
||||
|
||||
public QMUIBottomSheet build(int style, boolean refresh) {
|
||||
if (!refresh) {
|
||||
mDialog = createBottomSheet(style);
|
||||
}
|
||||
Context dialogContext = mDialog.getContext();
|
||||
QMUIBottomSheetRootLayout rootLayout = mDialog.getRootView();
|
||||
if (ifPreRemoveAllViews()) {
|
||||
@@ -130,6 +141,7 @@ public abstract class QMUIBottomSheetBaseBuilder<T extends QMUIBottomSheetBaseBu
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
lp.setPriority(QMUIPriorityLinearLayout.LayoutParams.PRIORITY_DISPOSABLE);
|
||||
mDialog.addContentView(contentView, lp);
|
||||
mContentView = contentView;
|
||||
}
|
||||
onAddCustomViewAfterContent(mDialog, rootLayout, dialogContext);
|
||||
|
||||
@@ -233,4 +245,8 @@ public abstract class QMUIBottomSheetBaseBuilder<T extends QMUIBottomSheetBaseBu
|
||||
protected boolean ifPreRemoveAllViews() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public View getContentView() {
|
||||
return mContentView;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user