Search in sources :

Example 1 with Wiki

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;
}
Also used : SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) Wiki(me.ccrama.redditslide.Activities.Wiki) CommentOverflow(me.ccrama.redditslide.Views.CommentOverflow) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) GeneralSwipeRefreshLayout(me.ccrama.redditslide.Views.GeneralSwipeRefreshLayout)

Aggregations

View (android.view.View)1 Wiki (me.ccrama.redditslide.Activities.Wiki)1 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)1 CommentOverflow (me.ccrama.redditslide.Views.CommentOverflow)1 GeneralSwipeRefreshLayout (me.ccrama.redditslide.Views.GeneralSwipeRefreshLayout)1