类org.apache.cordova.PluginEntry源码实例Demo

下面列出了怎么用org.apache.cordova.PluginEntry的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: wildfly-samples   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entries.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else if (entry.plugin != null) {
            if (entry.plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
/**
 * Init when loading a new HTML page into webview.
 */
public void init() {
    LOG.d(TAG, "init()");

    // If first time, then load plugins from config.xml file
    if (this.firstRun) {
        this.loadPlugins();
        this.firstRun = false;
    }

    // Stop plugins on current HTML page and discard plugin objects
    else {
        this.onPause(false);
        this.onDestroy();
        this.clearPluginObjects();
    }

    // Insert PluginManager service
    this.addService(new PluginEntry("PluginManager", new PluginManagerService()));

    // Start up all plugins that have onload specified
    this.startupPlugins();
}
 
源代码3 项目: crosswalk-cordova-android   文件: PluginManager.java
/**
 * Get the plugin object that implements the service.
 * If the plugin object does not already exist, then create it.
 * If the service doesn't exist, then return null.
 *
 * @param service       The name of the service.
 * @return              CordovaPlugin or null
 */
public CordovaPlugin getPlugin(String service) {
    CordovaPlugin ret = pluginMap.get(service);
    if (ret == null) {
        PluginEntry pe = entryMap.get(service);
        if (pe == null) {
            return null;
        }
        if (pe.plugin != null) {
            ret = pe.plugin;
        } else {
            ret = instantiatePlugin(pe.pluginClass);
        }
        ret.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(service, ret);
    }
    return ret;
}
 
源代码4 项目: L.TileLayer.Cordova   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码5 项目: IoTgo_Android_App   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码6 项目: bluemix-parking-meter   文件: PluginManager.java
/**
 * Get the plugin object that implements the service.
 * If the plugin object does not already exist, then create it.
 * If the service doesn't exist, then return null.
 *
 * @param service       The name of the service.
 * @return              CordovaPlugin or null
 */
public CordovaPlugin getPlugin(String service) {
    CordovaPlugin ret = pluginMap.get(service);
    if (ret == null) {
        PluginEntry pe = entryMap.get(service);
        if (pe == null) {
            return null;
        }
        if (pe.plugin != null) {
            ret = pe.plugin;
        } else {
            ret = instantiatePlugin(pe.pluginClass);
        }
        ret.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(service, ret);
    }
    return ret;
}
 
源代码7 项目: reader   文件: PluginManager.java
/**
 * Get the plugin object that implements the service.
 * If the plugin object does not already exist, then create it.
 * If the service doesn't exist, then return null.
 *
 * @param service       The name of the service.
 * @return              CordovaPlugin or null
 */
public CordovaPlugin getPlugin(String service) {
    CordovaPlugin ret = pluginMap.get(service);
    if (ret == null) {
        PluginEntry pe = entryMap.get(service);
        if (pe == null) {
            return null;
        }
        if (pe.plugin != null) {
            ret = pe.plugin;
        } else {
            ret = instantiatePlugin(pe.pluginClass);
        }
        ret.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(service, ret);
    }
    return ret;
}
 
源代码8 项目: reader   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码9 项目: reader   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
protected void setUp() throws Exception {
    super.setUp();
    activity = this.getActivity();
    cordovaWebView = activity.cordovaWebView;
    resourceApi = cordovaWebView.getResourceApi();
    resourceApi.setThreadCheckingEnabled(false);
    cordovaWebView.pluginManager.addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() {
        @Override
        public Uri remapUri(Uri uri) {
            if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) {
                return cordovaWebView.getResourceApi().remapUri(
                        Uri.parse("data:text/plain;charset=utf-8,pass"));
            }
            return null;
        }
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
            synchronized (CordovaResourceApiTest.this) {
                execPayload = args.getString(0);
                execStatus = args.getInt(1);
                CordovaResourceApiTest.this.notify();
            }
            return true;
        }
    }));
}
 
源代码11 项目: cordova-amazon-fireos   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    Log.d(TAG,"onOverrideUrlLoading()");
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码12 项目: phonegapbootcampsite   文件: PluginManager.java
/**
 * Init when loading a new HTML page into webview.
 */
