Open 2hamed opened 6 years ago
Hello, this is how I solved this problem (it's working):
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if(position == 1)
enableSliding(false);
else
enableSliding(true);
}
@Override
public void onPageSelected(int position) {
if(position == 1)
enableSliding(false);
else
enableSliding(true);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
public void enableSliding(boolean enable){
if (enable)
slidrInterface.unlock();
else
slidrInterface.lock();
}
slidrInterface is the interface obtained from the method of the library. This is how I use it with two tabs of a tablayout + viewpager. All perfectly working. If you have morethan two tabs you have only to do some little edit with the position variable.
@GGLabCenter What about nested ViewPagers or ViewPagers inside fragments or horizontal RecyclerViews.
I suspect this problem has to be solved at the library level. For example one should do a view traversal inside tryCaptureView
and check if there is any horizontally scrollable view inside the sliding parent.
Hello @2hamed , nested viewpagers: you should look for some function available to set the listening view (child/parent) from the user. Then it's the same code as above;
viewpagers inside fragments: same code as above, i used also in this way. the viewpager in fact is a statefragmentpageradapter that shows the current fragment, you can build your login from that;
I did not try the library functions inside a recyclerview. You could try to disable the interface inside the recyclerview's listener and before exiting from the listener you can reactivate it.
I believe in same way you can avoid to modify the library and achieve the same results. That said, you could clone the main repository and modify the library, then submit a pull request to the creator. In this way an eventual bug could be fixed :-)
Hi there,
There is a problem with using Slidr with a ViewPager in which Slidr intercepts touch events from ViewPager making it impossible for ViewPager to swipe left.
Slidr should consider the ViewPager and lock the dragging when the ViewPager is not at its first page.