本文整理匯總了Java中com.zzhoujay.markdown.MarkDown類的典型用法代碼示例。如果您正苦於以下問題:Java MarkDown類的具體用法?Java MarkDown怎麽用?Java MarkDown使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MarkDown類屬於com.zzhoujay.markdown包,在下文中一共展示了MarkDown類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setText
import com.zzhoujay.markdown.MarkDown; //導入依賴的package包/類
private void setText(int resId) {
final InputStream stream = getResources().openRawResource(resId);
mTextView.post(new Runnable() {
@Override
public void run() {
long time = System.nanoTime();
Spanned spanned = MarkDown.fromMarkdown(stream, new Html.ImageGetter() {
public static final String TAG = "Markdown";
@Override
public Drawable getDrawable(String source) {
Log.d(TAG, "getDrawable() called with: source = [" + source + "]");
Drawable drawable;
try {
drawable = drawableFromUrl(source);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
} catch (IOException e) {
Log.w(TAG, "can't get image", e);
drawable = new ColorDrawable(Color.LTGRAY);
drawable.setBounds(0, 0, mTextView.getWidth() - mTextView.getPaddingLeft() - mTextView.getPaddingRight(), 400);
}
return drawable;
}
}, mTextView);
long useTime = System.nanoTime() - time;
Toast.makeText(getApplicationContext(), "use time: " + useTime + "ns", Toast.LENGTH_LONG).show();
mTextView.setText(spanned);
}
});
}
示例2: parse
import com.zzhoujay.markdown.MarkDown; //導入依賴的package包/類
@Override
public Spanned parse(String source) {
return MarkDown.fromMarkdown(source, null, textView);
}