Java Code Examples for com.hippo.text.Html#fromHtml()

The following examples show how to use com.hippo.text.Html#fromHtml() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortForumsActivity.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ForumHolder holder, int position) {
    if (position > 0) {
        ACForumRaw raw = mLazyList.get(position - 1);
        holder.visibility.setActivated(raw.getVisibility());
        if (mAutoSorting) {
            holder.dragHandler.setVisibility(View.GONE);
            holder.pinning.setVisibility(View.VISIBLE);
            holder.pinning.setActivated(ForumAutoSortingUtils.isACForumPinned(raw));
        } else {
            holder.pinning.setVisibility(View.GONE);
            holder.dragHandler.setVisibility(View.VISIBLE);
        }

        CharSequence name = mForumNames.get(position);
        if (name == null) {
            if (raw.getDisplayname() == null) {
                name = "Forum";
            } else {
                name = Html.fromHtml(raw.getDisplayname());
            }
            mForumNames.put(position, name);
        }
        holder.forum.setText(name);
    }
}
 
Example 2
Source File: CommonOperations.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void handleResult(JSONObject jo) {
    if (null == jo || mActivity.isFinishing()) {
        return;
    }

    String versionName;
    int versionCode;
    String size;
    CharSequence info;
    String url;

    try {
        PackageManager pm = mActivity.getPackageManager();
        PackageInfo pi = pm.getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
        int currentVersionCode = pi.versionCode;
        versionCode = jo.getInt("version_code");
        if (currentVersionCode >= versionCode) {
            // Update to date
            if (mFeedback) {
                showUpToDateDialog();
            }
            return;
        }

        versionName = jo.getString("version_name");
        size = FileUtils.humanReadableByteCount(jo.getLong("size"), false);
        info = Html.fromHtml(jo.getString("info"));
        url = jo.getString("url");
    } catch (Throwable e) {
        ExceptionUtils.throwIfFatal(e);
        return;
    }

    if (mFeedback || versionCode != Settings.getSkipUpdateVersion()) {
        showUpdateDialog(versionName, versionCode, size, info, url);
    }
}
 
Example 3
Source File: MessagePreference.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MessagePreference, defStyleAttr, defStyleRes);
    String message = a.getString(R.styleable.MessagePreference_dialogMessage);
    if (a.getBoolean(R.styleable.MessagePreference_dialogMessageHtml, false)) {
        mDialogMessage = Html.fromHtml(message);
    } else {
        mDialogMessage = message;
    }
    mDialogMessageLinkify = a.getBoolean(R.styleable.MessagePreference_dialogMessageLinkify, false);
    a.recycle();
}
 
Example 4
Source File: DisplayForum.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getNMBDisplayname() {
    if (name == null) {
        if (displayname == null) {
            name = "Forum";
        } else {
            name = Html.fromHtml(displayname);
        }
    }
    return name;
}
 
Example 5
Source File: ACItemUtils.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
public static CharSequence generateContent(String content) {
    content = replaceBracketsH(content);
    CharSequence charSequence;
    charSequence = Html.fromHtml(content, null, AC_HTML_TAG_HANDLER);
    charSequence = handleReference(charSequence);
    charSequence = handleTextUrl(charSequence);
    charSequence = handleAcUrl(charSequence);

    return charSequence;
}
 
Example 6
Source File: CommonOperations.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void handleResult(JSONObject jo) {
    if (null == jo || mActivity.isFinishing()) {
        return;
    }

    String versionName;
    int versionCode;
    String size;
    CharSequence info;
    String url;

    try {
        PackageManager pm = mActivity.getPackageManager();
        PackageInfo pi = pm.getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
        int currentVersionCode = pi.versionCode;
        versionCode = jo.getInt("version_code");
        if (currentVersionCode >= versionCode) {
            // Update to date
            if (mFeedback) {
                showUpToDateDialog();
            }
            return;
        }

        versionName = jo.getString("version_name");
        size = FileUtils.humanReadableByteCount(jo.getLong("size"), false);
        info = Html.fromHtml(jo.getString("info"));
        url = jo.getString("url");
    } catch (Throwable e) {
        ExceptionUtils.throwIfFatal(e);
        return;
    }

    if (mFeedback || versionCode != Settings.getSkipUpdateVersion()) {
        showUpdateDialog(versionName, versionCode, size, info, url);
    }
}
 
