Search in sources :

Example 1 with RxMDConfiguration

use of com.yydcdut.rxmarkdown.RxMDConfiguration in project silverblog_android by SilverBlogTeam.

the class post_preview method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_preview);
    Toolbar toolbar = findViewById(R.id.toolbar);
    Context context = getApplicationContext();
    setSupportActionBar(toolbar);
    Intent intent = getIntent();
    TextView title = findViewById(R.id.title);
    title.setText(intent.getStringExtra(Intent.EXTRA_SUBJECT));
    // RichText.fromMarkdown().into((TextView) findViewById(R.id.markdown_view));
    RxMDConfiguration rxMDConfiguration = new RxMDConfiguration.Builder(context).setDefaultImageSize(100, // default image width & height
    100).setBlockQuotesColor(// default color of block quotes
    Color.LTGRAY).setHeader1RelativeSize(// default relative size of header1
    1.6f).setHeader2RelativeSize(// default relative size of header2
    1.5f).setHeader3RelativeSize(// default relative size of header3
    1.4f).setHeader4RelativeSize(// default relative size of header4
    1.3f).setHeader5RelativeSize(// default relative size of header5
    1.2f).setHeader6RelativeSize(// default relative size of header6
    1.1f).setHorizontalRulesColor(// default color of horizontal rules's background
    Color.LTGRAY).setInlineCodeBgColor(// default color of inline code's background
    Color.LTGRAY).setCodeBgColor(// default color of code's background
    Color.LTGRAY).setTodoColor(// default color
    Color.DKGRAY).setTodoDoneColor(// default color of done
    Color.DKGRAY).setUnOrderListColor(// default color of unorder list
    Color.BLACK).setLinkColor(// default color of link text
    R.color.colorPrimaryDark).setLinkUnderline(// default value of whether displays link underline
    true).setRxMDImageLoader(// default image loader
    new DefaultLoader(context)).setDebug(// default value of debug
    false).build();
    RxMarkdown.with(intent.getStringExtra(Intent.EXTRA_TEXT), this).config(rxMDConfiguration).factory(TextFactory.create()).intoObservable().subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<CharSequence>() {

        @Override
        public void onCompleted() {
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onNext(CharSequence charSequence) {
            TextView markdown = findViewById(R.id.markdown_view);
            markdown.setMovementMethod(ScrollingMovementMethod.getInstance());
            markdown.setText(charSequence, TextView.BufferType.SPANNABLE);
        }
    });
}
Also used : Context(android.content.Context) Intent(android.content.Intent) TextView(android.widget.TextView) RxMDConfiguration(com.yydcdut.rxmarkdown.RxMDConfiguration) DefaultLoader(com.yydcdut.rxmarkdown.loader.DefaultLoader) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 TextView (android.widget.TextView)1 RxMDConfiguration (com.yydcdut.rxmarkdown.RxMDConfiguration)1 DefaultLoader (com.yydcdut.rxmarkdown.loader.DefaultLoader)1