Example usage for android.view ViewGroup FOCUS_AFTER_DESCENDANTS

List of usage examples for android.view ViewGroup FOCUS_AFTER_DESCENDANTS

Introduction

In this page you can find the example usage for android.view ViewGroup FOCUS_AFTER_DESCENDANTS.

Prototype

int FOCUS_AFTER_DESCENDANTS

To view the source code for android.view ViewGroup FOCUS_AFTER_DESCENDANTS.

Click Source Link

Document

This view will get focus only if none of its descendants want it.

Usage

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

public DebugDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);/*from   w w w.  j a  va2s.  c o m*/

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }
}

From source file:com.xiaosu.lib.base.widget.drawerLayout.DrawerLayout.java

public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    // So that we can catch the back button
    setFocusableInTouchMode(true);/*from   w  ww  .  j  a va2 s .  c  om*/

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);

    mDrawerElevation = DRAWER_ELEVATION * density;

    mNonDrawerViews = new ArrayList<View>();

    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    mScroller = ScrollerCompat.create(context, sInterpolator);

    setNestedScrollingEnabled(true);
}

From source file:com.sanron.sunweather.view.v4.DrawerLayout.java

public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);/*from w  w  w . ja  va2  s.  c  om*/

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
    }
}

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);//from  w  w w .  j a  va  2 s.  c  o m

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }

    mDrawerElevation = DRAWER_ELEVATION * density;

    mNonDrawerViews = new ArrayList<View>();
}

From source file:com.jecelyin.editor.v2.widget.AnyDrawerLayout.java

public AnyDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);
    mBottomCallback = new ViewDragCallback(Gravity.BOTTOM);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback);
    mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    mBottomDragger.setMinVelocity(minVel);
    mBottomCallback.setDragger(mBottomDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);/*from   ww w .jav  a  2 s .  c om*/

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }

    mDrawerElevation = DRAWER_ELEVATION * density;

    mNonDrawerViews = new ArrayList<View>();
}

From source file:com.zyk.drawerlayout.widget.DrawerLayout.java

public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    density = getResources().getDisplayMetrics().density;
    mMinDrawerMarginWidth = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    //FIXME ????//from www  .  j  av a 2  s.  co  m
    mMinDrawerMarginHeight = mMinDrawerMarginWidth;
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);
    mTopCallback = new ViewDragCallback(Gravity.TOP);
    mBottomCallback = new ViewDragCallback(Gravity.BOTTOM);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback);
    mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP);
    mTopDragger.setMinVelocity(minVel);
    mTopCallback.setDragger(mTopDragger);

    mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback);
    mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    mBottomDragger.setMinVelocity(minVel);
    mBottomCallback.setDragger(mBottomDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }

    mDrawerElevation = DRAWER_ELEVATION * density;

    mNonDrawerViews = new ArrayList<View>();
}

From source file:ti.modules.titanium.ui.widget.abslistview.TiAbsListView.java

