Search in sources :

Example 1 with SidebarLayout

use of me.ccrama.redditslide.Views.SidebarLayout in project Slide by ccrama.

the class MainActivity method setViews.

private void setViews(String rawHTML, String subredditName, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
    if (rawHTML.isEmpty()) {
        return;
    }
    List<String> blocks = SubmissionParser.getBlocks(rawHTML);
    int startIndex = 0;
    // the <div class="md"> case is when the body contains a table or code block first
    if (!blocks.get(0).equals("<div class=\"md\">")) {
        firstTextView.setVisibility(View.VISIBLE);
        firstTextView.setTextHtml(blocks.get(0), subredditName);
        firstTextView.setLinkTextColor(new ColorPreferences(this).getColor(subredditName));
        startIndex = 1;
    } else {
        firstTextView.setText("");
        firstTextView.setVisibility(View.GONE);
    }
    if (blocks.size() > 1) {
        if (startIndex == 0) {
            commentOverflow.setViews(blocks, subredditName);
        } else {
            commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subredditName);
        }
        SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
        for (int i = 0; i < commentOverflow.getChildCount(); i++) {
            View maybeScrollable = commentOverflow.getChildAt(i);
            if (maybeScrollable instanceof HorizontalScrollView) {
                sidebar.addScrollable(maybeScrollable);
            }
        }
    } else {
        commentOverflow.removeAllViews();
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) SidebarLayout(me.ccrama.redditslide.Views.SidebarLayout) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ListView(android.widget.ListView) HorizontalScrollView(android.widget.HorizontalScrollView) Point(android.graphics.Point)

Example 2 with SidebarLayout

use of me.ccrama.redditslide.Views.SidebarLayout in project Slide by ccrama.

the class SubredditView method setViews.

private void setViews(String rawHTML, String subreddit, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
    if (rawHTML.isEmpty()) {
        return;
    }
    List<String> blocks = SubmissionParser.getBlocks(rawHTML);
    int startIndex = 0;
    // the <div class="md"> case is when the body contains a table or code block first
    if (!blocks.get(0).equals("<div class=\"md\">")) {
        firstTextView.setVisibility(View.VISIBLE);
        firstTextView.setTextHtml(blocks.get(0), subreddit);
        startIndex = 1;
    } else {
        firstTextView.setText("");
        firstTextView.setVisibility(View.GONE);
    }
    if (blocks.size() > 1) {
        if (startIndex == 0) {
            commentOverflow.setViews(blocks, subreddit);
        } else {
            commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subreddit);
        }
        SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
        for (int i = 0; i < commentOverflow.getChildCount(); i++) {
            View maybeScrollable = commentOverflow.getChildAt(i);
            if (maybeScrollable instanceof HorizontalScrollView) {
                sidebar.addScrollable(maybeScrollable);
            }
        }
    } else {
        commentOverflow.removeAllViews();
    }
}
Also used : SidebarLayout(me.ccrama.redditslide.Views.SidebarLayout) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) HorizontalScrollView(android.widget.HorizontalScrollView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) View(android.view.View) TextView(android.widget.TextView) HorizontalScrollView(android.widget.HorizontalScrollView)

Example 3 with SidebarLayout

use of me.ccrama.redditslide.Views.SidebarLayout in project Slide by ccrama.

the class LiveThread method setViews.

private void setViews(String rawHTML, String subreddit, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
    if (rawHTML.isEmpty()) {
        return;
    }
    List<String> blocks = SubmissionParser.getBlocks(rawHTML);
    int startIndex = 0;
    // the <div class="md"> case is when the body contains a table or code block first
    if (!blocks.get(0).equals("<div class=\"md\">")) {
        firstTextView.setVisibility(View.VISIBLE);
        firstTextView.setTextHtml(blocks.get(0), subreddit);
        startIndex = 1;
    } else {
        firstTextView.setText("");
        firstTextView.setVisibility(View.GONE);
    }
    if (blocks.size() > 1) {
        if (startIndex == 0) {
            commentOverflow.setViews(blocks, subreddit);
        } else {
            commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subreddit);
        }
        SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
        for (int i = 0; i < commentOverflow.getChildCount(); i++) {
            View maybeScrollable = commentOverflow.getChildAt(i);
            if (maybeScrollable instanceof HorizontalScrollView) {
                sidebar.addScrollable(maybeScrollable);
            }
        }
    } else {
        commentOverflow.removeAllViews();
    }
}
Also used : SidebarLayout(me.ccrama.redditslide.Views.SidebarLayout) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) HorizontalScrollView(android.widget.HorizontalScrollView)

Example 4 with SidebarLayout

use of me.ccrama.redditslide.Views.SidebarLayout in project Slide by ccrama.

the class Announcement method setViews.

private void setViews(String rawHTML, String subredditName, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
    if (rawHTML.isEmpty()) {
        return;
    }
    List<String> blocks = SubmissionParser.getBlocks(rawHTML);
    int startIndex = 0;
    // the <div class="md"> case is when the body contains a table or code block first
    if (!blocks.get(0).equals("<div class=\"md\">")) {
        firstTextView.setVisibility(View.VISIBLE);
        firstTextView.setTextHtml(blocks.get(0), subredditName);
        firstTextView.setLinkTextColor(new ColorPreferences(this).getColor(subredditName));
        startIndex = 1;
    } else {
        firstTextView.setText("");
        firstTextView.setVisibility(View.GONE);
    }
    if (blocks.size() > 1) {
        if (startIndex == 0) {
            commentOverflow.setViews(blocks, subredditName);
        } else {
            commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subredditName);
        }
        SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
        for (int i = 0; i < commentOverflow.getChildCount(); i++) {
            View maybeScrollable = commentOverflow.getChildAt(i);
            if (maybeScrollable instanceof HorizontalScrollView) {
                sidebar.addScrollable(maybeScrollable);
            }
        }
    } else {
        commentOverflow.removeAllViews();
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) SidebarLayout(me.ccrama.redditslide.Views.SidebarLayout) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) HorizontalScrollView(android.widget.HorizontalScrollView) TitleTextView(me.ccrama.redditslide.Views.TitleTextView) View(android.view.View) HorizontalScrollView(android.widget.HorizontalScrollView)

Aggregations

View (android.view.View)4 HorizontalScrollView (android.widget.HorizontalScrollView)4 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)4 SidebarLayout (me.ccrama.redditslide.Views.SidebarLayout)4 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 ColorPreferences (me.ccrama.redditslide.ColorPreferences)2 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)2 Point (android.graphics.Point)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 WebView (android.webkit.WebView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ListView (android.widget.ListView)1 TitleTextView (me.ccrama.redditslide.Views.TitleTextView)1