@Override
 public void onBackPressed() {
   if (cnodeWebView.canGoBack()) {
     cnodeWebView.goBack();
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 2
0
    public void update(int position) {
      this.position = position;
      reply = topic.getReplies().get(position);

      Picasso.with(activity)
          .load(reply.getAuthor().getAvatarUrl())
          .placeholder(R.drawable.image_placeholder)
          .into(imgAvatar);
      tvLoginName.setText(reply.getAuthor().getLoginName());
      tvIndex.setText(position + 1 + "楼");
      tvCreateTime.setText(FormatUtils.getRecentlyTimeText(reply.getCreateAt()));
      btnUps.setText(String.valueOf(reply.getUps().size()));
      btnUps.setCompoundDrawablesWithIntrinsicBounds(
          reply.getUps().contains(LoginShared.getId(activity))
              ? R.drawable.main_nav_ic_good_theme_24dp
              : R.drawable.main_nav_ic_good_grey_24dp,
          0,
          0,
          0);
      iconDeepLine.setVisibility(
          position == topic.getReplies().size() - 1 ? View.GONE : View.VISIBLE);
      iconShadowGap.setVisibility(
          position == topic.getReplies().size() - 1 ? View.VISIBLE : View.GONE);

      // TODO 这里直接使用WebView,有性能问题
      webReplyContent.loadRenderedContent(reply.getRenderedContent());
    }
Ejemplo n.º 3
0
    public void update(int position) {
      if (!isHeaderShow) {
        tvTitle.setText(topic.getTitle());
        tvTab.setText(topic.isTop() ? R.string.tab_top : topic.getTab().getNameId());
        tvTab.setBackgroundResource(
            topic.isTop()
                ? R.drawable.topic_tab_top_background
                : R.drawable.topic_tab_normal_background);
        tvTab.setTextColor(
            activity
                .getResources()
                .getColor(topic.isTop() ? android.R.color.white : R.color.text_color_secondary));
        tvVisitCount.setText(topic.getVisitCount() + "次浏览");
        Picasso.with(activity)
            .load(topic.getAuthor().getAvatarUrl())
            .placeholder(R.drawable.image_placeholder)
            .into(imgAvatar);
        tvLoginName.setText(topic.getAuthor().getLoginName());
        tvCreateTime.setText(
            activity.getString(R.string.post_at_$)
                + FormatUtils.getRecentlyTimeText(topic.getCreateAt()));
        iconGood.setVisibility(topic.isGood() ? View.VISIBLE : View.GONE);

        // TODO 这里直接使用WebView,有性能问题
        webReplyContent.loadRenderedContent(topic.getRenderedContent());

        isHeaderShow = true;
      }

      layoutNoReply.setVisibility(topic.getReplies().size() > 0 ? View.GONE : View.VISIBLE);
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_markdown_preview);
    ButterKnife.bind(this);

    toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));

    cnodeWebView.loadRenderedContent(
        FormatUtils.renderMarkdown(getIntent().getStringExtra(EXTRA_MARKDOWN)));
  }