List of usage examples for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS
int FOCUS_BLOCK_DESCENDANTS
To view the source code for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS.
Click Source Link
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;/*from ww w . j av a 2 s . c o m*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:org.chromium.chrome.browser.autofill.CardUnmaskPrompt.java
/** * Updates the verification overlay and main contents such that the overlay has |visibility|. * @param visibility A View visibility enumeration value. *//* w w w . j a v a 2 s . co m*/ private void setOverlayVisibility(int visibility) { mVerificationOverlay.setVisibility(visibility); mControlsContainer.setAlpha(1f); boolean contentsShowing = visibility == View.GONE; if (!contentsShowing) { int durationMs = 250; mVerificationOverlay.setAlpha(0f); mVerificationOverlay.animate().alpha(1f).setDuration(durationMs); mControlsContainer.animate().alpha(0f).setDuration(durationMs); } ViewCompat.setImportantForAccessibility(mControlsContainer, contentsShowing ? View.IMPORTANT_FOR_ACCESSIBILITY_AUTO : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); mControlsContainer.setDescendantFocusability( contentsShowing ? ViewGroup.FOCUS_BEFORE_DESCENDANTS : ViewGroup.FOCUS_BLOCK_DESCENDANTS); }
From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final RRThemeAttributes attr = new RRThemeAttributes(context); mPost = post;/*from w w w. ja v a 2 s . com*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.rrMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && RRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, RRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:com.ryan.ryanreader.fragments.CommentListingFragment.java
private void makeFirstRequest(final Context context) { final RedditAccount user = RedditAccountManager.getInstance(context).getDefaultAccount(); final CacheManager cm = CacheManager.getInstance(context); // TODO parameterise limit request = new CacheRequest(url, user, session, Constants.Priority.API_COMMENT_LIST, 0, downloadType, Constants.FileType.COMMENT_LIST, true, true, false, context) { @Override// w w w. j a v a 2s . co m protected void onDownloadNecessary() { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { listFooter.addView(loadingView); adapter.notifyDataSetChanged(); } }); } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(context.getString(R.string.download_connecting)); } @Override protected void onCallbackException(final Throwable t) { request = null; BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { request = null; if (!isAdded()) return; if (loadingView != null) loadingView.setDoneNoAnim(R.string.download_failed); final RRError error = General.getGeneralErrorForFailure(context, type, t, status); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { notifications.addView(new ErrorView(getSupportActivity(), error)); } }); } @Override protected void onProgress(final long bytesRead, final long totalBytes) { } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, final long timestamp, final UUID session, final boolean fromCache, final String mimetype) { request = null; } @Override public void onJsonParseStarted(final JsonValue value, final long timestamp, final UUID session, final boolean fromCache) { if (isAdded() && loadingView != null) loadingView.setIndeterminate("Downloading..."); // TODO pref (currently 10 mins) // TODO xml if (fromCache && RRTime.since(timestamp) > 10 * 60 * 1000) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isDetached()) return; final TextView cacheNotif = new TextView(context); cacheNotif.setText(context.getString(R.string.listing_cached) + " " + RRTime.formatDateTime(timestamp, context)); final int paddingPx = General.dpToPixels(context, 6); final int sidePaddingPx = General.dpToPixels(context, 10); cacheNotif.setPadding(sidePaddingPx, paddingPx, sidePaddingPx, paddingPx); cacheNotif.setTextSize(13f); listHeaderNotifications.addView(cacheNotif); adapter.notifyDataSetChanged(); } }); } ((SessionChangeListener) getSupportActivity()).onSessionChanged(session, SessionChangeListener.SessionChangeType.COMMENTS, timestamp); // TODO {"error": 403} is received for unauthorized subreddits try { // Download main post if (value.getType() == JsonValue.Type.ARRAY) { // lol, reddit api final JsonBufferedArray root = value.asArray(); final JsonBufferedObject thing = root.get(0).asObject(); final JsonBufferedObject listing = thing.getObject("data"); final JsonBufferedArray postContainer = listing.getArray("children"); final RedditThing postThing = postContainer.getObject(0, RedditThing.class); final RedditPost post = postThing.asPost(); // TODO show upvote/downvote/etc buttons final RedditSubreddit parentSubreddit = new RedditSubreddit("/r/" + post.subreddit, post.subreddit, false); CommentListingFragment.this.post = new RedditPreparedPost(context, cm, 0, post, timestamp, true, parentSubreddit, false, false, false, user); final ViewGroup selfText; if (post.is_self && post.selftext != null && post.selftext.trim().length() > 0) { selfText = RedditCommentTextParser.parse(StringEscapeUtils.unescapeHtml4(post.selftext)) .generate(context, 14f * commentFontScale, null, new ActiveTextView.OnLinkClickedListener() { public void onClickUrl(String url) { if (url != null) LinkHandler.onLinkClicked(getSupportActivity(), url, false); } public void onClickText(Object attachment) { } }, CommentListingFragment.this.post); } else { selfText = null; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final RedditPostHeaderView postHeader = new RedditPostHeaderView( getSupportActivity(), CommentListingFragment.this.post, CommentListingFragment.this); listHeaderPost.addView(postHeader); if (selfText != null) { selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); listHeaderSelftext.addView(selfText); listHeaderSelftext.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); listHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getSupportActivity().getSupportActionBar().setTitle(post.title); } } }); } // Download comments final JsonBufferedObject thing; if (value.getType() == JsonValue.Type.ARRAY) { thing = value.asArray().get(1).asObject(); } else { thing = value.asObject(); } final JsonBufferedObject listing = thing.getObject("data"); final JsonBufferedArray topLevelComments = listing.getArray("children"); final HashSet<String> needsChanging = RedditChangeDataManager.getInstance(context) .getChangedForParent(parentPostIdAndType, user); for (final JsonValue commentThingValue : topLevelComments) { buildComments(commentThingValue, null, timestamp, needsChanging); } commentHandler.sendMessage(General.handlerMessage(0, buffer)); } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "Parse failure"); return; } if (isAdded() && loadingView != null) loadingView.setDoneNoAnim(R.string.download_done); } private ArrayList<RedditPreparedComment> buffer = new ArrayList<RedditPreparedComment>(); private void buildComments(final JsonValue value, final RedditPreparedComment parent, final long timestamp, final HashSet<String> needsChanging) throws IOException, InterruptedException, IllegalAccessException, java.lang.InstantiationException, NoSuchMethodException, InvocationTargetException { final RedditThing commentThing = value.asObject(RedditThing.class); if (commentThing.getKind() != RedditThing.Kind.COMMENT) return; final RedditComment comment = commentThing.asComment(); final RedditPreparedComment preparedComment = new RedditPreparedComment(context, comment, parent, timestamp, needsChanging.contains(comment.name), post, user, headerItems); after = preparedComment.idAndType; buffer.add(preparedComment); if (buffer.size() >= 40) { commentHandler.sendMessage(General.handlerMessage(0, buffer)); buffer = new ArrayList<RedditPreparedComment>(); } if (comment.replies.getType() == JsonValue.Type.OBJECT) { final JsonBufferedObject replies = comment.replies.asObject(); final JsonBufferedArray children = replies.getObject("data").getArray("children"); for (final JsonValue v : children) { buildComments(v, preparedComment, timestamp, needsChanging); } } } }; cm.makeRequest(request); }
From source file:org.lol.reddit.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getSupportActivity(); if (mPost == null) { mPost = post;/*from ww w .j ava 2 s .c o m*/ final RedditPostHeaderView postHeader = new RedditPostHeaderView(getSupportActivity(), CommentListingFragment.this.mPost); listHeaderPost.addView(postHeader); if (post.parsedSelfText != null) { final ViewGroup selfText = post.parsedSelfText.buildView(getSupportActivity(), null, 14f * commentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); listHeaderSelftext.addView(selfText); listHeaderSelftext.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); listHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getSupportActivity().getSupportActionBar().setTitle(StringEscapeUtils.unescapeHtml4(post.title)); } } }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
/** * Indicates that the views created by the ListAdapter can contain focusable * items./*from w w w .j av a 2 s .c o m*/ * * @param itemsCanFocus true if items can get focus, false otherwise */ public void setItemsCanFocus(boolean itemsCanFocus) { mItemsCanFocus = itemsCanFocus; if (!itemsCanFocus) { setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); } }
From source file:com.artifex.mupdflib.TwoWayView.java
/** * Indicates that the views created by the ListAdapter can contain focusable * items.//from ww w . j a v a2 s . com * * @param itemsCanFocus true if items can get focus, false otherwise */ @SuppressWarnings("unused") public void setItemsCanFocus(boolean itemsCanFocus) { mItemsCanFocus = itemsCanFocus; if (!itemsCanFocus) { setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); } }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
/** * Binds a {@link ViewHolder} to a particular {@link GuidedAction}. * @param vh The view holder to be associated with the given action. * @param action The guided action to be displayed by the view holder's view. * @return The view to be added to the caller's view hierarchy. *//*from w w w . j a v a2 s . c om*/ public void onBindViewHolder(ViewHolder vh, GuidedAction action) { vh.mAction = action; if (vh.mTitleView != null) { vh.mTitleView.setText(action.getTitle()); vh.mTitleView.setAlpha(action.isEnabled() ? mEnabledTextAlpha : mDisabledTextAlpha); vh.mTitleView.setFocusable(false); vh.mTitleView.setClickable(false); vh.mTitleView.setLongClickable(false); } if (vh.mDescriptionView != null) { vh.mDescriptionView.setText(action.getDescription()); vh.mDescriptionView .setVisibility(TextUtils.isEmpty(action.getDescription()) ? View.GONE : View.VISIBLE); vh.mDescriptionView.setAlpha(action.isEnabled() ? mEnabledDescriptionAlpha : mDisabledDescriptionAlpha); vh.mDescriptionView.setFocusable(false); vh.mDescriptionView.setClickable(false); vh.mDescriptionView.setLongClickable(false); } // Clients might want the check mark view to be gone entirely, in which case, ignore it. if (vh.mCheckmarkView != null) { onBindCheckMarkView(vh, action); } setIcon(vh.mIconView, action); if (action.hasMultilineDescription()) { if (vh.mTitleView != null) { setMaxLines(vh.mTitleView, mTitleMaxLines); if (vh.mDescriptionView != null) { vh.mDescriptionView .setMaxHeight(getDescriptionMaxHeight(vh.itemView.getContext(), vh.mTitleView)); } } } else { if (vh.mTitleView != null) { setMaxLines(vh.mTitleView, mTitleMinLines); } if (vh.mDescriptionView != null) { setMaxLines(vh.mDescriptionView, mDescriptionMinLines); } } if (vh.mActivatorView != null) { onBindActivatorView(vh, action); } setEditingMode(vh, action, false); if (action.isFocusable()) { vh.itemView.setFocusable(true); ((ViewGroup) vh.itemView).setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); } else { vh.itemView.setFocusable(false); ((ViewGroup) vh.itemView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); } setupImeOptions(vh, action); updateChevronAndVisibility(vh); }
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 www . j a v a2s . c om*/ // 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 ww .j a v a2s .c o m 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); }