Example usage for android.view ViewGroup setFocusable

List of usage examples for android.view ViewGroup setFocusable

Introduction

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

Prototype

public void setFocusable(boolean focusable) 

Source Link

Document

Set whether this view can receive the focus.

Usage

From source file:io.v.syncslides.NavigateFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle bundle = savedInstanceState;//  ww  w  .j  ava2s  .  c  o  m
    if (bundle == null) {
        bundle = getArguments();
    }
    String sessionId = bundle.getString(SESSION_ID_KEY);
    try {
        mSession = DB.Singleton.get().getSession(sessionId);
    } catch (VException e) {
        handleFatalError("Failed to fetch Session", e);
    }

    final View rootView = inflater.inflate(R.layout.fragment_navigate, container, false);

    //        mFabSync = rootView.findViewById(R.id.audience_sync_fab);
    //        if (((PresentationActivity) getActivity()).getSynced() || mRole != Role.AUDIENCE) {
    //            mFabSync.setVisibility(View.INVISIBLE);
    //        } else {
    //            mFabSync.setVisibility(View.VISIBLE);
    //        }
    //
    //        mFabSync.setOnClickListener(new NavigateClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                super.onClick(v);
    //                sync();
    //                mFabSync.setVisibility(View.INVISIBLE);
    //            }
    //        });
    View.OnClickListener previousSlideListener = new NavigateClickListener() {
        @Override
        void onNavigate() {
            previousSlide();
        }
    };
    View arrowBack = rootView.findViewById(R.id.arrow_back);
    arrowBack.setOnClickListener(previousSlideListener);
    mPrevThumb = (ImageView) rootView.findViewById(R.id.prev_thumb);
    mPrevThumb.setOnClickListener(previousSlideListener);

    View.OnClickListener nextSlideListener = new NavigateClickListener() {
        @Override
        void onNavigate() {
            nextSlide();
        }
    };
    // Show either the arrowForward or the FAB but not both.
    View arrowForward = rootView.findViewById(R.id.arrow_forward);
    View fabForward = rootView.findViewById(R.id.primary_navigation_fab);
    //        if (mRole == Role.PRESENTER) {
    //            arrowForward.setVisibility(View.INVISIBLE);
    //            fabForward.setOnClickListener(nextSlideListener);
    //        } else {
    fabForward.setVisibility(View.INVISIBLE);
    arrowForward.setOnClickListener(nextSlideListener);
    //        }
    mNextThumb = (ImageView) rootView.findViewById(R.id.next_thumb);
    mNextThumb.setOnClickListener(nextSlideListener);
    //        mQuestions = (ImageView) rootView.findViewById(R.id.questions);
    //        // TODO(kash): Hide the mQuestions button if mRole == BROWSER.
    //        mQuestions.setOnClickListener(new NavigateClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                super.onClick(v);
    //                questionButton();
    //            }
    //        });
    mCurrentSlide = (ImageView) rootView.findViewById(R.id.slide_current_medium);
    mCurrentSlide.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onNavigate() {
            // TODO(kash): Disallow presenter from switching to fullscreen.
            ((PresentationActivity) getActivity()).showFullscreenSlide();
        }
    });

    mSlideNumText = (TextView) rootView.findViewById(R.id.slide_num_text);
    mNotes = (EditText) rootView.findViewById(R.id.notes);
    mNotes.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            ((PresentationActivity) getActivity()).getSupportActionBar().show();
            mEditing = true;
            getActivity().invalidateOptionsMenu();
            // We don't want the presentation to advance while the user
            // is editing the notes.  Force the app to stay on this slide.
            try {
                mSession.setLocalSlideNum(mSlideNum);
            } catch (VException e) {
                handleFatalError("Could not set local slide num", e);
            }
        }
    });

    // The parent of mNotes needs to be focusable in order to clear focus
    // from mNotes when done editing.  We set the attributes in code rather
    // than in XML because it is too easy to add an extra level of layout
    // in XML and forget to add these attributes.
    ViewGroup parent = (ViewGroup) mNotes.getParent();
    parent.setFocusable(true);
    parent.setClickable(true);
    parent.setFocusableInTouchMode(true);

    //        View slideListIcon = rootView.findViewById(R.id.slide_list);
    //        slideListIcon.setOnClickListener(new NavigateClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                super.onClick(v);
    //                if (mRole == Role.AUDIENCE) {
    //                    ((PresentationActivity) getActivity()).showSlideList();
    //                } else {
    //                    getActivity().getSupportFragmentManager().popBackStack();
    //                }
    //            }
    //        });
    //        mQuestionsNum = (TextView) rootView.findViewById(R.id.questions_num);
    //        // Start off invisible for everyone.  If there are questions, this
    //        // will be set to visible in the mDB.getQuestionerList() callback.
    //        mQuestionsNum.setVisibility(View.INVISIBLE);
    //
    //        mDB = DB.Singleton.get(getActivity().getApplicationContext());
    //        mDB.getSlides(mDeckId, new DB.Callback<List<Slide>>() {
    //            @Override
    //            public void done(List<Slide> slides) {
    //                mSlides = slides;
    //                // The CurrentSlideListener could have been notified while we were waiting for
    //                // the slides to load.
    //                if (mLoadingCurrentSlide != -1) {
    //                    currentSlideChanged(mLoadingCurrentSlide);
    //                }
    //                updateView();
    //            }
    //        });
    //        if (((PresentationActivity) getActivity()).getSynced()) {
    //            sync();
    //        } else {
    //            unsync();
    //        }

    return rootView;
}

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;/*w w w.  j a  va2s .c  om*/
        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:io.v.android.apps.syncslides.NavigateFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle args;//  w  w  w .  jav  a2 s. c o  m
    if (savedInstanceState != null) {
        args = savedInstanceState;
    } else {
        args = getArguments();
    }
    mDeckId = args.getString(DECK_ID_KEY);
    mPresentationId = args.getString(PRESENTATION_ID_KEY);
    mLoadingCurrentSlide = -1;
    mCurrentSlideNum = mUserSlideNum = args.getInt(SLIDE_NUM_KEY);
    mRole = (Role) args.get(ROLE_KEY);
    final View rootView = inflater.inflate(R.layout.fragment_navigate, container, false);
    mFabSync = rootView.findViewById(R.id.audience_sync_fab);
    if (((PresentationActivity) getActivity()).getSynced() || mRole != Role.AUDIENCE) {
        mFabSync.setVisibility(View.INVISIBLE);
    } else {
        mFabSync.setVisibility(View.VISIBLE);
    }

    mFabSync.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            sync();
            mFabSync.setVisibility(View.INVISIBLE);
        }
    });
    View.OnClickListener previousSlideListener = new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            previousSlide();
        }
    };
    View arrowBack = rootView.findViewById(R.id.arrow_back);
    arrowBack.setOnClickListener(previousSlideListener);
    mPrevThumb = (ImageView) rootView.findViewById(R.id.prev_thumb);
    mPrevThumb.setOnClickListener(previousSlideListener);

    View.OnClickListener nextSlideListener = new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            nextSlide();
        }
    };
    // Show either the arrowForward or the FAB but not both.
    View arrowForward = rootView.findViewById(R.id.arrow_forward);
    View fabForward = rootView.findViewById(R.id.primary_navigation_fab);
    if (mRole == Role.PRESENTER) {
        arrowForward.setVisibility(View.INVISIBLE);
        fabForward.setOnClickListener(nextSlideListener);
    } else {
        fabForward.setVisibility(View.INVISIBLE);
        arrowForward.setOnClickListener(nextSlideListener);
    }
    mNextThumb = (ImageView) rootView.findViewById(R.id.next_thumb);
    mNextThumb.setOnClickListener(nextSlideListener);
    mQuestions = (ImageView) rootView.findViewById(R.id.questions);
    // TODO(kash): Hide the mQuestions button if mRole == BROWSER.
    mQuestions.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            questionButton();
        }
    });
    mCurrentSlide = (ImageView) rootView.findViewById(R.id.slide_current_medium);
    mCurrentSlide.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            if (mRole == Role.AUDIENCE || mRole == Role.BROWSER) {
                ((PresentationActivity) getActivity()).showFullscreenSlide(mUserSlideNum);
            }
        }
    });

    mSlideNumText = (TextView) rootView.findViewById(R.id.slide_num_text);
    mNotes = (EditText) rootView.findViewById(R.id.notes);
    mNotes.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            ((PresentationActivity) getActivity()).getSupportActionBar().show();
            mEditing = hasFocus;
            getActivity().invalidateOptionsMenu();
            unsync();
        }
    });

    // The parent of mNotes needs to be focusable in order to clear focus
    // from mNotes when done editing.  We set the attributes in code rather
    // than in XML because it is too easy to add an extra level of layout
    // in XML and forget to add these attributes.
    ViewGroup parent = (ViewGroup) mNotes.getParent();
    parent.setFocusable(true);
    parent.setClickable(true);
    parent.setFocusableInTouchMode(true);

    View slideListIcon = rootView.findViewById(R.id.slide_list);
    slideListIcon.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            if (mRole == Role.AUDIENCE) {
                ((PresentationActivity) getActivity()).showSlideList();
            } else {
                getActivity().getSupportFragmentManager().popBackStack();
            }
        }
    });
    mQuestionsNum = (TextView) rootView.findViewById(R.id.questions_num);
    // Start off invisible for everyone.  If there are questions, this
    // will be set to visible in the mDB.getQuestionerList() callback.
    mQuestionsNum.setVisibility(View.INVISIBLE);

    mDB = DB.Singleton.get(getActivity().getApplicationContext());
    mDB.getSlides(mDeckId, new DB.Callback<List<Slide>>() {
        @Override
        public void done(List<Slide> slides) {
            mSlides = slides;
            // The CurrentSlideListener could have been notified while we were waiting for
            // the slides to load.
            if (mLoadingCurrentSlide != -1) {
                currentSlideChanged(mLoadingCurrentSlide);
            }
            updateView();
        }
    });
    if (((PresentationActivity) getActivity()).getSynced()) {
        sync();
    } else {
        unsync();
    }

    return rootView;
}

From source file:org.alfresco.mobile.android.application.fragments.preferences.PasscodePreferences.java

private void disableEnableControls(boolean enable, ViewGroup vg) {
    for (int i = 0; i < vg.getChildCount(); i++) {
        View child = vg.getChildAt(i);
        child.setEnabled(enable);//from w ww .j  a  v  a2s  .c  om
        child.setFocusable(enable);
        if (child instanceof ViewGroup) {
            disableEnableControls(enable, (ViewGroup) child);
        }
    }
    vg.setEnabled(enable);
    vg.setFocusable(enable);
}

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  ww w  . j  a va 2s  . 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.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:org.lol.reddit.fragments.CommentListingFragment.java

@Override
public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) {

    final Context context = getSupportActivity();

    if (mPost == null) {

        mPost = post;// w w w .  j  a va2  s  .com

        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.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//ww  w . j a  v  a2  s  . c  o 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);
}