mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
Remove getClassForService() and make addPlugin() private.
This commit is contained in:
parent
5a2398dbea
commit
e3cef16629
@ -57,6 +57,7 @@ public final class PluginManager {
|
|||||||
*
|
*
|
||||||
* @return JSON encoded string with a response message and status.
|
* @return JSON encoded string with a response message and status.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) {
|
public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) {
|
||||||
System.out.println("PluginManager.exec("+service+", "+action+", "+callbackId+", "+jsonArgs+", "+async+")");
|
System.out.println("PluginManager.exec("+service+", "+action+", "+callbackId+", "+jsonArgs+", "+async+")");
|
||||||
PluginResult cr = null;
|
PluginResult cr = null;
|
||||||
@ -119,6 +120,7 @@ public final class PluginManager {
|
|||||||
* @return
|
* @return
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private Class getClassByName(final String clazz) throws ClassNotFoundException {
|
private Class getClassByName(final String clazz) throws ClassNotFoundException {
|
||||||
return Class.forName(clazz);
|
return Class.forName(clazz);
|
||||||
}
|
}
|
||||||
@ -130,6 +132,7 @@ public final class PluginManager {
|
|||||||
* @param c The class to check the interfaces of.
|
* @param c The class to check the interfaces of.
|
||||||
* @return Boolean indicating if the class implements com.phonegap.api.Plugin
|
* @return Boolean indicating if the class implements com.phonegap.api.Plugin
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private boolean isPhoneGapPlugin(Class c) {
|
private boolean isPhoneGapPlugin(Class c) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
if (c.getSuperclass().getName().equals("com.phonegap.api.Plugin")) {
|
if (c.getSuperclass().getName().equals("com.phonegap.api.Plugin")) {
|
||||||
@ -145,11 +148,17 @@ public final class PluginManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add plugin to be loaded and cached. This creates an instance of the plugin.
|
||||||
|
* If plugin is already created, then just return it.
|
||||||
|
*
|
||||||
|
* @param className The class to load
|
||||||
|
* @return The plugin
|
||||||
|
*/
|
||||||
public Plugin addPlugin(String className) {
|
public Plugin addPlugin(String className) {
|
||||||
try {
|
try {
|
||||||
return this.addPlugin(className, this.getClassByName(className), "");
|
return this.addPlugin(className, this.getClassByName(className), "");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Error adding plugin "+className+".");
|
System.out.println("Error adding plugin "+className+".");
|
||||||
}
|
}
|
||||||
@ -157,13 +166,16 @@ public final class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add plugin to be loaded and cached.
|
* Add plugin to be loaded and cached. This creates an instance of the plugin.
|
||||||
* If plugin is already created, then just return it.
|
* If plugin is already created, then just return it.
|
||||||
*
|
*
|
||||||
* @param className The class to load
|
* @param className The class to load
|
||||||
|
* @param clazz The class object (must be a class object of the className)
|
||||||
|
* @param callbackId The callback id to use when calling back into JavaScript
|
||||||
* @return The plugin
|
* @return The plugin
|
||||||
*/
|
*/
|
||||||
public Plugin addPlugin(String className, Class clazz, String callbackId) {
|
@SuppressWarnings("unchecked")
|
||||||
|
private Plugin addPlugin(String className, Class clazz, String callbackId) {
|
||||||
if (this.plugins.containsKey(className)) {
|
if (this.plugins.containsKey(className)) {
|
||||||
return this.getPlugin(className);
|
return this.getPlugin(className);
|
||||||
}
|
}
|
||||||
@ -196,6 +208,7 @@ public final class PluginManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a class that implements a service.
|
* Add a class that implements a service.
|
||||||
|
* This does not create the class instance. It just maps service name to class name.
|
||||||
*
|
*
|
||||||
* @param serviceType
|
* @param serviceType
|
||||||
* @param className
|
* @param className
|
||||||
@ -210,9 +223,9 @@ public final class PluginManager {
|
|||||||
* @param serviceType
|
* @param serviceType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getClassForService(String serviceType) {
|
//private String getClassForService(String serviceType) {
|
||||||
return this.services.get(serviceType);
|
// return this.services.get(serviceType);
|
||||||
}
|
//}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
|
Loading…
Reference in New Issue
Block a user