public TiAbsListView(TiViewProxy proxy, Activity activity) {
    super(proxy);

    //initializing variables
    sections = Collections.synchronizedList(new ArrayList<AbsListSectionProxy>());
    itemTypeCount = new AtomicInteger(CUSTOM_TEMPLATE_ITEM_TYPE);
    templatesByBinding = new HashMap<String, TiAbsListViewTemplate>();
    defaultTemplateBinding = defaultTemplateKey;
    templatesByBinding.put(defaultTemplateKey, defaultTemplate);
    defaultTemplate.setType(BUILT_IN_TEMPLATE_ITEM_TYPE);
    caseInsensitive = true;//from  w w w. ja  v a 2  s.  co m
    ignoreExactMatch = false;

    //handling marker
    HashMap preloadMarker = ((AbsListViewProxy) proxy).getPreloadMarker();
    if (preloadMarker != null) {
        setMarker(preloadMarker);
    } else {
        resetMarker();
    }

    final KrollProxy fProxy = proxy;
    //initializing listView
    listView = createListView(activity);
    listView.setSelector(android.R.color.transparent);
    listView.setAreHeadersSticky(false);

    //      listView.setDuplicateParentStateEnabled(true);
    AbsListView internalListView = getInternalListView();
    if (TiC.LOLLIPOP_OR_GREATER) {
        listView.setNestedScrollingEnabled(true);
        internalListView.setNestedScrollingEnabled(true);
    }
    if (internalListView instanceof ListView) {
        ((ListView) internalListView).setHeaderDividersEnabled(false);
        ((ListView) internalListView).setFooterDividersEnabled(false);
    }

    if (listView instanceof CustomListView) {
        ((CustomListView) listView).setOnPullListener(new OnPullListener() {
            private boolean canUpdate = false;

            @Override
            public void onPull(boolean canUpdate) {
                if (canUpdate != this.canUpdate) {
                    this.canUpdate = canUpdate;
                    if (fProxy.hasListeners(TiC.EVENT_PULL_CHANGED, false)) {
                        KrollDict event = dictForScrollEvent();
                        event.put("active", canUpdate);
                        fProxy.fireEvent(TiC.EVENT_PULL_CHANGED, event, false, false);
                    }
                }
                if (fProxy.hasListeners(TiC.EVENT_PULL, false)) {
                    KrollDict event = dictForScrollEvent();
                    event.put("active", canUpdate);
                    fProxy.fireEvent(TiC.EVENT_PULL, event, false, false);
                }
            }

            @Override
            public void onPullEnd(boolean canUpdate) {
                if (fProxy.hasListeners(TiC.EVENT_PULL_END, false)) {
                    KrollDict event = dictForScrollEvent();
                    event.put("active", canUpdate);
                    fProxy.fireEvent(TiC.EVENT_PULL_END, event, false, false);
                }
            }
        });
    }

    adapter = new TiBaseAdapter(activity);
    listView.setOnScrollListener(new OnScrollListener() {
        private boolean scrollTouch = false;
        private int lastValidfirstItem = 0;
        private Timer endTimer = null;

        public void cancelEndCall() {
            if (endTimer != null) {
                endTimer.cancel();
                endTimer = null;
            }
        }

        public void delayEndCall() {
            cancelEndCall();
            endTimer = new Timer();

            TimerTask action = new TimerTask() {
                public void run() {
                    scrollTouch = false;
                    if (fProxy.hasListeners(TiC.EVENT_SCROLLEND, false)) {
                        fProxy.fireEvent(TiC.EVENT_SCROLLEND, dictForScrollEvent(), false, false);
                    }
                }

            };

            this.endTimer.schedule(action, 200);
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

            view.requestDisallowInterceptTouchEvent(scrollState != ViewPager.SCROLL_STATE_IDLE);
            if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                if (scrollTouch) {
                    delayEndCall();
                }
            } else if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
                cancelEndCall();
            } else if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                cancelEndCall();
                if (hideKeyboardOnScroll && hasFocus()) {
                    blur();
                }
                if (scrollTouch == false) {
                    scrollTouch = true;
                    if (fProxy.hasListeners(TiC.EVENT_SCROLLSTART, false)) {
                        fProxy.fireEvent(TiC.EVENT_SCROLLSTART, dictForScrollEvent(), false, false);
                    }
                }
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            //            Log.d(TAG, "onScroll : " + scrollValid, Log.DEBUG_MODE);
            //            boolean fireScroll = scrollValid;
            //            if (!fireScroll && visibleItemCount > 0) {
            //               //Items in a list can be selected with a track ball in which case
            //               //we must check to see if the first visibleItem has changed.
            //               fireScroll = (lastValidfirstItem != firstVisibleItem);
            //            }
            if (fProxy.hasListeners(TiC.EVENT_SCROLL, false)) {
                int newScrollOffset = getScroll();
                //                   Log.d(TAG, "newScrollOffset : " + newScrollOffset, Log.DEBUG_MODE);
                lastValidfirstItem = firstVisibleItem;
                if (newScrollOffset != currentScrollOffset) {
                    currentScrollOffset = newScrollOffset;
                    fProxy.fireEvent(TiC.EVENT_SCROLL, dictForScrollEvent(currentScrollOffset), false, false);
                }
            }
        }
    });

    listView.setOnStickyHeaderChangedListener(new OnStickyHeaderChangedListener() {

        @Override
        public void onStickyHeaderChanged(StickyListHeadersListViewAbstract l, View header, int itemPosition,
                long headerId) {
            //for us headerId is the section index
            int sectionIndex = (int) headerId;
            if (fProxy.hasListeners(TiC.EVENT_HEADER_CHANGE, false)) {
                KrollDict data = new KrollDict();
                AbsListSectionProxy section = null;
                synchronized (sections) {
                    if (sectionIndex >= 0 && sectionIndex < sections.size()) {
                        section = sections.get(sectionIndex);
                    } else {
                        return;
                    }
                }
                data.put(TiC.PROPERTY_HEADER_VIEW, section.getHoldedProxy(TiC.PROPERTY_HEADER_VIEW));
                data.put(TiC.PROPERTY_SECTION, section);
                data.put(TiC.PROPERTY_SECTION_INDEX, sectionIndex);
                fProxy.fireEvent(TiC.EVENT_HEADER_CHANGE, data, false, false);
            }
        }
    });

    internalListView.setCacheColorHint(Color.TRANSPARENT);
    listView.setEnabled(true);
    getLayoutParams().autoFillsHeight = true;
    getLayoutParams().autoFillsWidth = true;
    //      listView.setFocusable(false);
    listView.setFocusable(true);
    listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    //       try {
    // //         headerFooterId = TiRHelper.getApplicationResource("layout.titanium_ui_list_header_or_footer");
    // //         titleId = TiRHelper.getApplicationResource("id.titanium_ui_list_header_or_footer_title");
    //          isCheck = TiRHelper.getApplicationResource("drawable.btn_check_buttonless_on_64");
    //          hasChild = TiRHelper.getApplicationResource("drawable.btn_more_64");
    //          disclosure = TiRHelper.getApplicationResource("drawable.disclosure_64");
    //       } catch (ResourceNotFoundException e) {
    //          Log.e(TAG, "XML resources could not be found!!!", Log.DEBUG_MODE);
    //       }
    setNativeView(listView);
}

