feat(tabs): add animationEnabled property (#8704)

This commit is contained in:
Igor Randjelovic
2020-07-11 16:58:50 +02:00
committed by GitHub
parent 9834c4f887
commit 36aa181185
4 changed files with 33 additions and 20 deletions

View File

@@ -1,18 +1,15 @@
/**
*
*/
package org.nativescript.widgets;
import android.content.Context;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.view.View;
import android.view.MotionEvent;
import android.view.KeyEvent;
// See this thread for more information https://stackoverflow.com/questions/9650265
public class TabViewPager extends ViewPager {
private boolean swipePageEnabled = true;
private boolean animationEnabled = true;
public TabViewPager(Context context) {
super(context);
@@ -26,6 +23,10 @@ public class TabViewPager extends ViewPager {
this.swipePageEnabled = enabled;
}
public void setAnimationEnabled(boolean enabled) {
this.animationEnabled = enabled;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (this.swipePageEnabled) {
@@ -55,6 +56,7 @@ public class TabViewPager extends ViewPager {
@Override
public void setCurrentItem(int item) {
super.setCurrentItem(item, this.swipePageEnabled);
boolean smoothScroll = this.animationEnabled && this.swipePageEnabled;
super.setCurrentItem(item, smoothScroll);
}
}