Skip to content

Commit

Permalink
Tweak CordovaPlugin.initialize method to be less deprecated.
Browse files Browse the repository at this point in the history
Thinking here is that we need a while for both initialize and
pluginInitialize to exist before plugin authors would bother not using
the deprecated one anyways. Really, no harm in keeping both for some
time.
  • Loading branch information
agrieve committed Jul 10, 2014
1 parent a14c794 commit 3792f75
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions framework/src/org/apache/cordova/CordovaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,35 @@ Licensed to the Apache Software Foundation (ASF) under one
public class CordovaPlugin {
@Deprecated // This is never set.
public String id;
public CordovaWebView webView; // WebView object
public CordovaWebView webView;
public CordovaInterface cordova;
protected CordovaPreferences preferences;

void privateInitialize(CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
/**
* Call this after constructing to initialize the plugin.
* Final because we want to be able to change args without breaking plugins.
*/
public final void privateInitialize(CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
assert this.cordova == null;
this.cordova = cordova;
this.webView = webView;
this.preferences = preferences;
initialize(cordova, webView);
initialize();
pluginInitialize();
}

@Deprecated // Override initialize() instead.
/**
* Called after plugin construction and fields have been initialized.
* Prefer to use pluginInitialize instead since there is no value in
* having parameters on the initialize() function.
*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
}

/**
* This is where you can do start-up logic with protected fields set.
* Called after plugin construction and fields have been initialized.
*/
protected void initialize() {
protected void pluginInitialize() {
}

/**
Expand Down

0 comments on commit 3792f75

Please sign in to comment.