mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Cleanup plugin code.
This commit is contained in:
parent
b02f376826
commit
2d2adf29fd
@ -6,10 +6,7 @@ import java.util.Map.Entry;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import com.phonegap.DroidGap;
|
import com.phonegap.DroidGap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +62,7 @@ public final class PluginManager {
|
|||||||
final JSONArray args = new JSONArray(jsonArgs);
|
final JSONArray args = new JSONArray(jsonArgs);
|
||||||
Class c = getClassByName(clazz);
|
Class c = getClassByName(clazz);
|
||||||
if (isPhoneGapPlugin(c)) {
|
if (isPhoneGapPlugin(c)) {
|
||||||
final Plugin plugin = this.addPlugin(clazz); //cmd;
|
final Plugin plugin = this.addPlugin(clazz);
|
||||||
final DroidGap ctx = this.ctx;
|
final DroidGap ctx = this.ctx;
|
||||||
if (async) {
|
if (async) {
|
||||||
// Run this on a different thread so that this one can return back to JS
|
// 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
|
// Check the status for 0 (success) or otherwise
|
||||||
if (cr.getStatus() == 0) {
|
if (cr.getStatus() == 0) {
|
||||||
ctx.sendJavascript(cr.toSuccessCallbackString(callbackId));
|
ctx.sendJavascript(cr.toSuccessCallbackString(callbackId));
|
||||||
//app.loadUrl(cr.toSuccessCallbackString(callbackId));
|
|
||||||
} else {
|
} else {
|
||||||
ctx.sendJavascript(cr.toErrorCallbackString(callbackId));
|
ctx.sendJavascript(cr.toErrorCallbackString(callbackId));
|
||||||
//app.loadUrl(cr.toErrorCallbackString(callbackId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -145,10 +140,10 @@ public final class PluginManager {
|
|||||||
* @return The plugin
|
* @return The plugin
|
||||||
*/
|
*/
|
||||||
public Plugin addPlugin(String className) {
|
public Plugin addPlugin(String className) {
|
||||||
System.out.println("PluginManager.addPlugin("+className+")");
|
|
||||||
if (this.plugins.containsKey(className)) {
|
if (this.plugins.containsKey(className)) {
|
||||||
return this.getPlugin(className);
|
return this.getPlugin(className);
|
||||||
}
|
}
|
||||||
|
System.out.println("PluginManager.addPlugin("+className+")");
|
||||||
try {
|
try {
|
||||||
Plugin plugin = (Plugin)Class.forName(className).newInstance();
|
Plugin plugin = (Plugin)Class.forName(className).newInstance();
|
||||||
this.plugins.put(className, plugin);
|
this.plugins.put(className, plugin);
|
||||||
@ -212,18 +207,4 @@ public final class PluginManager {
|
|||||||
plugin.onDestroy();
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
@ -48,11 +48,11 @@ public class PluginResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toSuccessCallbackString(String callbackId) {
|
public String toSuccessCallbackString(String callbackId) {
|
||||||
return "javascript:PhoneGap.callbackSuccess('"+callbackId+"', " + this.getJSONString() + " );";
|
return "PhoneGap.callbackSuccess('"+callbackId+"', " + this.getJSONString() + " );";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toErrorCallbackString(String callbackId) {
|
public String toErrorCallbackString(String callbackId) {
|
||||||
return "javascript:PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
|
return "PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] StatusMessages = new String[] {
|
public static String[] StatusMessages = new String[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user