mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
Handle null bottomSheetBehavior
This commit is contained in:
parent
820a959196
commit
90aa9bb954
@ -373,7 +373,9 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
binding.sliderParent.setLayoutParams(new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
binding.sliderParent.requestLayout();
|
||||
if (bottomSheetBehavior != null) {
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (destView == binding.videoPost.thumbnailParent) {
|
||||
@ -382,9 +384,11 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
params.gravity = Gravity.CENTER;
|
||||
binding.videoPost.thumbnailParent.setLayoutParams(params);
|
||||
binding.videoPost.thumbnailParent.requestLayout();
|
||||
if (bottomSheetBehavior != null) {
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
@ -703,10 +707,12 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
}
|
||||
});
|
||||
binding.caption.setOnClickListener(v -> {
|
||||
if (bottomSheetBehavior == null) return;
|
||||
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) return;
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
});
|
||||
binding.captionToggle.setOnClickListener(v -> {
|
||||
if (bottomSheetBehavior == null) return;
|
||||
switch (bottomSheetBehavior.getState()) {
|
||||
case BottomSheetBehavior.STATE_HIDDEN:
|
||||
binding.captionParent.fullScroll(ScrollView.FOCUS_UP); // reset scroll position
|
||||
@ -734,6 +740,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
binding.getRoot().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
if (bottomSheetBehavior == null) return;
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
@ -762,7 +769,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
final int likesCount = (int) feedModel.getLikesCount();
|
||||
final String likesString = getResources().getQuantityString(R.plurals.likes_count, likesCount, likesCount);
|
||||
binding.likesCount.setText(likesString);
|
||||
} catch (IllegalStateException e) {}
|
||||
} catch (IllegalStateException ignored) {}
|
||||
}
|
||||
|
||||
private void setupPostTypeLayout() {
|
||||
|
Loading…
Reference in New Issue
Block a user