use of me.ccrama.redditslide.Activities.Wiki in project Slide by ccrama.
the class WikiPage method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.justtext, container, false);
final SpoilerRobotoTextView body = (SpoilerRobotoTextView) v.findViewById(R.id.body);
final CommentOverflow commentOverflow = (CommentOverflow) v.findViewById(R.id.commentOverflow);
final GeneralSwipeRefreshLayout ref = (GeneralSwipeRefreshLayout) v.findViewById(R.id.ref);
ref.setColorSchemeColors(Palette.getColors(subreddit, getActivity()));
// If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
// So, we estimate the height of the header in dp
// Something isn't right with the Wiki layout though, so use the SINGLE_HEADER instead.
ref.setProgressViewOffset(false, Constants.SINGLE_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.SINGLE_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
ref.post(new Runnable() {
@Override
public void run() {
ref.setRefreshing(true);
}
});
new AsyncTask<Void, Void, Void>() {
String text;
@Override
protected Void doInBackground(Void... params) {
try {
text = ((Wiki) getActivity()).wiki.get(subreddit, title).getDataNode().get("content_html").asText();
} catch (Exception ignored) {
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
setViews(text, subreddit, body, commentOverflow);
ref.setRefreshing(false);
ref.setEnabled(false);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return v;
}
Aggregations