public void init() {
    LOG.d(TAG, "init()");

    // If first time, then load plugins from config.xml file
    if (this.firstRun) {
        this.loadPlugins();
        this.firstRun = false;
    }

    // Stop plugins on current HTML page and discard plugin objects
    else {
        this.onPause(false);
        this.onDestroy();
        this.clearPluginObjects();
    }

    // Insert PluginManager service
    this.addService(new PluginEntry("PluginManager", new PluginManagerService()));

    // Start up all plugins that have onload specified
    this.startupPlugins();
}
 
源代码13 项目: phonegapbootcampsite   文件: PluginManager.java
/**
 * Send a message to all plugins.
 *
 * @param id                The message id
 * @param data              The message data
 * @return                  Object to stop propagation or null
 */
public Object postMessage(String id, Object data) {
    Object obj = this.ctx.onMessage(id, data);
    if (obj != null) {
        return obj;
    }
    for (PluginEntry entry : this.entries.values()) {
        if (entry.plugin != null) {
            obj = entry.plugin.onMessage(id, data);
            if (obj != null) {
                return obj;
            }
        }
    }
    return null;
}
 
源代码14 项目: phonegapbootcampsite   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entries.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else if (entry.plugin != null) {
            if (entry.plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
protected void setUp() throws Exception {
    super.setUp();
    activity = this.getActivity();
    cordovaWebView = activity.cordovaWebView;
    resourceApi = cordovaWebView.getResourceApi();
    resourceApi.setThreadCheckingEnabled(false);
    cordovaWebView.pluginManager.addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() {
        @Override
        public Uri remapUri(Uri uri) {
            if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) {
                return cordovaWebView.getResourceApi().remapUri(
                        Uri.parse("data:text/plain;charset=utf-8,pass"));
            }
            return null;
        }
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
            synchronized (CordovaResourceApiTest.this) {
                execPayload = args.getString(0);
                execStatus = args.getInt(1);
                CordovaResourceApiTest.this.notify();
            }
            return true;
        }
    }));
}
 
源代码16 项目: CordovaYoutubeVideoPlayer   文件: PluginManager.java
/**
 * Send a message to all plugins.
 *
 * @param id                The message id
 * @param data              The message data
 * @return                  Object to stop propagation or null
 */
public Object postMessage(String id, Object data) {
    Object obj = this.ctx.onMessage(id, data);
    if (obj != null) {
        return obj;
    }
    for (PluginEntry entry : this.entries.values()) {
        if (entry.plugin != null) {
            obj = entry.plugin.onMessage(id, data);
            if (obj != null) {
                return obj;
            }
        }
    }
    return null;
}
 
源代码17 项目: CordovaYoutubeVideoPlayer   文件: PluginManager.java
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entries.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else if (entry.plugin != null) {
            if (entry.plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码18 项目: OsmGo   文件: MockCordovaWebViewImpl.java
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences, WebView webView) {
  this.cordova = cordova;
  this.webView = webView;
  this.preferences = preferences;
  this.pluginManager = new PluginManager(this, this.cordova, pluginEntries);
  this.resourceApi = new CordovaResourceApi(this.context, this.pluginManager);
  nativeToJsMessageQueue = new NativeToJsMessageQueue();
  nativeToJsMessageQueue.addBridgeMode(new CapacitorEvalBridgeMode(webView, this.cordova));
  nativeToJsMessageQueue.setBridgeMode(0);
  this.cookieManager = new CapacitorCordovaCookieManager(webView);
  this.pluginManager.init();
}
 
源代码19 项目: L.TileLayer.Cordova   文件: PluginManager.java
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
    this.ctx = cordova;
    this.app = cordovaWebView;
    if (pluginEntries == null) {
        ConfigXmlParser parser = new ConfigXmlParser();
        parser.parse(ctx.getActivity());
        pluginEntries = parser.getPluginEntries();
    }
    setPluginEntries(pluginEntries);
}
 
源代码20 项目: L.TileLayer.Cordova   文件: PluginManager.java
/**
 * Create plugins objects that have onload set.
 */
@Deprecated // Should not be exposed as public.
public void startupPlugins() {
    for (PluginEntry entry : entryMap.values()) {
        // Add a null entry to for each non-startup plugin to avoid ConcurrentModificationException
        // When iterating plugins.
        if (entry.onload) {
            getPlugin(entry.service);
        } else {
            pluginMap.put(entry.service, null);
        }
    }
}
 
源代码21 项目: L.TileLayer.Cordova   文件: PluginManager.java
/**
 * Add a plugin class that implements a service to the service entry table.
 * This does not create the plugin object instance.
 *
 * @param entry             The plugin entry
 */
public void addService(PluginEntry entry) {
    this.entryMap.put(entry.service, entry);
    List<String> urlFilters = entry.getUrlFilters();
    if (urlFilters != null) {
        urlMap.put(entry.service, urlFilters);
    }
    if (entry.plugin != null) {
        entry.plugin.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(entry.service, entry.plugin);
    }

}
 
源代码22 项目: IoTgo_Android_App   文件: PluginManager.java
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
    this.ctx = cordova;
    this.app = cordovaWebView;
    if (pluginEntries == null) {
        ConfigXmlParser parser = new ConfigXmlParser();
        parser.parse(ctx.getActivity());
        pluginEntries = parser.getPluginEntries();
    }
    setPluginEntries(pluginEntries);
}
 
源代码23 项目: IoTgo_Android_App   文件: PluginManager.java
public void setPluginEntries(List<PluginEntry> pluginEntries) {
    this.onPause(false);
    this.onDestroy();
    pluginMap.clear();
    urlMap.clear();
    for (PluginEntry entry : pluginEntries) {
        addService(entry);
    }
}
 
源代码24 项目: wildfly-samples   文件: PluginManager.java
/**
 * Called when the system is about to start resuming a previous activity.
 *
 * @param multitasking      Flag indicating if multitasking is turned on for app
 */
public void onPause(boolean multitasking) {
    for (PluginEntry entry : this.entries.values()) {
        if (entry.plugin != null) {
            entry.plugin.onPause(multitasking);
        }
    }
}
 
/**
 * Called when the app navigates or refreshes.
 */
public void onReset() {
    Iterator<PluginEntry> it = this.entries.values().iterator();
    while (it.hasNext()) {
        CordovaPlugin plugin = it.next().plugin;
        if (plugin != null) {
            plugin.onReset();
        }
    }
}
 
源代码26 项目: IoTgo_Android_App   文件: PluginManager.java
/**
 * Add a plugin class that implements a service to the service entry table.
 * This does not create the plugin object instance.
 *
 * @param entry             The plugin entry
 */
public void addService(PluginEntry entry) {
    this.entryMap.put(entry.service, entry);
    List<String> urlFilters = entry.getUrlFilters();
    if (urlFilters != null) {
        urlMap.put(entry.service, urlFilters);
    }
    if (entry.plugin != null) {
        entry.plugin.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(entry.service, entry.plugin);
    }

}
 
源代码27 项目: bluemix-parking-meter   文件: PluginManager.java
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
    this.ctx = cordova;
    this.app = cordovaWebView;
    if (pluginEntries == null) {
        ConfigXmlParser parser = new ConfigXmlParser();
        parser.parse(ctx.getActivity());
        pluginEntries = parser.getPluginEntries();
    }
    setPluginEntries(pluginEntries);
}
 
源代码28 项目: bluemix-parking-meter   文件: PluginManager.java
public void setPluginEntries(List<PluginEntry> pluginEntries) {
    this.onPause(false);
    this.onDestroy();
    pluginMap.clear();
    urlMap.clear();
    for (PluginEntry entry : pluginEntries) {
        addService(entry);
    }
}
 
源代码29 项目: bluemix-parking-meter   文件: PluginManager.java
/**
 * Create plugins objects that have onload set.
 */
@Deprecated // Should not be exposed as public.
public void startupPlugins() {
    for (PluginEntry entry : entryMap.values()) {
        // Add a null entry to for each non-startup plugin to avoid ConcurrentModificationException
        // When iterating plugins.
        if (entry.onload) {
            getPlugin(entry.service);
        } else {
            pluginMap.put(entry.service, null);
        }
    }
}
 
源代码30 项目: bluemix-parking-meter   文件: PluginManager.java
/**
 * Add a plugin class that implements a service to the service entry table.
 * This does not create the plugin object instance.
 *
 * @param entry             The plugin entry
 */
public void addService(PluginEntry entry) {
    this.entryMap.put(entry.service, entry);
    List<String> urlFilters = entry.getUrlFilters();
    if (urlFilters != null) {
        urlMap.put(entry.service, urlFilters);
    }
    if (entry.plugin != null) {
        entry.plugin.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(entry.service, entry.plugin);
    }

}