use of me.ccrama.redditslide.Adapters.CommentAdapter in project Slide by ccrama.
the class CommentPage method doAdapter.
public void doAdapter(boolean load) {
commentSorting = SettingValues.getCommentSorting(subreddit);
if (load)
doRefresh(true);
if (load)
loaded = true;
if (!single && getActivity() instanceof CommentsScreen && ((CommentsScreen) getActivity()).subredditPosts != null && Authentication.didOnline && ((CommentsScreen) getActivity()).currentPosts != null && ((CommentsScreen) getActivity()).currentPosts.size() > page) {
try {
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout);
} catch (IndexOutOfBoundsException e) {
return;
}
Submission s = ((CommentsScreen) getActivity()).currentPosts.get(page);
if (s != null && s.getDataNode().has("suggested_sort") && !s.getDataNode().get("suggested_sort").asText().equalsIgnoreCase("null")) {
String sorting = s.getDataNode().get("suggested_sort").asText().toUpperCase();
sorting = sorting.replace("İ", "I");
commentSorting = CommentSort.valueOf(sorting);
} else if (s != null) {
commentSorting = SettingValues.getCommentSorting(s.getSubredditName());
}
if (load)
comments.setSorting(commentSorting);
if (adapter == null) {
adapter = new CommentAdapter(this, comments, rv, s, getFragmentManager());
rv.setAdapter(adapter);
}
} else if (getActivity() instanceof MainActivity) {
if (Authentication.didOnline) {
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout);
Submission s = ((MainActivity) getActivity()).openingComments;
if (s != null && s.getDataNode().has("suggested_sort") && !s.getDataNode().get("suggested_sort").asText().equalsIgnoreCase("null")) {
String sorting = s.getDataNode().get("suggested_sort").asText().toUpperCase();
sorting = sorting.replace("İ", "I");
commentSorting = CommentSort.valueOf(sorting);
} else if (s != null) {
commentSorting = SettingValues.getCommentSorting(s.getSubredditName());
}
if (load)
comments.setSorting(commentSorting);
if (adapter == null) {
adapter = new CommentAdapter(this, comments, rv, s, getFragmentManager());
rv.setAdapter(adapter);
}
} else {
Submission s = ((MainActivity) getActivity()).openingComments;
doRefresh(false);
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout, s);
if (adapter == null) {
adapter = new CommentAdapter(this, comments, rv, s, getFragmentManager());
rv.setAdapter(adapter);
}
}
} else {
Submission s = null;
try {
s = OfflineSubreddit.getSubmissionFromStorage(fullname.contains("_") ? fullname : "t3_" + fullname, getContext(), !NetworkUtil.isConnected(getActivity()), new ObjectMapper().reader());
} catch (IOException e) {
e.printStackTrace();
}
if (s != null && s.getComments() != null) {
doRefresh(false);
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout, s);
if (adapter == null) {
adapter = new CommentAdapter(this, comments, rv, s, getFragmentManager());
rv.setAdapter(adapter);
}
} else if (context.isEmpty()) {
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout);
comments.setSorting(commentSorting);
if (adapter == null) {
if (s != null) {
adapter = new CommentAdapter(this, comments, rv, s, getFragmentManager());
}
rv.setAdapter(adapter);
}
} else {
if (context.equals(Reddit.EMPTY_STRING)) {
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout);
if (load)
comments.setSorting(commentSorting);
} else {
comments = new SubmissionComments(fullname, this, mSwipeRefreshLayout, context, contextNumber);
if (load)
comments.setSorting(commentSorting);
}
}
}
}
use of me.ccrama.redditslide.Adapters.CommentAdapter in project Slide by ccrama.
the class CommentPage method doData.
public void doData(Boolean b) {
if (adapter == null || single) {
adapter = new CommentAdapter(this, comments, rv, comments.submission, getFragmentManager());
rv.setAdapter(adapter);
adapter.currentSelectedItem = context;
if (context.isEmpty()) {
if (SettingValues.collapseCommentsDefault) {
adapter.collapseAll();
}
}
adapter.reset(getContext(), comments, rv, comments.submission, b);
} else if (!b) {
try {
adapter.reset(getContext(), comments, rv, (getActivity() instanceof MainActivity) ? ((MainActivity) getActivity()).openingComments : comments.submission, b);
if (SettingValues.collapseCommentsDefault) {
adapter.collapseAll();
}
} catch (Exception ignored) {
}
} else {
adapter.reset(getContext(), comments, rv, comments.submission, b);
if (SettingValues.collapseCommentsDefault) {
adapter.collapseAll();
}
adapter.notifyItemChanged(1);
}
}
Aggregations