Example 7
Source File: MessagePreference.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MessagePreference, defStyleAttr, defStyleRes);
    String message = a.getString(R.styleable.MessagePreference_dialogMessage);
    if (a.getBoolean(R.styleable.MessagePreference_dialogMessageHtml, false)) {
        mDialogMessage = Html.fromHtml(message);
    } else {
        mDialogMessage = message;
    }
    mDialogMessageLinkify = a.getBoolean(R.styleable.MessagePreference_dialogMessageLinkify, false);
    a.recycle();
}
 
Example 8
Source File: ListActivity.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(ListHolder holder, int position) {
    Post post = mPostHelper.getDataAt(position);
    holder.leftText.setText(post.getNMBDisplayUsername());
    ACForumRaw forum = DB.getACForumForForumid(post.getNMBFid());
    if (forum != null) {
        String displayName = forum.getDisplayname();
        CharSequence name = mForumNames.get(displayName);
        if (name == null) {
            if (displayName == null) {
                name = "Forum";
            } else {
                name = Html.fromHtml(displayName);
            }
            mForumNames.put(displayName, name);
        }
        holder.centerText.setText(name);
    } else {
        holder.centerText.setText("No." + post.getNMBId());
    }
    holder.rightText.setText(ReadableTime.getDisplayTime(post.getNMBTime()));
    ACItemUtils.setContentText(holder.content, post.getNMBDisplayContent());
    holder.bottomText.setText(post.getNMBReplyDisplayCount());

    View bottom = holder.bottom;
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) bottom.getLayoutParams();
    String thumbKey = post.getNMBThumbKey();
    String thumbUrl = post.getNMBThumbUrl();

    boolean tryShowImage;
    boolean loadFromNetwork;
    int ils = Settings.getImageLoadingStrategy();
    if (ils == Settings.IMAGE_LOADING_STRATEGY_ALL ||
            (ils == Settings.IMAGE_LOADING_STRATEGY_WIFI && NMBApplication.isConnectedWifi(ListActivity.this))) {
        tryShowImage = true;
        loadFromNetwork = true;
    } else {
        tryShowImage = Settings.getImageLoadingStrategy2();
        loadFromNetwork = false;
    }

    boolean showImage;
    if (!TextUtils.isEmpty(thumbKey) && !TextUtils.isEmpty(thumbUrl) && tryShowImage) {
        showImage = true;

        holder.thumb.setVisibility(View.VISIBLE);
        holder.thumb.unload();
        holder.thumb.load(thumbKey, thumbUrl, loadFromNetwork);
    } else {
        showImage = false;

        holder.thumb.setVisibility(View.GONE);
        holder.thumb.unload();
    }

    boolean showReplies;
    Reply[] replies = post.getNMBReplies();
    if (Settings.getDynamicComments()) {
        showReplies = holder.setReplies(replies);
    } else {
        showReplies = holder.setReplies(null);
    }

    if (showImage && !showReplies) {
        lp.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.thumb);
        lp.addRule(RelativeLayout.BELOW, 0);
        bottom.setLayoutParams(lp);
    } else if (showImage) {
        lp.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
        lp.addRule(RelativeLayout.BELOW, R.id.thumb);
        bottom.setLayoutParams(lp);
    } else {
        lp.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
        lp.addRule(RelativeLayout.BELOW, R.id.content);
        bottom.setLayoutParams(lp);
    }

    holder.content.setTextSize(Settings.getFontSize());
    holder.content.setLineSpacing(LayoutUtils.dp2pix(ListActivity.this, Settings.getLineSpacing()), 1.0f);
    if (Settings.getFixEmojiDisplay()) {
        holder.content.useCustomTypeface();
    } else {
        holder.content.useOriginalTypeface();
    }
}