Java Code Examples for org.appcelerator.titanium.util.TiConvert#toBoolean()

The following examples show how to use org.appcelerator.titanium.util.TiConvert#toBoolean() . 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: CollectionViewProxy.java    From TiCollectionView with MIT License 6 votes vote down vote up
@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);
	}
}
 
Example 2
Source File: RealSwitch.java    From RealSwitch with MIT License 5 votes vote down vote up
@Override
public void processProperties(KrollDict d) {
	super.processProperties(d);

	// Create Real Switch
	CompoundButton button = new Switch(proxy.getActivity()) {
		@Override
		protected void onLayout(boolean changed, int left, int top,
				int right, int bottom) {
			super.onLayout(changed, left, top, right, bottom);
			TiUIHelper.firePostLayoutEvent(proxy);
		}
	};

	setNativeView(button);
	updateButton(button, proxy.getProperties());
	button.setOnCheckedChangeListener(this);

	if (d.containsKey(TiC.PROPERTY_VALUE)) {
		oldValue = TiConvert.toBoolean(d, TiC.PROPERTY_VALUE);
	}

	View nativeView = getNativeView();
	if (nativeView != null) {
		updateButton((CompoundButton) nativeView, d);
	}
}
 
Example 3
Source File: ActionbarextrasModule.java    From actionbarextras with MIT License 5 votes vote down vote up
/**
 * disables or enables the icon
 * @param arg
 */
@Kroll.method @Kroll.setProperty
public void setDisableIcon(@Kroll.argument(optional = true) Boolean arg) {
	
	Boolean disabled = true;
	
	if (arg != null) {
		disabled = TiConvert.toBoolean(arg);
	}
	
	Message message = getMainHandler().obtainMessage(MSG_DISABLE_ICON, disabled);
	message.sendToTarget();
}
 
Example 4
Source File: CollectionView.java    From TiCollectionView with MIT License 4 votes vote down vote up
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {

		if (key.equals(TiC.PROPERTY_HEADER_TITLE)) {
			setHeaderTitle(TiConvert.toString(newValue));
		} else if (key.equals(TiC.PROPERTY_FOOTER_TITLE)) {
			setFooterTitle(TiConvert.toString(newValue));
		} else if (key.equals(TiC.PROPERTY_SECTIONS) && newValue instanceof Object[] ) {
			processSectionsAndNotify((Object[])newValue);
		} else if (key.equals(TiC.PROPERTY_SEARCH_TEXT)) {
			this.searchText = TiConvert.toString(newValue);
			if (this.searchText != null) {
				reFilter(this.searchText);
			}
		} else if (key.equals(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH)) {
			this.caseInsensitive = TiConvert.toBoolean(newValue, true);
			if (this.searchText != null) {
				reFilter(this.searchText);
			}
		} else if (key.equals(TiC.PROPERTY_SEARCH_VIEW)) {
			TiViewProxy searchView = (TiViewProxy) newValue;
			if (isSearchViewValid(searchView)) {
				TiUIView search = searchView.getOrCreateView();
				setSearchListener(searchView, search);
				if (searchLayout != null) {
					searchLayout.removeAllViews();
					addSearchLayout(searchLayout, searchView, search);
				} else {
					layoutSearchView(searchView);
				}
			} else {
				Log.e(TAG, "Searchview type is invalid");
			}
			
		} else if (key.equals(TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR) && newValue != null) {
			listView.setVerticalScrollBarEnabled(TiConvert.toBoolean(newValue));
		} else if (key.equals(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE) && newValue != null) {
			defaultTemplateBinding = TiConvert.toString(newValue);
			refreshItems();
		} else if (key.equals(TiC.PROPERTY_SEPARATOR_COLOR)) {
			String color = TiConvert.toString(newValue);
			setSeparatorColor(color);
		} else {
			super.propertyChanged(key, oldValue, newValue, proxy);
		}
	}