Skip to content

Support ViewPager in BottomSheet #2188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

umerov1999
Copy link

Fix swipe gestures

Thanks for starting a pull request on Material Components!

Don't forget:

  • Identify the component the PR relates to in brackets in the title.
    [Buttons] Updated documentation
  • Link to GitHub issues it solves. closes #1234
  • Sign the CLA bot. You can do this once the pull request is opened.

Contributing
has more information and tips for a great pull request.

@google-cla google-cla bot added the cla: yes label Apr 21, 2021
return view;
}
if (view instanceof ViewPager2) {
ViewPager2 viewPager2 = (ViewPager2) view;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to declare a separate local variable.

@@ -1286,12 +1288,32 @@ boolean shouldHide(@NonNull View child, float yvel) {
return Math.abs(newTop - collapsedOffset) / (float) peek > HIDE_THRESHOLD;
}

@Nullable
private View getCurrentViewWithVP2(ViewPager2 viewPager) {
Copy link
Contributor

Choose a reason for hiding this comment

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

getCurrentViewFromViewPager?

if(((RecyclerView) child).getLayoutManager() == null)
return null;
child = ((RecyclerView) child).getLayoutManager().findViewByPosition(currentItem);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

else return null?

@@ -65,6 +65,8 @@
import com.google.android.material.resources.MaterialResources;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need dependency to ViewPager2? This code may be applied to any ViewGroup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants