package com.app.duck.ui;

import androidx.annotation.NonNull;

import com.app.duck.BaseActivity;
import com.app.duck.R;
import com.app.duck.databinding.ActivityIniEditBinding;
import com.app.duck.util.HxUtils;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class TemplateActivity extends BaseActivity<ActivityIniEditBinding> {


    @Override
    public void initView() {
        initToolbar();
        initEdit();
    }

    private void initEdit() {
        HxUtils.getStringFromRaw(TemplateActivity.this, R.raw.frpc_full)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String content) {
                        b.editText.setText(content, 1);

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });


    }

    private void initToolbar() {
        setSupportActionBar(b.toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        b.toolbar.setNavigationOnClickListener(v -> finish());
        b.toolbar.setTitle(R.string.titleTemplate);
    }
}
