org.appcelerator.titanium.view.TiUIView Java Examples

The following examples show how to use org.appcelerator.titanium.view.TiUIView. 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: CollectionSectionProxy.java    From TiCollectionView with MIT License 6 votes vote down vote up
public void generateChildContentViews(DataItem item, TiUIView parentContent, BaseCollectionViewItem rootItem, boolean root) {

		ArrayList<DataItem> childrenItem = item.getChildren();
		for (int i = 0; i < childrenItem.size(); i++) {
			DataItem child = childrenItem.get(i);
			TiViewProxy proxy = child.getViewProxy();
			TiUIView view = proxy.createView(proxy.getActivity());
			view.registerForTouch();
			proxy.setView(view);
			generateChildContentViews(child, view, rootItem, false);
			//Bind view to root.
			
			ViewItem viewItem = new ViewItem(view, new KrollDict());
			rootItem.bindView(child.getBindingId(), viewItem);
			//Add it to view hierarchy
			if (root) {
				rootItem.addView(view.getNativeView(), view.getLayoutParams());
			} else {
				parentContent.add(view);
			}

		}
	}
 
Example #2
Source File: CollectionItem.java    From TiCollectionView with MIT License 6 votes vote down vote up
protected void handleFireItemClick (KrollDict data) {
	TiViewProxy listViewProxy = ((CollectionItemProxy)proxy).getListProxy();
	if (listViewProxy != null) {
		TiUIView listView = listViewProxy.peekView();
		if (listView != null) {
			KrollDict d = listView.getAdditionalEventData();
			if (d == null) {
				listView.setAdditionalEventData(new KrollDict((HashMap) additionalEventData));
			} else {
				d.clear();
				d.putAll(additionalEventData);
			}
			listView.fireEvent(TiC.EVENT_ITEM_CLICK, data);
		}
	}
}
 
Example #3
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 6 votes vote down vote up
@Kroll.setProperty @Kroll.method
public void setSections(Object sections)
{
	if (!(sections instanceof Object[])) {
		Log.e(TAG, "Invalid argument type to setSection(), needs to be an array", Log.DEBUG_MODE);
		return;
	}
	//Update java and javascript property
	setProperty(TiC.PROPERTY_SECTIONS, sections);

	Object[] sectionsArray = (Object[]) sections;
	TiUIView listView = peekView();
	//Preload sections if listView is not opened.
	if (listView == null) {
		preload = true;
		clearPreloadSections();
		addPreloadSections(sectionsArray, -1, true);
	} else {
		if (TiApplication.isUIThread()) {
			((CollectionView)listView).processSectionsAndNotify(sectionsArray);
		} else {
			TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_SECTIONS), sectionsArray);
		}
		
	}
}
 
Example #4
Source File: CameraViewProxy.java    From Ti-Android-CameraView with MIT License 5 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	view = new CameraView(this);
	act = activity;
	view.getLayoutParams().autoFillsHeight = true;
	view.getLayoutParams().autoFillsWidth = true;
	return view;
}
 
Example #5
Source File: ExampleProxy.java    From NovarumBluetooth with MIT License 5 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	TiUIView view = new ExampleView(this);
	view.getLayoutParams().autoFillsHeight = true;
	view.getLayoutParams().autoFillsWidth = true;
	return view;
}
 
Example #6
Source File: CollectionSectionProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	TiUIView view = new TiView(this);
	view.getLayoutParams().autoFillsHeight = true;
	view.getLayoutParams().autoFillsWidth = true;
	return view;
}
 
Example #7
Source File: ExampleProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	TiUIView view = new ExampleView(this);
	view.getLayoutParams().autoFillsHeight = true;
	view.getLayoutParams().autoFillsWidth = true;
	return view;
}
 
Example #8
Source File: BaseCollectionViewItem.java    From TiCollectionView with MIT License 5 votes vote down vote up
public TiUIView getViewFromBinding(String binding) {
	ViewItem viewItem = viewsMap.get(binding);
	if (viewItem != null) {
		return viewItem.getView();
	}
	return null;
}
 
Example #9
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
@Kroll.method @Kroll.getProperty
public boolean isRefreshing() {
	TiUIView listView = peekView();
	
	if (listView != null) {
		return ((CollectionView) listView).isRefreshing();
	}
	
	return false;
}
 
