CB-8814 Deprecate ScrollEvent

This commit is contained in:
Andrew Grieve 2015-04-07 21:15:33 -04:00
parent b27d283f21
commit 581252febc
4 changed files with 9 additions and 15 deletions

View File

@ -76,7 +76,6 @@ public interface CordovaWebViewEngine {
void onPageStarted(String newUrl); void onPageStarted(String newUrl);
void onReceivedError(int errorCode, String description, String failingUrl); void onReceivedError(int errorCode, String description, String failingUrl);
void onPageFinishedLoading(String url); void onPageFinishedLoading(String url);
void onScrollChanged(int l, int t, int oldl, int oldt);
boolean onNavigationAttempt(String url); boolean onNavigationAttempt(String url);
} }
} }

View File

@ -573,14 +573,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
return null; 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 @Override
public boolean onNavigationAttempt(String url) { public boolean onNavigationAttempt(String url) {
// Give plugins the chance to handle the url // Give plugins the chance to handle the url

View File

@ -22,11 +22,9 @@ package org.apache.cordova;
import android.view.View; 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 class ScrollEvent {
public int l, t, nl, nt; public int l, t, nl, nt;

View File

@ -62,8 +62,13 @@ public class SystemWebView extends WebView implements CordovaWebViewEngine.Engin
@Override @Override
public void onScrollChanged(int l, int t, int oldl, int oldt) public void onScrollChanged(int l, int t, int oldl, int oldt)
{ {
super.onScrollChanged(l, t, oldl, oldt); // TODO: scrolling is perf-sensitive, so we'd be better to not use postMessage
parentEngine.client.onScrollChanged(l, t, oldl, oldt); // 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 @Override