本文整理匯總了Java中org.appcelerator.kroll.KrollDict.put方法的典型用法代碼示例。如果您正苦於以下問題:Java KrollDict.put方法的具體用法?Java KrollDict.put怎麽用?Java KrollDict.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.appcelerator.kroll.KrollDict
的用法示例。
在下文中一共展示了KrollDict.put方法的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: 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);
}
}
示例3: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: updateOrMergeWithDefaultProperties
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
public void updateOrMergeWithDefaultProperties(KrollDict data, boolean update) {
for (String binding: data.keySet()) {
DataItem dataItem = dataItems.get(binding);
if (dataItem == null) continue;
KrollDict defaultProps = dataItem.getDefaultProperties();
KrollDict props = new KrollDict((HashMap)data.get(binding));
if (defaultProps != null) {
if (update) {
//update default properties
Set<String> existingKeys = defaultProps.keySet();
for (String key: props.keySet()) {
if (!existingKeys.contains(key)) {
defaultProps.put(key, null);
}
}
} else {
//merge default properties with new properties and update data
HashMap<String, Object> newData = ((HashMap<String, Object>)defaultProps.clone());
newData.putAll(props);
data.put(binding, newData);
}
}
}
}
示例7: scrollToItem
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
@Kroll.method
public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("rawtypes") @Kroll.argument(optional=true)HashMap options) {
boolean animated = true;
if ( (options != null) && (options instanceof HashMap<?, ?>) ) {
@SuppressWarnings("unchecked")
KrollDict animationargs = new KrollDict(options);
if (animationargs.containsKeyAndNotNull(TiC.PROPERTY_ANIMATED)) {
animated = TiConvert.toBoolean(animationargs.get(TiC.PROPERTY_ANIMATED), true);
}
}
if (TiApplication.isUIThread()) {
handleScrollToItem(sectionIndex, itemIndex, animated);
} else {
KrollDict d = new KrollDict();
d.put("itemIndex", itemIndex);
d.put("sectionIndex", sectionIndex);
d.put(TiC.PROPERTY_ANIMATED, Boolean.valueOf(animated));
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SCROLL_TO_ITEM), d);
}
}
示例8: replaceItemsAt
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
@Kroll.method
public void replaceItemsAt(int index, int count, Object data) {
if (!isIndexValid(index)) {
return;
}
if (TiApplication.isUIThread()) {
handleReplaceItemsAt(index, count, data);
} else {
KrollDict d = new KrollDict();
d.put(TiC.EVENT_PROPERTY_INDEX, index);
d.put(TiC.PROPERTY_COUNT, count);
d.put(TiC.PROPERTY_DATA, data);
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_REPLACE_ITEMS_AT), d);
}
}
示例9: getEngines
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
@Kroll.method
public KrollDict getEngines() {
KrollDict data = new KrollDict();
PackageManager pm = TiApplication.getInstance().getPackageManager();
Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfos == null)
return data;
for (ResolveInfo resolveInfo : resolveInfos) {
MyEngineInfo engine = getEngineInfo(resolveInfo, pm);
if (engine != null) {
data.put(engine.label, engine.name);
}
}
return data;
}
示例10: getPairedDevices
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
@Kroll.method
public KrollDict getPairedDevices()
{
Log.d(TAG, "getPairedDevices called");
Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
KrollDict result = new KrollDict();
// If there are paired devices
if (pairedDevices.size() > 0)
{
// Loop through paired devices
for (BluetoothDevice device : pairedDevices)
{
//Halilk: for some devices, device name is the same so put some of mac digits
String strDigitstoAdd = device.getAddress();
strDigitstoAdd = strDigitstoAdd.replace(":","");
result.put(device.getName()+"_"+strDigitstoAdd, device.getAddress());
}
}
return result;
}
示例11: createPolyline
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
/**
* <p>Draws a polyline on the map view.</p>
* Supported parameters:<br>
* latlngs Array<Array<Integer>> Like [ [45,12], [45,13] ]<br>
* color String Supported colors are: black, blue, green, red, transparent, white.<br>
* strokeWidth Integer
* @param dict dictionary with key-value pairs: {key:value}.
*/
@Kroll.method
public HashMap createPolyline(KrollDict dict) {
containsKey(dict, KEY_COORDINATES);
Object[] coordinates = (Object[]) dict.get(KEY_COORDINATES);
List<LatLong> geom = coordinatesToList(coordinates);
Color color = Color.RED;
float strokeWidth = 0;
if (dict.containsKey(KEY_COLOR)) {
color = Color.valueOf(dict.get(KEY_COLOR).toString().toUpperCase());
}
if (dict.containsKey(KEY_STROKEWIDTH)) {
strokeWidth = TiConvert.toFloat(dict.get(KEY_STROKEWIDTH));
}
int id = mView.createPolyline(geom, color, strokeWidth);
dict.put(KEY_ID, id);
dict.put(KEY_LAYERTYPE, TYPE_POLYLINE);
return dict;
}
示例12: callListener
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
private void callListener(String eventName) {
if (mListener == null && mStartAction == null && mEndAction == null) {
return;
}
KrollDict args = new KrollDict();
args.put(TiC.EVENT_PROPERTY_TYPE, eventName);
args.put(TiC.EVENT_PROPERTY_SOURCE, this);
if (mListener != null) {
mListener.call(this.getKrollObject(), args);
}
if (eventName.equals("start") && mStartAction != null) {
mStartAction.call(this.getKrollObject(), args);
}
if (eventName.equals("end") && mEndAction != null) {
mEndAction.call(this.getKrollObject(), args);
}
}
示例13: createPolygon
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
/**
* <p>Draws a polygon on the map view.</p>
* Supported parameters:<br>
* latlngs Array<Array<Integer>> Like [ [45,12], [45,13] ]<br>
* fillColor String Supported colors are: black, blue, green, red, transparent, white.<br>
* strokeColor String Supported colors are: black, blue, green, red, transparent, white.<br>
* strokeWidth Integer
* @param dict dictionary with key-value pairs: {key:value}.
*/
@Kroll.method
public HashMap createPolygon(KrollDict dict) {
containsKey(dict, KEY_COORDINATES);
Object[] coordinates = (Object[]) dict.get(KEY_COORDINATES);
List<LatLong> geom = coordinatesToList(coordinates);
Color fillColor = Color.TRANSPARENT;
Color strokeColor = Color.BLACK;
float strokeWidth = 0;
if (dict.containsKey(KEY_FILLCOLOR)) {
fillColor = Color.valueOf(dict.get(KEY_FILLCOLOR).toString().toUpperCase());
}
if (dict.containsKey(KEY_STROKECOLOR)) {
strokeColor = Color.valueOf(dict.get(KEY_STROKECOLOR).toString().toUpperCase());
}
if (dict.containsKey(KEY_STROKEWIDTH)) {
strokeWidth = TiConvert.toFloat(dict.get(KEY_STROKEWIDTH));
}
int id = mView.createPolygon(geom, fillColor, strokeColor, strokeWidth);
dict.put(KEY_ID, id);
dict.put(KEY_LAYERTYPE, TYPE_POLYGON);
return dict;
}
示例14: onReceive
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
public void onReceive(Context context, Intent intent) {
List<String> supportedLanguages = new ArrayList<String>();
String languagePreference = "";
Bundle results = getResultExtras(true);
if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE)) {
languagePreference = results
.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
}
if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) {
supportedLanguages = results
.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
}
KrollDict data = new KrollDict();
data.put(TiC.EVENT_PROPERTY_SOURCE, SpeechrecognizerModule.this);
data.put(TiC.PROPERTY_TYPE,
SpeechrecognizerModule.BEGINNINGOFSPEECH);
data.put(LANGUAGE_PREFERENCE, languagePreference);
data.put(SUPPORTED_LANGUAGES,
supportedLanguages.toArray(new String[0]));
fireEvent(LANGUAGEDETAILS, data);
}
示例15: sendResult
import org.appcelerator.kroll.KrollDict; //導入方法依賴的package包/類
private void sendResult(boolean success, String error, String image) {
KrollDict callbackResult = new KrollDict();
callbackResult.put("success", success);
callbackResult.put("error", error);
callbackResult.put("image", image);
callback.callAsync(getKrollObject(), callbackResult);
}