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

Add property which allows header view to handle touch events. #64

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 @@ -59,6 +59,7 @@ public abstract class FadingActionBarHelperBase {
private boolean mFirstGlobalLayoutPerformed;
private FrameLayout mMarginView;
private View mListViewBackgroundView;
private boolean mAllowHeaderTouchEvents = false;

public final <T extends FadingActionBarHelperBase> T actionBarBackground(int drawableResId) {
mActionBarBackgroundResId = drawableResId;
Expand Down Expand Up @@ -110,6 +111,11 @@ public final <T extends FadingActionBarHelperBase> T parallax(boolean value) {
return (T)this;
}

public final <T extends FadingActionBarHelperBase> T allowHeaderTouchEvents(boolean value) {
mAllowHeaderTouchEvents = value;
return (T)this;
}

public final View createView(Context context) {
return createView(LayoutInflater.from(context));
}
Expand Down Expand Up @@ -232,6 +238,10 @@ private View createWebView() {
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
webView.addView(mMarginView);

if (mAllowHeaderTouchEvents) {
setMarginViewTouchListener();
}

return webViewContainer;
}

Expand All @@ -251,6 +261,10 @@ private View createScrollView() {
mHeaderContainer.addView(mHeaderView, 0);
mMarginView = (FrameLayout) contentContainer.findViewById(R.id.fab__content_top_margin);

if (mAllowHeaderTouchEvents) {
setMarginViewTouchListener();
}

return scrollViewContainer;
}

Expand Down Expand Up @@ -279,6 +293,11 @@ private View createListView(ListView listView) {
mListViewBackgroundView.setLayoutParams(params);

listView.setOnScrollListener(mOnScrollListener);

if (mAllowHeaderTouchEvents) {
setMarginViewTouchListener();
}

return contentContainer;
}

Expand Down Expand Up @@ -356,4 +375,13 @@ private void initializeGradient(ViewGroup headerContainer) {
}
gradientView.setBackgroundResource(gradient);
}

private void setMarginViewTouchListener() {
mMarginView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return mHeaderView.dispatchTouchEvent(event);
}
});
}
}