Last active
August 18, 2016 08:01
-
-
Save beta/65266f7d6abbebac71e55d5a2b5a1d21 to your computer and use it in GitHub Desktop.
android/support/design/widget/BottomSheetDialog.java of Android Design Support Library 23.4.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) { | |
final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(), | |
R.layout.design_bottom_sheet_dialog, null); | |
if (layoutResId != 0 && view == null) { | |
view = getLayoutInflater().inflate(layoutResId, coordinator, false); | |
} | |
FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet); | |
BottomSheetBehavior.from(bottomSheet).setBottomSheetCallback(mBottomSheetCallback); | |
if (params == null) { | |
bottomSheet.addView(view); | |
} else { | |
bottomSheet.addView(view, params); | |
} | |
// We treat the CoordinatorLayout as outside the dialog though it is technically inside | |
if (shouldWindowCloseOnTouchOutside()) { | |
coordinator.findViewById(R.id.touch_outside).setOnClickListener( | |
new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if (isShowing()) { | |
cancel(); | |
} | |
} | |
}); | |
} | |
return coordinator; | |
} | |
... | |
private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback | |
= new BottomSheetBehavior.BottomSheetCallback() { | |
@Override | |
public void onStateChanged(@NonNull View bottomSheet, | |
@BottomSheetBehavior.State int newState) { | |
if (newState == BottomSheetBehavior.STATE_HIDDEN) { | |
dismiss(); | |
} | |
} | |
@Override | |
public void onSlide(@NonNull View bottomSheet, float slideOffset) { | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment