本文整理汇总了Java中org.appcelerator.kroll.KrollDict类的典型用法代码示例。如果您正苦于以下问题:Java KrollDict类的具体用法?Java KrollDict怎么用?Java KrollDict使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KrollDict类属于org.appcelerator.kroll包,在下文中一共展示了KrollDict类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceivedSslError
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
/*
* in theory this should be checked to make sure it's not null but if there is some failure
* in the association then usage of webViewProxy should trigger a NPE to make sure the issue
* is not ignored
*/
KrollProxy webViewProxy = this.webView.getProxy();
KrollDict data = new KrollDict();
data.put(TiC.ERROR_PROPERTY_CODE, error.getPrimaryError());
webView.getProxy().fireSyncEvent(TiC.EVENT_SSL_ERROR, data);
boolean ignoreSslError = false;
try {
ignoreSslError = webViewProxy.getProperties().optBoolean(TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR, false);
} catch(IllegalArgumentException e) {
Log.e(TAG, TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR + " property does not contain a boolean value, ignoring");
}
if (ignoreSslError == true) {
Log.w(TAG, "ran into SSL error but ignoring...");
handler.proceed();
} else {
Log.e(TAG, "SSL error occurred: " + error.toString());
handler.cancel();
}
}
示例2: handleCreationDict
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void handleCreationDict(KrollDict dict) {
super.handleCreationDict(dict);
if (dict.containsKey(PROPERTY_ID)) {
setId(TiConvert.toInt(dict, PROPERTY_ID));
} else {
throw new IllegalArgumentException("property 'id' is required");
}
if (dict.containsKey(PROPERTY_TITLE)) {
setTitle(TiConvert.toString(dict, PROPERTY_TITLE));
}
if (dict.containsKey(PROPERTY_TEXT)) {
setText(TiConvert.toString(dict, PROPERTY_TEXT));
}
if (dict.containsKey(PROPERTY_ICON)) {
setIcon(TiConvert.toInt(dict, PROPERTY_ICON));
}
if (dict.containsKey(PROPERTY_PENDING_INTENT)) {
setPendingIntent((PendingIntentProxy) dict.get(PROPERTY_PENDING_INTENT));
}
if (dict.containsKey(PROPERTY_NUMBER)) {
setNumber(TiConvert.toInt(dict, PROPERTY_NUMBER));
}
}
示例3: flushResponse
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
protected void flushResponse(Object... params) {
if (null != callback) {
ArrayList<Object> args = new ArrayList<Object>();
for (Object a : params) {
args.add(a);
}
int length = args.size();
KrollDict response = new KrollDict();
for (int i=0; i<length; i++) { // double increase i to make key-value pair
String key = (String) args.get(i);
++i;
response.put(key, args.get(i));
}
callback.callAsync(krollObject, response);
}
}
示例4: prepareExtrasForIntent
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
private Intent prepareExtrasForIntent(Intent intent, KrollDict options, boolean openGallery) {
Defaults.resetValues(openGallery);
checkAndSetParameters(1, Defaults.Params.STATUS_BAR_COLOR, Defaults.STATUS_BAR_COLOR, options, intent);
checkAndSetParameters(1, Defaults.Params.BAR_COLOR, Defaults.BAR_COLOR, options, intent);
checkAndSetParameters(1, Defaults.Params.BACKGROUND_COLOR, Defaults.BACKGROUND_COLOR, options, intent);
checkAndSetParameters(1, Defaults.Params.COVER_VIEW_COLOR, Defaults.COVER_VIEW_COLOR, options, intent);
checkAndSetParameters(1, Defaults.Params.CHECKMARK_COLOR, Defaults.CHECKMARK_COLOR, options, intent);
checkAndSetParameters(1, Defaults.Params.TITLE, Defaults.TITLE, options, intent);
checkAndSetParameters(1, Defaults.Params.DONE_BTN_TITLE, Defaults.DONE_BTN_TITLE, options, intent);
checkAndSetParameters(1, Defaults.Params.MAX_IMAGE_MSG, Defaults.MAX_IMAGE_MSG, options, intent);
checkAndSetParameters(2, Defaults.Params.GRID_SIZE, Defaults.GRID_SIZE, options, intent);
checkAndSetParameters(2, Defaults.Params.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT, options, intent);
checkAndSetParameters(2, Defaults.Params.SHOW_DIVIDER, Defaults.SHOW_DIVIDER, options, intent);
checkAndSetParameters(2, Defaults.Params.DIVIDER_WIDTH, Defaults.DIVIDER_WIDTH, options, intent);
checkAndSetParameters(2, Defaults.Params.MAX_IMAGE_SELECTION, Defaults.MAX_IMAGE_SELECTION, options, intent);
checkAndSetParameters(2, Defaults.Params.SHAPE, Defaults.SHAPE, options, intent);
checkAndSetParameters(2, Defaults.Params.CIRCLE_RADIUS, Defaults.CIRCLE_RADIUS, options, intent);
checkAndSetParameters(2, Defaults.Params.CIRCLE_PADDING, Defaults.CIRCLE_PADDING, options, intent);
return intent;
}
示例5: start
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Kroll.method
public void start()
{
setState(STATE_RUNNING);
// App opens analytics
ParseAnalytics.trackAppOpenedInBackground(TiApplication.getAppRootOrCurrentActivity().getIntent());
ParseInstallation.getCurrentInstallation().put("androidId", getAndroidId());
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e != null) {
Log.e(TAG, "Installation initialization failed: " + e.getMessage());
}
// fire event
try {
JSONObject pnData = new JSONObject();
pnData.put("objectId", getObjectId());
pnData.put("installationId", getCurrentInstallationId());
KrollDict data = new KrollDict(pnData);
module.fireEvent("installationId", data);
} catch (JSONException e1) {
Log.e(TAG, "InstallationId event failed: " + e1.getMessage());
}
}
});
}
示例6: openURL
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Kroll.method
public boolean openURL(KrollDict options) {
if ( (options != null) && options.containsKeyAndNotNull(Params.URL)) {
Context context = TiApplication.getAppCurrentActivity();
List<ResolveInfo> browsersList = Utils.allBrowsers(context);
if (!browsersList.isEmpty()) {
List<String> customTabBrowsers = getCustomTabBrowsers(context, browsersList);
// show supported browsers list or open directly if only 1 supported browser is available
openCustomTab(context, customTabBrowsers, options);
return true;
} else {
Log.i(Params.LCAT, "No browsers available in this device.");
return false;
}
}
Log.i(Params.LCAT, "Check your paramters. URL parameter is mandatory.");
return false;
}
示例7: setHtml
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Kroll.method
public void setHtml(String html, @Kroll.argument(optional = true) KrollDict d)
{
setProperty(TiC.PROPERTY_HTML, html);
setProperty(OPTIONS_IN_SETHTML, d);
// If the web view has not been created yet, don't set html here. It will be set in processProperties() when the
// view is created.
TiUIView v = peekView();
if (v != null) {
if (TiApplication.isUIThread()) {
((TiUIWebView) v).setHtml(html, d);
} else {
getMainHandler().sendEmptyMessage(MSG_SET_HTML);
}
}
}
示例8: onPageFinished
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
WebViewProxy proxy = (WebViewProxy) webView.getProxy();
webView.changeProxyUrl(url);
KrollDict data = new KrollDict();
data.put("url", url);
proxy.fireEvent(TiC.EVENT_LOAD, data);
boolean enableJavascriptInjection = true;
if (proxy.hasProperty(TiC.PROPERTY_ENABLE_JAVASCRIPT_INTERFACE)) {
enableJavascriptInjection = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_JAVASCRIPT_INTERFACE), true);
}
if (Build.VERSION.SDK_INT > 16 || enableJavascriptInjection) {
WebView nativeWebView = webView.getWebView();
if (nativeWebView != null) {
if (webView.shouldInjectBindingCode()) {
nativeWebView.loadUrl("javascript:" + TiWebViewBinding.INJECTION_CODE);
}
nativeWebView.loadUrl("javascript:" + TiWebViewBinding.POLLING_CODE);
}
}
webView.setBindingCodeInjected(false);
}
示例9: onCreate
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
HashMap<String, Object> data = (HashMap)intent.getSerializableExtra(TiGCMModule.NTF_KEY_DATA);
TiGCMModule module = TiGCMModule.getInstance();
TiApplication instance = TiApplication.getInstance();
if(module != null) {
module.fireMessage(data, false);
} else {
KrollDict kdata = new KrollDict(data);
TiApplication.getInstance().getAppProperties().setString(TiGCMModule.PROPERTY_PENDING_DATA, kdata.toString());
Log.d(TAG, "Saving data in props: " + kdata.toString());
}
String pkg = instance.getApplicationContext().getPackageName();
Intent launcherIntent = instance.getApplicationContext().getPackageManager().getLaunchIntentForPackage(pkg);
startActivity(launcherIntent);
finish();
}
示例10: checkLatestEventInfoProperties
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
protected void checkLatestEventInfoProperties(KrollDict d)
{
if (d.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)
|| d.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT))
{
String contentTitle = "";
String contentText = "";
PendingIntent contentIntent = null;
if (d.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)) {
contentTitle = TiConvert.toString(d, TiC.PROPERTY_CONTENT_TITLE);
}
if (d.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT)) {
contentText = TiConvert.toString(d, TiC.PROPERTY_CONTENT_TEXT);
}
Context c = getActivity();
if (c == null) {
c = TiApplication.getInstance().getApplicationContext();
}
contentIntent = createDefaultIntent(c, d.getKrollDict(TiC.PROPERTY_DATA));
notification.setLatestEventInfo(c, contentTitle, contentText, contentIntent);
}
}
示例11: onStart
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
TiGcmModule.logd("GcmLauncherActivity: Starting activity");
KrollDict data = extractIntentData();
if (!appWasRunning) {
TiApplication tiApp = TiApplication.getInstance();
String tiPackageName = tiApp.getPackageName();
String mainClassName = tiApp.getPackageManager().getLaunchIntentForPackage(tiPackageName).getComponent().getClassName();
Intent mainActivityIntent = new Intent();
mainActivityIntent.setClassName(tiPackageName, mainClassName);
mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_SINGLE_TOP);
mainActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(mainActivityIntent);
TiGcmModule.queueDataFromBackground(data);
} else {
TiGcmModule.queueDataFromBackground(data);
this.finish();
}
}
示例12: onError
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public boolean onError(MediaPlayer mp, int what, int extra)
{
int code = 0;
String msg = "Unknown media error.";
if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED)
{
msg = "Media server died";
}
release();
KrollDict data = new KrollDict();
data.put(TiC.PROPERTY_CODE, code);
data.put(TiC.PROPERTY_MESSAGE, msg);
proxy.fireEvent(EVENT_ERROR, data);
return true;
}
示例13: handleCreationDict
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void handleCreationDict(KrollDict options) {
super.handleCreationDict(options);
if (options.containsKey(TiC.PROPERTY_URL)) {
setProperty(TiC.PROPERTY_URL, resolveUrl(null, TiConvert.toString(options, TiC.PROPERTY_URL)));
}
if (options.containsKey(TiC.PROPERTY_ALLOW_BACKGROUND)) {
setProperty(TiC.PROPERTY_ALLOW_BACKGROUND, options.get(TiC.PROPERTY_ALLOW_BACKGROUND));
}
if(options.containsKey("speakerphone")) {
setProperty("speakerphone", TiConvert.toBoolean(options.get("speakerphone")));
}
if (DBG) {
Log.i(LCAT, "Creating audio player proxy for url: " + TiConvert.toString(getProperty("url")));
}
}
示例14: applicationError
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void applicationError(int errorCode) {
if (DEBUG)
Log.d(TAG, "LicenseCheckerCallback.applicationError " + errorCode);
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
// Please examine the error code and fix the error.
KrollDict info = new KrollDict();
info.put("response", "error");
info.put("reason", errorCode);
fireEvent("licenseCheckerEvent", info);
}
示例15: handleCreationDict
import org.appcelerator.kroll.KrollDict; //导入依赖的package包/类
@Override
public void handleCreationDict(KrollDict d)
{
super.handleCreationDict(d);
if (d == null) {
return;
}
if (d.containsKey(NotificationfactoryModule.PROPERTY_BIG_TEXT)) {
setBigText(TiConvert.toString(d.get(NotificationfactoryModule.PROPERTY_BIG_TEXT)));
}
if (d.containsKey(NotificationfactoryModule.PROPERTY_BIG_CONTENT_TITLE)) {
setBigContentTitle(TiConvert.toString(d.get(NotificationfactoryModule.PROPERTY_BIG_CONTENT_TITLE)));
}
if (d.containsKey(NotificationfactoryModule.PROPERTY_SUMMARY_TEXT)) {
setSummaryText(TiConvert.toString(d.get(NotificationfactoryModule.PROPERTY_SUMMARY_TEXT)));
}
}