Example #10
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
@Kroll.method
public void setRefreshing(boolean refreshing) {
	TiUIView listView = peekView();
	
	if (listView != null) {
		((CollectionView) listView).setRefreshing(refreshing);
	}	
}
 
Example #11
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
private CollectionSectionProxy[] handleSections()
{
	TiUIView listView = peekView();

	if (listView != null) {
		return ((CollectionView) listView).getSections();
	}
	ArrayList<CollectionSectionProxy> preloadedSections = getPreloadSections();
	return preloadedSections.toArray(new CollectionSectionProxy[preloadedSections.size()]);
}
 
Example #12
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void handleReplaceSectionAt(int index, Object section) {
	TiUIView listView = peekView();
	if (listView != null) {
		((CollectionView) listView).replaceSectionAt(index, section);
	} else {
		handleDeleteSectionAt(index);
		handleInsertSectionAt(index,  section);
		
	}
}
 
Example #13
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void handleInsertSectionAt(int index, Object section) {
	TiUIView listView = peekView();
	if (listView != null) {
		((CollectionView) listView).insertSectionAt(index, section);
	} else {
		if (index < 0 || index > preloadSections.size()) {
			Log.e(TAG, "Invalid index to insertSection");
			return;
		}
		preload = true;
		addPreloadSections(section, index, false);
	}
}
 
Example #14
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void handleAppendSection(Object section) {
	TiUIView listView = peekView();
	if (listView != null) {
		((CollectionView) listView).appendSection(section);
	} else {
		preload = true;
		addPreloadSections(section, -1, false);
	}
}
 
Example #15
Source File: CollectionView.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void layoutSearchView(TiViewProxy searchView) {
	TiUIView search = searchView.getOrCreateView();
	RelativeLayout layout = new RelativeLayout(proxy.getActivity());
	layout.setGravity(Gravity.NO_GRAVITY);
	layout.setPadding(0, 0, 0, 0);
	addSearchLayout(layout, searchView, search);
	setNativeView(layout);	
}
 
Example #16
Source File: CollectionView.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void addSearchLayout(RelativeLayout layout, TiViewProxy searchView, TiUIView search) {
	RelativeLayout.LayoutParams p = createBasicSearchLayout();
	p.addRule(RelativeLayout.ALIGN_PARENT_TOP);

	TiDimension rawHeight;
	if (searchView.hasProperty(TiC.PROPERTY_HEIGHT)) {
		rawHeight = TiConvert.toTiDimension(searchView.getProperty(TiC.PROPERTY_HEIGHT), 0);
	} else {
		rawHeight = TiConvert.toTiDimension(MIN_SEARCH_HEIGHT, 0);
	}
	p.height = rawHeight.getAsPixels(layout);

	View nativeView = search.getNativeView();
	layout.addView(nativeView, p);

	p = createBasicSearchLayout();
	p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	p.addRule(RelativeLayout.BELOW, nativeView.getId());
	ViewParent parentWrapper = wrapper.getParent();
	if (parentWrapper != null && parentWrapper instanceof ViewGroup) {
		//get the previous layout params so we can reset with new layout
		ViewGroup.LayoutParams lp = wrapper.getLayoutParams();
		ViewGroup parentView = (ViewGroup) parentWrapper;
		//remove view from parent
		parentView.removeView(wrapper);
		//add new layout
		layout.addView(wrapper, p);
		parentView.addView(layout, lp);
		
	} else {
		layout.addView(wrapper, p);
	}
	this.searchLayout = layout;
}
 
Example #17
Source File: CollectionView.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void setSearchListener(TiViewProxy searchView, TiUIView search) 
{
	if (searchView instanceof SearchBarProxy) {
		((TiUISearchBar)search).setOnSearchChangeListener(this);
	} else if (searchView instanceof SearchViewProxy) {
		((TiUISearchView)search).setOnSearchChangeListener(this);
	}
}
 
Example #18
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
@Kroll.method
public void setMarker(Object marker) {
	if (marker instanceof HashMap) {
		HashMap<String, Integer> m = (HashMap<String, Integer>) marker;
		TiUIView listView = peekView();
		if (listView != null) {
			((CollectionView)listView).setMarker(m);
		} else {
			preloadMarker = m;
		}
	}
}
 
