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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations