Skip to content

Commit

Permalink
CB-8814 Deprecate ScrollEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
agrieve committed Apr 8, 2015
1 parent b27d283 commit 581252f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
1 change: 0 additions & 1 deletion framework/src/org/apache/cordova/CordovaWebViewEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public interface Client {
void onPageStarted(String newUrl);
void onReceivedError(int errorCode, String description, String failingUrl);
void onPageFinishedLoading(String url);
void onScrollChanged(int l, int t, int oldl, int oldt);
boolean onNavigationAttempt(String url);
}
}
8 changes: 0 additions & 8 deletions framework/src/org/apache/cordova/CordovaWebViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,6 @@ public Boolean onDispatchKeyEvent(KeyEvent event) {
return null;
}

@Override
public void onScrollChanged(int l, int t, int oldl, int oldt) {
// TODO: scrolling is perf-sensitive, so we'd probably be better to no use postMessage
// here, and also not to create any new objects.
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, getView());
pluginManager.postMessage("onScrollChanged", myEvent);
}

@Override
public boolean onNavigationAttempt(String url) {
// Give plugins the chance to handle the url
Expand Down
6 changes: 2 additions & 4 deletions framework/src/org/apache/cordova/ScrollEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.view.View;

/*
* This can be used by any view, including native views
*
* @deprecated As of release 4.0. Use view.getViewTreeObserver().addOnScrollChangedListener(...) instead.
*/


@Deprecated
public class ScrollEvent {

public int l, t, nl, nt;
Expand Down
9 changes: 7 additions & 2 deletions framework/src/org/apache/cordova/engine/SystemWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ public void setWebChromeClient(WebChromeClient client) {
@Override
public void onScrollChanged(int l, int t, int oldl, int oldt)
{
super.onScrollChanged(l, t, oldl, oldt);
parentEngine.client.onScrollChanged(l, t, oldl, oldt);
// TODO: scrolling is perf-sensitive, so we'd be better to not use postMessage
// here, and also not create any new objects. Instead, plugins should use:
// webView.getView().getViewTreeObserver().addOnScrollChangedListener(...)
if (parentEngine != null && parentEngine.pluginManager != null) {
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, this);
parentEngine.pluginManager.postMessage("onScrollChanged", myEvent);
}
}

@Override
Expand Down

0 comments on commit 581252f

Please sign in to comment.