From source file:cn.ismartv.tvrecyclerview.widget.RecyclerView.java

public RecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, CLIP_TO_PADDING_ATTR, defStyle, 0);
        mClipToPadding = a.getBoolean(0, true);
        a.recycle();/*from ww w  .j ava2s  .co  m*/
    } else {
        mClipToPadding = true;
    }
    setScrollContainer(true);
    setFocusableInTouchMode(true);
    final int version = Build.VERSION.SDK_INT;
    mPostUpdatesOnAnimation = version >= 16;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    setWillNotDraw(getOverScrollMode() == View.OVER_SCROLL_NEVER);

    mItemAnimator.setListener(mItemAnimatorListener);
    initAdapterManager();
    initChildrenHelper();
    // If not explicitly specified this view is important for accessibility.
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    setAccessibilityDelegateCompat(new RecyclerViewAccessibilityDelegate(this));
    // Create the layoutManager if specified.

    boolean nestedScrollingEnabled = true;

    if (attrs != null) {
        int defStyleRes = 0;
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecyclerView, defStyle, defStyleRes);
        String layoutManagerName = a.getString(R.styleable.RecyclerView_layoutManager);
        int descendantFocusability = a.getInt(R.styleable.RecyclerView_android_descendantFocusability, -1);
        if (descendantFocusability == -1) {
            setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
        a.recycle();
        createLayoutManager(context, layoutManagerName, attrs, defStyle, defStyleRes);

        if (Build.VERSION.SDK_INT >= 21) {
            a = context.obtainStyledAttributes(attrs, NESTED_SCROLLING_ATTRS, defStyle, defStyleRes);
            nestedScrollingEnabled = a.getBoolean(0, true);
            a.recycle();
        }
    } else {
        setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    }

    // Re-set whether nested scrolling is enabled so that it is set on all API levels
    setNestedScrollingEnabled(nestedScrollingEnabled);
}

From source file:org.mozilla.gecko.AwesomeBarTabs.java

public void filter(String searchTerm) {
    // Don't let the tab's content steal focus on tab switch
    setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

    // Ensure the 'All Pages' tab is selected
    setCurrentTabByTag(ALL_PAGES_TAB);//from ww  w.  jav  a  2s  . c o  m

    // Restore normal focus behavior on tab host
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    // The tabs should only be visible if there's no on-going search
    int tabsVisibility = (searchTerm.length() == 0 ? View.VISIBLE : View.GONE);
    getTabWidget().setVisibility(tabsVisibility);

    // Perform the actual search
    mAllPagesCursorAdapter.filter(searchTerm);
}

From source file:ti.modules.titanium.ui.widget.collectionview.TiCollectionView.java

