org.appcelerator.titanium.proxy.TiViewProxy Java Examples
The following examples show how to use
org.appcelerator.titanium.proxy.TiViewProxy.
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: Drawer.java From Ti.DrawerLayout with MIT License | 6 votes |
/** * centerView 변경 */ private void replaceCenterView(TiViewProxy viewProxy) { if (viewProxy == this.centerView) { Log.d(TAG, "centerView was not changed"); return; } if (viewProxy == null) { return; } // update the main content by replacing fragments View contentView = viewProxy.getOrCreateView().getOuterView(); Fragment fragment = new ContentWrapperFragment(contentView); FragmentManager fragmentManager = ((ActionBarActivity)proxy.getActivity()).getSupportFragmentManager(); fragmentManager.beginTransaction().replace(id_content_frame, fragment).commit(); // fragmentManager.beginTransaction().replace(id_content_frame, fragment).commitAllowingStateLoss(); this.centerView = viewProxy; }
Example #2
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
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 #3
Source File: CollectionItem.java From TiCollectionView with MIT License | 6 votes |
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 #4
Source File: CameraViewProxy.java From Ti-Android-CameraView with MIT License | 5 votes |
public CameraView(TiViewProxy proxy) { super(proxy); SurfaceView preview = new SurfaceView(proxy.getActivity()); SurfaceHolder previewHolder = preview.getHolder(); previewHolder.addCallback(this); previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); FrameLayout previewLayout = new FrameLayout(proxy.getActivity()); previewLayout.addView(preview, layoutParams); setNativeView(previewLayout); }
Example #5
Source File: ExampleProxy.java From NovarumBluetooth with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #6
Source File: ViewProxy.java From TiAndroidAutofocus with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LinearLayout view = new LinearLayout( proxy.getActivity() ); view.setFocusable( true ); view.setFocusableInTouchMode( true ); setNativeView( view ); }
Example #7
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
/** * This method creates a new cell and fill it with content. getView() calls this method * when a view needs to be created. * @param index Entry's index relative to its section * @return */ public void generateCellContent(int sectionIndex, KrollDict data, CollectionViewTemplate template, BaseCollectionViewItem itemContent, int itemPosition, View item_layout) { //Here we create an item content and populate it with data //Get item proxy TiViewProxy itemProxy = template.getRootItem().getViewProxy(); //Create corresponding TiUIView for item proxy CollectionItem item = new CollectionItem(itemProxy, (TiCompositeLayout.LayoutParams)itemContent.getLayoutParams(), itemContent, item_layout); //Connect native view with TiUIView so we can get it from recycled view. itemContent.setTag(item); if (data != null && template != null) { generateChildContentViews(template.getRootItem(), null, itemContent, true); populateViews(data, itemContent, template, itemPosition, sectionIndex, item_layout); } }
Example #8
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
@Kroll.method @Kroll.setProperty public void setFooterView(TiViewProxy footerView) { if (TiApplication.isUIThread()) { handleSetFooterView(footerView); } else { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_FOOTER_VIEW), footerView); } }
Example #9
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
@Kroll.method @Kroll.setProperty public void setHeaderView(TiViewProxy headerView) { if (TiApplication.isUIThread()) { handleSetHeaderView(headerView); } else { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_HEADER_VIEW), headerView); } }
Example #10
Source File: CollectionItem.java From TiCollectionView with MIT License | 5 votes |
public CollectionItem(TiViewProxy proxy, LayoutParams p, View v, View item_layout) { super(proxy); layoutParams = p; listItemLayout = item_layout; setNativeView(v); registerForTouch(v); v.setFocusable(false); }
Example #11
Source File: ExampleProxy.java From TiCollectionView with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #12
Source File: CollectionItemProxy.java From TiCollectionView with MIT License | 5 votes |
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); } } } }
Example #13
Source File: CollectionItemProxy.java From TiCollectionView with MIT License | 5 votes |
public TiViewProxy getListProxy() { if (listProxy != null) { return listProxy.get(); } return null; }
Example #14
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
private boolean isSearchViewValid(TiViewProxy proxy) { if (proxy instanceof SearchBarProxy || proxy instanceof SearchViewProxy) { return true; } else { return false; } }
Example #15
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
private void setHeaderOrFooterView (Object viewObj, boolean isHeader) { if (viewObj instanceof TiViewProxy) { TiViewProxy viewProxy = (TiViewProxy)viewObj; View view = layoutHeaderOrFooterView(viewProxy); if (view != null) { if (isHeader) { headerView = view; } else { footerView = view; } } } }
Example #16
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
public DataItem(TiViewProxy proxy, String id, DataItem parent) { vProxy = proxy; bindId = id; this.parent = parent; setProxyParent(); children = new ArrayList<DataItem>(); defaultProperties = new KrollDict(); }
Example #17
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
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 #18
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
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 #19
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
private void setProxyParent() { if (vProxy != null && parent != null) { TiViewProxy parentProxy = parent.getViewProxy(); if (parentProxy != null) { vProxy.setParent(parentProxy); } } }
Example #20
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
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; }
Example #21
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
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 #22
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 4 votes |
@Kroll.method @Kroll.getProperty public TiViewProxy getFooterView() { return footerView; }
Example #23
Source File: RealSwitch.java From RealSwitch with MIT License | 4 votes |
public RealSwitch(TiViewProxy proxy) { super(proxy); }
Example #24
Source File: MultiPickerProxy.java From TiDialogs with MIT License | 4 votes |
public MultiPicker(TiViewProxy proxy) { super(proxy); }
Example #25
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 4 votes |
public TiViewProxy getViewProxy() { return vProxy; }
Example #26
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 4 votes |
private void handleSetFooterView(TiViewProxy footerView) { this.footerView = footerView; if (adapter != null) { adapter.notifyDataSetChanged(); } }
Example #27
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 4 votes |
private void handleSetHeaderView(TiViewProxy headerView) { this.headerView = headerView; if (adapter != null) { adapter.notifyDataSetChanged(); } }
Example #28
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 4 votes |
public void setRootParent(TiViewProxy listView) { CollectionItemProxy rootProxy = (CollectionItemProxy) rootItem.getViewProxy(); if (rootProxy != null && rootProxy.getListProxy() == null) { rootProxy.setListProxy(listView); } }
Example #29
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 4 votes |
@Kroll.method @Kroll.getProperty public TiViewProxy getHeaderView() { return headerView; }
Example #30
Source File: CollectionView.java From TiCollectionView with MIT License | 4 votes |
@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); } } } }