FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(android-scrollview): add isScrollEnabled property by manoldonev · Pull Request #150 · NativeScript/tns-core-modules-widgets · GitHub

This repository was archived by the owner on Mar 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
Expand All @@ -26,6 +27,7 @@ public class HorizontalScrollView extends android.widget.HorizontalScrollView {
private int scrollableLength = 0;
private SavedState mSavedState;
private boolean isFirstLayout = true;
private boolean scrollEnabled = true;

/**
* True when the layout has changed but the traversal has not come through yet.
Expand All @@ -47,7 +49,34 @@ public HorizontalScrollView(Context context) {
public int getScrollableLength() {
return this.scrollableLength;
}


public boolean getScrollEnabled() {
return this.scrollEnabled;
}

public void setScrollEnabled(boolean value) {
this.scrollEnabled = value;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Do nothing with intercepted touch events if we are not scrollable
if (!this.scrollEnabled) {
return false;
}

return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!this.scrollEnabled && ev.getAction() == MotionEvent.ACTION_DOWN) {
return false;
}

return super.onTouchEvent(ev);
}

@Override
public void requestLayout() {
this.mIsLayoutDirty = true;
Expand Down
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.graphics.Rect;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
Expand All @@ -26,6 +27,7 @@ public class VerticalScrollView extends ScrollView {
private int scrollableLength = 0;
private SavedState mSavedState;
private boolean isFirstLayout = true;
private boolean scrollEnabled = true;

/**
* True when the layout has changed but the traversal has not come through yet.
Expand All @@ -48,6 +50,33 @@ public int getScrollableLength() {
return this.scrollableLength;
}

public boolean getScrollEnabled() {
return this.scrollEnabled;
}

public void setScrollEnabled(boolean value) {
this.scrollEnabled = value;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Do nothing with intercepted touch events if we are not scrollable
if (!this.scrollEnabled) {
return false;
}

return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!this.scrollEnabled && ev.getAction() == MotionEvent.ACTION_DOWN) {
return false;
}

return super.onTouchEvent(ev);
}

@Override
public void requestLayout() {
this.mIsLayoutDirty = true;
Expand Down

Back | FazBrowse Home | New Git URL