public TiCollectionView(TiViewProxy proxy, Activity activity) {
    super(proxy);

    // initializing variables
    sections = Collections.synchronizedList(new ArrayList<AbsListSectionProxy>());
    itemTypeCount = new AtomicInteger(CUSTOM_TEMPLATE_ITEM_TYPE);
    defaultTemplateBinding = defaultTemplateKey;
    defaultTemplate.setType(BUILT_IN_TEMPLATE_ITEM_TYPE);
    processTemplates(null);//  w  w  w  .ja v  a 2 s .c  om

    caseInsensitive = true;
    ignoreExactMatch = false;

    // handling marker
    HashMap<String, Integer> preloadMarker = ((AbsListViewProxy) proxy).getPreloadMarker();
    if (preloadMarker != null) {
        setMarker(preloadMarker);
    } else {
        resetMarker();
    }

    final KrollProxy fProxy = proxy;
    layoutManager = new TiGridLayoutManager(activity);

    // trick to get scrollbar to be initialized!
    mRecyclerView = new FastScrollRecyclerView(activity, null,
            Resources.getSystem().getIdentifier("listViewStyle", "attr", "android")) {
        // private boolean viewFocused = false;
        private boolean selectionSet = false;

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            // if ((Build.VERSION.SDK_INT >= 18 && !changed && viewFocused))
            // {
            // viewFocused = false;
            // super.onLayout(changed, left, top, right, bottom);
            // return;
            // }
            // Starting with API 21, setSelection() triggers another layout
            // pass, so we need to end it here to prevent
            // an infinite loop
            if (Build.VERSION.SDK_INT >= 21 && selectionSet) {
                selectionSet = false;
                return;
            }
            OnFocusChangeListener focusListener = null;
            View focusedView = findFocus();
            int cursorPosition = -1;
            if (focusedView != null) {
                if (focusedView instanceof EditText) {
                    cursorPosition = ((EditText) focusedView).getSelectionStart();
                }
                OnFocusChangeListener listener = focusedView.getOnFocusChangeListener();
                if (listener != null && listener instanceof TiUIView) {
                    focusedView.setOnFocusChangeListener(null);
                    focusListener = listener;
                }
            }
            if (focusedView != null) {
                setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
            }
            super.onLayout(changed, left, top, right, bottom);
            setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

            if (changed) {
                TiUIHelper.firePostLayoutEvent(TiCollectionView.this);
            }

            // Layout is finished, re-enable focus events.
            if (focusedView != null) {
                // If the configuration changed, we manually fire the blur
                // event
                if (changed) {
                    focusedView.setOnFocusChangeListener(focusListener);
                    if (focusListener != null) {
                        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);
                        selectionSet = true;
                    }

                }
            }
        }
        // @Override
        // protected void onLayout(boolean changed, int left, int top,
        // int right, int bottom) {
        //
        // super.onLayout(changed, left, top, right, bottom);
        // if (changed) {
        // TiUIHelper.firePostLayoutEvent(TiCollectionView.this);
        // }
        //
        // }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (mColumnsWidth != null && !mColumnsWidth.isUnitFixed()) {
                layoutManager.setColumnWidth(mColumnsWidth.getAsPixels(this));
                // } else if (gridAdapter.updateNumColumns()) {
                // adapter.notifyDataSetChanged();
            }
            layoutManager.requestColumnUpdate();
        }

        @Override
        public void dispatchSetPressed(boolean pressed) {
            if (propagateSetPressed(this, pressed)) {
                super.dispatchSetPressed(pressed);
            }
        }

        @Override
        public boolean dispatchTouchEvent(MotionEvent event) {
            if (touchPassThrough(getParentViewForChild(), event))
                return false;
            return super.dispatchTouchEvent(event);
        }

        // @Override
        // public boolean dispatchTouchEvent(MotionEvent event) {
        // if (touchPassThrough == true)
        // return false;
        // return super.dispatchTouchEvent(event);
        // }

        @Override
        protected void dispatchDraw(Canvas canvas) {
            try {
                super.dispatchDraw(canvas);
            } catch (IndexOutOfBoundsException e) {
                // samsung error
            }
        }
    };
    // mRecyclerView.setClipChildren(false);

    mAdapter = new TiBaseAdapter(mRecyclerView.getContext(), null);
    mAdapter.setDisplayHeaders(true);
    mSwipeMenuTouchListener = new SwipeMenuTouchListener(this);
    mRecyclerView.addOnItemTouchListener(mSwipeMenuTouchListener);
    mRecyclerView.setItemAnimator(new TiItemAnimator());
    mRecyclerView.setHorizontalScrollBarEnabled(false);
    mRecyclerView.setVerticalScrollBarEnabled(true);
    mRecyclerView.setHasFixedSize(true);
    layoutManager.setSmoothScrollbarEnabled(true);
    mRecyclerView.addOnScrollListener(new OnScrollListener() {
        private boolean scrollTouch = false;
        private Timer endTimer = null;

        public void cancelEndCall() {
            if (endTimer != null) {
                endTimer.cancel();
                endTimer = null;
            }
        }

        public void delayEndCall() {
            cancelEndCall();
            endTimer = new Timer();

            TimerTask action = new TimerTask() {
                public void run() {
                    scrollTouch = false;
                    if (fProxy.hasListeners(TiC.EVENT_SCROLLEND, false)) {
                        fProxy.fireEvent(TiC.EVENT_SCROLLEND, dictForScrollEvent(), false, false);
                    }
                }

            };

            this.endTimer.schedule(action, 200);
        }

        @Override
        public void onScrollStateChanged(RecyclerView view, int scrollState) {

            view.requestDisallowInterceptTouchEvent(scrollState != ViewPager.SCROLL_STATE_IDLE);
            if (scrollState == RecyclerView.SCROLL_STATE_IDLE) {
                if (scrollTouch) {
                    delayEndCall();
                }
            } else if (scrollState == RecyclerView.SCROLL_STATE_SETTLING) {
                cancelEndCall();
            } else if (scrollState == RecyclerView.SCROLL_STATE_DRAGGING) {
                cancelEndCall();
                if (hideKeyboardOnScroll && hasFocus()) {
                    blur();
                }
                if (scrollTouch == false) {
                    scrollTouch = true;
                    if (fProxy.hasListeners(TiC.EVENT_SCROLLSTART, false)) {
                        fProxy.fireEvent(TiC.EVENT_SCROLLSTART, dictForScrollEvent(), false, false);
                    }
                }
            }
        }

        @Override
        public void onScrolled(RecyclerView view, int dx, int dy) {
            if (dx == 0 && dy == 0) {
                return;
            }

            if (fProxy.hasListeners(TiC.EVENT_SCROLL, false)) {
                fProxy.fireEvent(TiC.EVENT_SCROLL, dictForScrollEvent(), false, false);
            }
        }
    });

    // mRecyclerView.setOnStickyHeaderChangedListener(
    // new OnStickyHeaderChangedListener() {
    //
    // @Override
    // public void onStickyHeaderChanged(
    // StickyListHeadersListViewAbstract l, View header,
    // int itemPosition, long headerId) {
    // // for us headerId is the section index
    // int sectionIndex = (int) headerId;
    // if (fProxy.hasListeners(TiC.EVENT_HEADER_CHANGE,
    // false)) {
    // KrollDict data = new KrollDict();
    // AbsListSectionProxy section = null;
    // synchronized (sections) {
    // if (sectionIndex >= 0
    // && sectionIndex < sections.size()) {
    // section = sections.get(sectionIndex);
    // } else {
    // return;
    // }
    // }
    // data.put(TiC.PROPERTY_HEADER_VIEW, section
    // .getHoldedProxy(TiC.PROPERTY_HEADER_VIEW));
    // data.put(TiC.PROPERTY_SECTION, section);
    // data.put(TiC.PROPERTY_SECTION_INDEX, sectionIndex);
    // fProxy.fireEvent(TiC.EVENT_HEADER_CHANGE, data,
    // false, false);
    // }
    // }
    // });

    mRecyclerView.setEnabled(true);
    getLayoutParams().autoFillsHeight = true;
    getLayoutParams().autoFillsWidth = true;
    mRecyclerView.setFocusable(true);
    mRecyclerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    // try {
    //     isCheck = TiRHelper.getApplicationResource(
    //             "drawable.btn_check_buttonless_on_64");
    //     hasChild = TiRHelper.getApplicationResource("drawable.btn_more_64");
    //     disclosure = TiRHelper
    //             .getApplicationResource("drawable.disclosure_64");
    // } catch (ResourceNotFoundException e) {
    //     Log.e(TAG, "XML resources could not be found!!!", Log.DEBUG_MODE);
    // }

    // RelativeLayout layout = new RelativeLayout(proxy.getActivity()) {
    // @Override
    // protected void onLayout(boolean changed, int left, int top,
    // int right, int bottom) {
    // super.onLayout(changed, left, top, right, bottom);
    // if (changed) {
    // TiUIHelper.firePostLayoutEvent(TiCollectionView.this);
    // }
    // }
    //
    // @Override
    // public void dispatchSetPressed(boolean pressed) {
    // if (propagateSetPressed(this, pressed)) {
    // super.dispatchSetPressed(pressed);
    // }
    // }
    //
    // @Override
    // public boolean dispatchTouchEvent(MotionEvent event) {
    // if (touchPassThrough(getParentViewForChild(), event))
    // return false;
    // return super.dispatchTouchEvent(event);
    // }
    //
    // };
    // layout.addView(mRecyclerView);
    setNativeView(mRecyclerView);

    // needs to be fired after because
    // getStickyHeadersHolder will be called and need nativeView
    mRecyclerView.setLayoutManager(layoutManager);
    mAdapter.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(mAdapter);
}