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

setOnScrollChangeListener Added #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ public class MyActivity extends Activity implements AdvancedWebView.Listener {

mWebView = (AdvancedWebView) findViewById(R.id.webview);
mWebView.setListener(this, this);

mWebView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View view, int i, int i1, int i2, int i3) {
Log.d("scrollX", String.valueOf(i))
Log.d("scrollY", String.valueOf(i1))
Log.d("oldScrollX", String.valueOf(i2))
Log.d("oldScrollY", String.valueOf(i3))
}
});

mWebView.loadUrl("http://www.example.org/");

// ...
Expand Down Expand Up @@ -137,6 +148,17 @@ public class MyFragment extends Fragment implements AdvancedWebView.Listener {

mWebView = (AdvancedWebView) rootView.findViewById(R.id.webview);
mWebView.setListener(this, this);

mWebView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View view, int i, int i1, int i2, int i3) {
Log.d("scrollX", String.valueOf(i))
Log.d("scrollY", String.valueOf(i1))
Log.d("oldScrollX", String.valueOf(i2))
Log.d("oldScrollY", String.valueOf(i3))
}
});

mWebView.loadUrl("http://www.example.org/");

// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,34 @@ protected void setListener(final Listener listener, final int requestCodeFilePic
mListener = listener;
mRequestCodeFilePicker = requestCodeFilePicker;
}

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (onScrollChangeListener != null) {
onScrollChangeListener.onScrollChange(getContext(), l, t, oldl, oldt);
}
}

public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) {
this.onScrollChangeListener = onScrollChangeListener;
}

public OnScrollChangeListener getOnScrollChangeListener() {
return onScrollChangeListener;
}

public interface OnScrollChangeListener {
/**
* Called when the scroll position of a view changes.
* @param v The view whose scroll position has changed.
* @param scrollX Current horizontal scroll origin.
* @param scrollY Current vertical scroll origin.
* @param oldScrollX Previous horizontal scroll origin.
* @param oldScrollY Previous vertical scroll origin.
*/
void onScrollChange(Context v, int scrollX, int scrollY, int oldScrollX, int oldScrollY);
}

@Override
public void setWebViewClient(final WebViewClient client) {
Expand Down