本文整理汇总了Java中org.appcelerator.kroll.KrollDict.get方法的典型用法代码示例。如果您正苦于以下问题:Java KrollDict.get方法的具体用法?Java KrollDict.get怎么用?Java KrollDict.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.appcelerator.kroll.KrollDict
的用法示例。
在下文中一共展示了KrollDict.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
}
示例2: generateDiffProperties
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
/**
* This method compares applied properties of a view and our data model to
* generate a new set of properties we need to set. It is crucial for scrolling performance.
* @param properties The properties from our data model
* @return The difference set of properties to set
*/
public KrollDict generateDiffProperties(KrollDict properties) {
diffProperties.clear();
for (String appliedProp : this.properties.keySet()) {
if (!properties.containsKey(appliedProp)) {
applyProperty(appliedProp, null);
}
}
for (String property : properties.keySet()) {
Object value = properties.get(property);
if (CollectionView.MUST_SET_PROPERTIES.contains(property)) {
applyProperty(property, value);
continue;
}
Object existingVal = this.properties.get(property);
if (existingVal == null || value == null || !existingVal.equals(value)) {
applyProperty(property, value);
}
}
return diffProperties;
}
示例3: CollectionItemData
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
public CollectionItemData (KrollDict properties, CollectionViewTemplate template) {
this.properties = properties;
this.template = template;
//set searchableText
if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) {
Object props = properties.get(TiC.PROPERTY_PROPERTIES);
if (props instanceof HashMap) {
HashMap<String, Object> propsHash = (HashMap<String, Object>) props;
Object searchText = propsHash.get(TiC.PROPERTY_SEARCHABLE_TEXT);
if (propsHash.containsKey(TiC.PROPERTY_SEARCHABLE_TEXT) && searchText != null) {
searchableText = TiConvert.toString(searchText);
}
}
}
}
示例4: signin
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
@Kroll.method
public void signin(KrollDict props)
{
if (props.containsKey("success")) {
successCallback = (KrollFunction) props.get("success");
}
if (props.containsKey("error")) {
errorCallback = (KrollFunction) props.get("error");
}
String[] accountTypes = new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE };
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
accountTypes, false, null, null, null, null);
Activity activity = TiApplication.getAppCurrentActivity();
TiActivitySupport support = (TiActivitySupport) activity;
requestCode = support.getUniqueResultCode();
support.launchActivityForResult(intent, requestCode, this);
}
示例5: 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;
}
示例6: 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;
}
示例7: initBeacon
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
@Kroll.method
public void initBeacon(HashMap args){
KrollDict arg = new KrollDict(args);
success =(KrollFunction) arg.get("success");
region=(KrollFunction) arg.get("region");
error =(KrollFunction) arg.get("error");
found =(KrollFunction) arg.get("found");
seconds=arg.optInt("interval",60);
}
示例8: bindProxiesAndProperties
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
private DataItem bindProxiesAndProperties(KrollDict properties, boolean isRootTemplate, DataItem parent) {
Object proxy = null;
String id = null;
Object props = null;
DataItem item = null;
if (properties.containsKey(TiC.PROPERTY_TI_PROXY)) {
proxy = properties.get(TiC.PROPERTY_TI_PROXY);
}
//Get/generate random bind id
if (isRootTemplate) {
id = itemID;
} else if (properties.containsKey(TiC.PROPERTY_BIND_ID)) {
id = TiConvert.toString(properties, TiC.PROPERTY_BIND_ID);
} else {
id = GENERATED_BINDING + Math.random();
}
if (proxy instanceof TiViewProxy) {
TiViewProxy viewProxy = (TiViewProxy) proxy;
if (isRootTemplate) {
rootItem = item = new DataItem(viewProxy, TiC.PROPERTY_PROPERTIES, null);
} else {
item = new DataItem(viewProxy, id, parent);
parent.addChild(item);
}
dataItems.put(id, item);
}
if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) {
props = properties.get(TiC.PROPERTY_PROPERTIES);
}
if (props instanceof HashMap) {
item.setDefaultProperties(new KrollDict((HashMap)props));
}
return item;
}
示例9: processTemplates
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
protected void processTemplates(KrollDict templates) {
for (String key : templates.keySet()) {
//Here we bind each template with a key so we can use it to look up later
KrollDict properties = new KrollDict((HashMap)templates.get(key));
CollectionViewTemplate template = new CollectionViewTemplate(key, properties);
//Set type to template, for recycling purposes.
template.setType(getItemType());
templatesByBinding.put(key, template);
//set parent of root item
template.setRootParent(proxy);
}
}
示例10: fireItemClick
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
private void fireItemClick(String event, Object data)
{
if (event.equals(TiC.EVENT_CLICK) && data instanceof HashMap) {
KrollDict eventData = new KrollDict((HashMap) data);
Object source = eventData.get(TiC.EVENT_PROPERTY_SOURCE);
if (source != null && !source.equals(this) && listProxy != null) {
TiViewProxy listViewProxy = listProxy.get();
if (listViewProxy != null) {
listViewProxy.fireEvent(TiC.EVENT_ITEM_CLICK, eventData);
}
}
}
}
示例11: handleCreationDict
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
public void handleCreationDict(KrollDict options) {
super.handleCreationDict(options);
//Adding sections to preload sections, so we can handle appendSections/insertSection
//accordingly if user call these before TiListView is instantiated.
if (options.containsKey(TiC.PROPERTY_SECTIONS)) {
Object obj = options.get(TiC.PROPERTY_SECTIONS);
if (obj instanceof Object[]) {
addPreloadSections((Object[]) obj, -1, true);
}
}
}
示例12: handleCreationDict
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
@Override
public void handleCreationDict(KrollDict dict) {
super.handleCreationDict(dict);
String[] options = null;
View view = null;
if (dict.containsKey(PROPERTY_OPTIONS)) {
options = dict.getStringArray(PROPERTY_OPTIONS);
}
if (options == null) {
throw new IllegalArgumentException("'options' is required");
}
if (dict.containsKey(PROPERTY_VIEW)) {
Object v = dict.get(PROPERTY_VIEW);
if (v instanceof TiViewProxy) {
TiViewProxy vp = (TiViewProxy) v;
view = vp.getOrCreateView().getOuterView();
}
if (v instanceof MenuItemProxy) {
view = getActivity().findViewById(((MenuItemProxy) v).getItemId());
}
}
if (view == null) {
throw new IllegalArgumentException("'view' is required");
}
mPopupMenu = new PopupMenu(getActivity(), view);
mPopupMenu.setOnMenuItemClickListener(this);
mPopupMenu.setOnDismissListener(this);
int i = 0;
for (String option : options) {
mPopupMenu.getMenu().add(Menu.NONE, Menu.NONE, i++, option);
}
}
示例13: initCrittercism
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
private void initCrittercism(KrollDict dict) {
String apiKey = (String) dict.get("apiKey");
Log.d(TAG, apiKey);
// Create the CrittercismConfig instance.
CrittercismConfig config = new CrittercismConfig();
Boolean includeVersionName = (Boolean)dict.get("includeVersionName");
Boolean includeVersionCode = (Boolean)dict.get("includeVersionCode");
if (includeVersionName!=null && includeVersionName) {
// set the custom version name.
try {
config.setCustomVersionName(currentActivity
.getPackageManager().getPackageInfo(
currentActivity.getPackageName(), 0).versionName);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (includeVersionCode!=null && includeVersionCode) {
// Set the custom version name.
config.setVersionCodeToBeIncludedInVersionString(true);
}
// Initialize.
Crittercism.initialize(currentActivity.getApplicationContext(),
apiKey, config);
Crittercism.setUsername((String) dict.get("userName"));
}
示例14: createCircle
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
/**
* <p>Draws a circle on the map view.</p>
* Supported parameters:<br>
* latlng Array<Integer> Like [45,12]<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<br>
* radius Integer Radius of the circle in meters.
* @param dict dictionary with key-value pairs: {key:value}.
*/
@Kroll.method
public HashMap createCircle(KrollDict dict) {
containsKey(dict, KEY_COORDINATE);
Object[] coordinate = (Object[]) dict.get(KEY_COORDINATE);
double lat = TiConvert.toDouble(coordinate[0]);
double lon = TiConvert.toDouble(coordinate[1]);
LatLong latLong = new LatLong(lat, lon);
Color fillColor = Color.RED;
Color strokeColor = Color.BLACK;
float strokeWidth = 0;
float radius = 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));
}
if (dict.containsKey(KEY_RADIUS)) {
radius = TiConvert.toFloat(dict.get(KEY_RADIUS));
}
if (radius < 0) {
throw new IllegalArgumentException("Parameter 'radius' can not be <0!");
}
int id = mView.createCircle(latLong, radius, fillColor, strokeColor, strokeWidth);
dict.put(KEY_ID, id);
dict.put(KEY_LAYERTYPE, TYPE_CIRCLE);
return dict;
}
示例15: createCustomGallery
import org.appcelerator.kroll.KrollDict; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Kroll.method
public void createCustomGallery(KrollDict options) {
if ( (options != null) && options.containsKeyAndNotNull(Defaults.Params.IMAGES) ) {
Object[] imageArray = (Object []) options.get(Defaults.Params.IMAGES);
int size = imageArray.length;
if (size != 0) {
ArrayList<ImageViewerInfo> imagesInfo = new ArrayList<ImageViewerInfo>();
for (int i=0; i<size; i++) {
Object o = imageArray[i];
KrollDict info = new KrollDict((HashMap<String, Object>) o);
if ( (info != null) && info.containsKeyAndNotNull(Defaults.Params.IMAGE_PATH) ) {
String path = info.getString(Defaults.Params.IMAGE_PATH);
String title = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE) ? info.getString(Defaults.Params.IMAGE_TITLE) : "";
String titleColor = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE_COLOR) ? info.getString(Defaults.Params.IMAGE_TITLE_COLOR) : Defaults.IMAGE_TITLE_COLOR;
String titleBgColor = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE_BACKGROUND_COLOR) ? info.getString(Defaults.Params.IMAGE_TITLE_BACKGROUND_COLOR) : Defaults.IMAGE_TITLE_BACKGROUND_COLOR;
imagesInfo.add(new ImageViewerInfo(path, title, titleColor, titleBgColor));
}
}
if (imagesInfo.size() > 0) {
Activity activity = TiApplication.getAppCurrentActivity();
Intent intent = new Intent(activity, ImageViewerActivity.class);
intent = prepareExtrasForIntent(intent, options, false);
intent.putParcelableArrayListExtra(Defaults.Params.IMAGES, imagesInfo);
activity.startActivity(intent);
}
} else {
Log.e(Defaults.LCAT, "No images passed.");
}
} else {
Log.e(Defaults.LCAT, "No options passed.");
}
}