Example #19
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void handleDeleteSectionAt(int index) {
	TiUIView listView = peekView();
	if (listView != null) {
		((CollectionView) listView).deleteSectionAt(index);
	} else {
		if (index < 0 || index >= preloadSections.size()) {
			Log.e(TAG, "Invalid index to delete section");
			return;
		}
		preload = true;
		preloadSections.remove(index);
	}
}
 
Example #20
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 5 votes vote down vote up
public int handleSectionCount () {
	TiUIView listView = peekView();
	if (listView != null) {
		return ((CollectionView) listView).getSectionCount();
	}
	return 0;
}
 
Example #21
Source File: CollectionView.java    From TiCollectionView with MIT License 4 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
	// To prevent undesired "focus" and "blur" events during layout caused
	// by ListView temporarily taking focus, we will disable focus events until
	// layout has finished.
	// First check for a quick exit. listView can be null, such as if window closing.
	// Starting with API 18, calling requestFocus() will trigger another layout pass of the listview,
	// resulting in an infinite loop. Here we check if the view is already focused, and stop the loop.
	if (listView == null || (Build.VERSION.SDK_INT >= 18 && listView != null && !changed && viewFocused)) {
		viewFocused = false;
		super.onLayout(changed, left, top, right, bottom);
		return;
	}
	OnFocusChangeListener focusListener = null;
	View focusedView = listView.findFocus();
	int cursorPosition = -1;
	if (focusedView != null) {
		OnFocusChangeListener listener = focusedView.getOnFocusChangeListener();
		if (listener != null && listener instanceof TiUIView) {
			//Before unfocus the current editText, store cursor position so
			//we can restore it later
			if (focusedView instanceof EditText) {
				cursorPosition = ((EditText)focusedView).getSelectionStart();
			}
			focusedView.setOnFocusChangeListener(null);
			focusListener = listener;
		}
	}
	
	//We are temporarily going to block focus to descendants 
	//because LinearLayout on layout will try to find a focusable descendant
	if (focusedView != null) {
		listView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
	}
	super.onLayout(changed, left, top, right, bottom);
	//Now we reset the descendant focusability
	listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

	TiViewProxy viewProxy = proxy;
	if (viewProxy != null && viewProxy.hasListeners(TiC.EVENT_POST_LAYOUT)) {
		viewProxy.fireEvent(TiC.EVENT_POST_LAYOUT, null);
	}

	// Layout is finished, re-enable focus events.
	if (focusListener != null) {
		// If the configuration changed, we manually fire the blur event
		if (changed) {
			focusedView.setOnFocusChangeListener(focusListener);
			focusListener.onFocusChange(focusedView, false);
		} else {
			//Ok right now focus is with listView. So set it back to the focusedView
			viewFocused = true;
			focusedView.requestFocus();
			focusedView.setOnFocusChangeListener(focusListener);
			//Restore cursor position
			if (cursorPosition != -1) {
				((EditText)focusedView).setSelection(cursorPosition);
			}
		}
	}
}
 
Example #22
Source File: DrawerProxy.java    From Ti.DrawerLayout with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity) {
	drawer = new Drawer(this);
	return drawer;
}
 
Example #23
Source File: DatePickerProxy.java    From TiDialogs with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity) {
	return new BasicDatePicker(this);
}
 
Example #24
Source File: MultiPickerProxy.java    From TiDialogs with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity) {
	return new MultiPicker(this);
}
 
Example #25
Source File: TimePickerProxy.java    From TiDialogs with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity) {
	return new BasicDatePicker(this);
}
 
Example #26
Source File: RealSwitchProxy.java    From RealSwitch with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	return new RealSwitch(this);
}
 
Example #27
Source File: ViewProxy.java    From TiAndroidAutofocus with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	TiUIView view = new ExampleView(this);
	return view;
}
 
Example #28
Source File: ViewProxy.java    From TiTouchImageView with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity)
{
	return new TiTouchImageView(this);
}
 
Example #29
Source File: ViewProxy.java    From TiBubbleViewForAndroid with MIT License 4 votes vote down vote up
@Override
public TiUIView createView(Activity activity) {
	return new TiBubbleAndroidView(this);
}
 
Example #30
Source File: CollectionViewProxy.java    From TiCollectionView with MIT License 4 votes vote down vote up
private void handleScrollToItem(int sectionIndex, int itemIndex, boolean animated) {
	TiUIView listView = peekView();
	if (listView != null) {
		((CollectionView) listView).scrollToItem(sectionIndex, itemIndex, animated);
	}
}