本文整理汇总了Java中org.appcelerator.titanium.proxy.TiViewProxy.fireEvent方法的典型用法代码示例。如果您正苦于以下问题:Java TiViewProxy.fireEvent方法的具体用法?Java TiViewProxy.fireEvent怎么用?Java TiViewProxy.fireEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.appcelerator.titanium.proxy.TiViewProxy
的用法示例。
在下文中一共展示了TiViewProxy.fireEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fireItemClick
import org.appcelerator.titanium.proxy.TiViewProxy; //导入方法依赖的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);
}
}
}
}
示例2: onLayout
import org.appcelerator.titanium.proxy.TiViewProxy; //导入方法依赖的package包/类
@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);
}
}
}
}