Java Code Examples for org.appcelerator.kroll.KrollDict#getString()

The following examples show how to use org.appcelerator.kroll.KrollDict#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraViewProxy.java    From Ti-Android-CameraView with MIT License 6 votes vote down vote up
@Override
public void processProperties(KrollDict d)
{	
	super.processProperties(d);
	
	if(d.containsKey("save_location")){
		SAVE = d.getString("save_location");
	}
	
	if( d.containsKey("useFrontCamera") ){
		Log.i(TAG, "Front Camera Property exists!");
		FRONT_CAMERA = d.getBoolean("useFrontCamera");
	}
	
	if( d.containsKey("pictureTimeout")){
		PICTURE_TIMEOUT = d.getInt("pictureTimeout");
	}
	
	if( d.containsKey("resolutionNamed") ){
		RESOLUTION_NAME = d.getInt("resolutionNamed");
	}
}
 
Example 2
Source File: RealSwitch.java    From RealSwitch with MIT License 5 votes vote down vote up
protected void updateButton(CompoundButton cb, KrollDict d) {
	if (d.containsKey(TiC.PROPERTY_TITLE_OFF)) {
		((Switch) cb).setTextOff(TiConvert.toString(d,
				TiC.PROPERTY_TITLE_OFF));
	}
	if (d.containsKey(TiC.PROPERTY_TITLE_ON)) {
		((Switch) cb).setTextOn(TiConvert.toString(d,
				TiC.PROPERTY_TITLE_ON));
	}
	if (d.containsKey(TiC.PROPERTY_VALUE)) {
		cb.setChecked(TiConvert.toBoolean(d, TiC.PROPERTY_VALUE));
	}
	if (d.containsKey(TiC.PROPERTY_COLOR)) {
		cb.setTextColor(TiConvert.toColor(d, TiC.PROPERTY_COLOR));
	}
	if (d.containsKey(TiC.PROPERTY_FONT)) {
		TiUIHelper.styleText(cb, d.getKrollDict(TiC.PROPERTY_FONT));
	}
	if (d.containsKey(TiC.PROPERTY_TEXT_ALIGN)) {
		String textAlign = d.getString(TiC.PROPERTY_TEXT_ALIGN);
		TiUIHelper.setAlignment(cb, textAlign, null);
	}
	if (d.containsKey(TiC.PROPERTY_VERTICAL_ALIGN)) {
		String verticalAlign = d.getString(TiC.PROPERTY_VERTICAL_ALIGN);
		TiUIHelper.setAlignment(cb, null, verticalAlign);
	}
	cb.invalidate();
}
 
Example 3
Source File: CameraViewProxy.java    From Ti-Android-CameraView with MIT License 5 votes vote down vote up
@Override
public void handleCreationDict(KrollDict options)
{
	super.handleCreationDict(options);
	
	if (options.containsKey("save_location")) {
		SAVE = options.getString("save_location");
	}
}
 
Example 4
Source File: TimePickerProxy.java    From TiDialogs with MIT License 5 votes vote down vote up
@Override
public void processProperties(KrollDict d) {
	super.processProperties(d);

	Calendar c = Calendar.getInstance();
	if (d.containsKey("value")) {
		c.setTime((Date) d.get("value"));
		hour = c.get(Calendar.HOUR_OF_DAY);
		minute = c.get(Calendar.MINUTE);
	} else {
		if (d.containsKey("hour")) {
			hour = d.getInt("hour");
		} else {
			hour = c.get(Calendar.HOUR_OF_DAY);
		}
		if (d.containsKey("minute")) {
			minute = d.getInt("minute");
		} else {
			minute = c.get(Calendar.MINUTE);
		}
	}

	if (d.containsKey("okButtonTitle")) {
		okButtonTitle = d.getString("okButtonTitle");
	} else {
		okButtonTitle =  this.proxy.getActivity().getApplication().getResources().getString(R.string.ok);
	}
	if (d.containsKey("cancelButtonTitle")) {
		cancelButtonTitle = d.getString("cancelButtonTitle");
	} else {
		cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel);
	}
}
 
Example 5
Source File: DatePickerProxy.java    From TiDialogs with MIT License 5 votes vote down vote up
@Override
public void processProperties(KrollDict d) {
	super.processProperties(d);
	Calendar c = Calendar.getInstance();
	if (d.containsKey("value")) {
		c.setTime((Date) d.get("value"));
		year = c.get(Calendar.YEAR);
		month = c.get(Calendar.MONTH);
		day = c.get(Calendar.DAY_OF_MONTH);
	} else {
		if (d.containsKey("year")) {
			year = d.getInt("year");
		} else {
			year = c.get(Calendar.YEAR);
		}
		if (d.containsKey("month")) {
			month = d.getInt("month");
		} else {
			month = c.get(Calendar.MONTH);
		}
		if (d.containsKey("day")) {
			day = d.getInt("day");
		} else {
			day = c.get(Calendar.DAY_OF_MONTH);
		}
	}

	if (d.containsKey("okButtonTitle")) {
		okButtonTitle = d.getString("okButtonTitle");
	} else {
		okButtonTitle =  this.proxy.getActivity().getApplication().getResources().getString(R.string.ok);
	}
	if (d.containsKey("cancelButtonTitle")) {
		cancelButtonTitle = d.getString("cancelButtonTitle");
	} else {
		cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel);
	}
}
 
Example 6
Source File: ImagepickerModule.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@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.");
	}
}
 
Example 7
Source File: ImagepickerModule.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@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.");
	}
}