Skip to content
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

Added support for the background of the slideview to be clickable #924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public enum PanelState {
*/
private boolean mIsTouchEnabled;

private OnBackgroundClick mBackgroundListener;

private float mPrevMotionX;
private float mPrevMotionY;
private float mInitialMotionX;
Expand Down Expand Up @@ -966,6 +968,14 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
final float x = ev.getX();
final float y = ev.getY();

if (!isViewUnder(mSlideableView, (int)x, (int)y)) {
if (mBackgroundListener != null) {
mBackgroundListener.onClick();
}

return false;
}

if (action == MotionEvent.ACTION_DOWN) {
mIsScrollableViewHandlingTouch = false;
mPrevMotionX = x;
Expand Down Expand Up @@ -1144,6 +1154,10 @@ private void setPanelStateInternal(PanelState state) {
dispatchOnPanelStateChanged(this, oldState, state);
}

public void setOnBackgroundClicked(OnBackgroundClick listener) {
mBackgroundListener = listener;
}

/**
* Update the parallax based on the current slide offset.
*/
Expand Down Expand Up @@ -1487,4 +1501,8 @@ public LayoutParams(Context c, AttributeSet attrs) {

}
}

public interface OnBackgroundClick {
void onClick();
}
}