Cleanup plugin code.

This commit is contained in:
Bryce Curtis 2010-09-09 11:04:04 -05:00
parent b02f376826
commit 2d2adf29fd
2 changed files with 4 additions and 23 deletions

View File

@ -6,10 +6,7 @@ import java.util.Map.Entry;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Context;
import android.content.Intent;
import android.webkit.WebView;
import com.phonegap.DroidGap;
/**
@ -65,7 +62,7 @@ public final class PluginManager {
final JSONArray args = new JSONArray(jsonArgs);
Class c = getClassByName(clazz);
if (isPhoneGapPlugin(c)) {
final Plugin plugin = this.addPlugin(clazz); //cmd;
final Plugin plugin = this.addPlugin(clazz);
final DroidGap ctx = this.ctx;
if (async) {
// Run this on a different thread so that this one can return back to JS
@ -76,10 +73,8 @@ public final class PluginManager {
// Check the status for 0 (success) or otherwise
if (cr.getStatus() == 0) {
ctx.sendJavascript(cr.toSuccessCallbackString(callbackId));
//app.loadUrl(cr.toSuccessCallbackString(callbackId));
} else {
ctx.sendJavascript(cr.toErrorCallbackString(callbackId));
//app.loadUrl(cr.toErrorCallbackString(callbackId));
}
}
});
@ -145,10 +140,10 @@ public final class PluginManager {
* @return The plugin
*/
public Plugin addPlugin(String className) {
System.out.println("PluginManager.addPlugin("+className+")");
if (this.plugins.containsKey(className)) {
return this.getPlugin(className);
}
System.out.println("PluginManager.addPlugin("+className+")");
try {
Plugin plugin = (Plugin)Class.forName(className).newInstance();
this.plugins.put(className, plugin);
@ -212,18 +207,4 @@ public final class PluginManager {
plugin.onDestroy();
}
}
/**
* Send JavaScript statement back to JavaScript.
*
* @param message
*/
/*
public void sendJavascript(String statement) {
//System.out.println("Module.sendResponse("+statement+")");
this.ctx.callbackServer.sendJavascript(statement);
}
*/
}

View File

@ -48,11 +48,11 @@ public class PluginResult {
}
public String toSuccessCallbackString(String callbackId) {
return "javascript:PhoneGap.callbackSuccess('"+callbackId+"', " + this.getJSONString() + " );";
return "PhoneGap.callbackSuccess('"+callbackId+"', " + this.getJSONString() + " );";
}
public String toErrorCallbackString(String callbackId) {
return "javascript:PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
return "PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
}
public static String[] StatusMessages = new String[] {