|
|
|
@ -49,6 +49,8 @@ import androidx.constraintlayout.widget.Group;
|
|
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
|
|
|
|
|
import static android.app.Activity.RESULT_OK;
|
|
|
|
|
|
|
|
|
|
public class FragmentAnswer extends FragmentBase {
|
|
|
|
@ -246,7 +248,7 @@ public class FragmentAnswer extends FragmentBase {
|
|
|
|
|
args.putString("name", etName.getText().toString().trim());
|
|
|
|
|
args.putBoolean("favorite", cbFavorite.isChecked());
|
|
|
|
|
args.putBoolean("hide", cbHide.isChecked());
|
|
|
|
|
args.putString("text", HtmlHelper.toHtml(etText.getText(), getContext()));
|
|
|
|
|
args.putString("html", HtmlHelper.toHtml(etText.getText(), getContext()));
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
@ -265,25 +267,27 @@ public class FragmentAnswer extends FragmentBase {
|
|
|
|
|
String name = args.getString("name");
|
|
|
|
|
boolean favorite = args.getBoolean("favorite");
|
|
|
|
|
boolean hide = args.getBoolean("hide");
|
|
|
|
|
String text = args.getString("text");
|
|
|
|
|
String html = args.getString("html");
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(name))
|
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_name));
|
|
|
|
|
|
|
|
|
|
Document document = HtmlHelper.fixEdit(JsoupEx.parse(html));
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
if (id < 0) {
|
|
|
|
|
EntityAnswer answer = new EntityAnswer();
|
|
|
|
|
answer.name = name;
|
|
|
|
|
answer.favorite = favorite;
|
|
|
|
|
answer.hide = hide;
|
|
|
|
|
answer.text = text;
|
|
|
|
|
answer.text = document.body().html();
|
|
|
|
|
answer.id = db.answer().insertAnswer(answer);
|
|
|
|
|
} else {
|
|
|
|
|
EntityAnswer answer = db.answer().getAnswer(id);
|
|
|
|
|
answer.name = name;
|
|
|
|
|
answer.favorite = favorite;
|
|
|
|
|
answer.hide = hide;
|
|
|
|
|
answer.text = text;
|
|
|
|
|
answer.text = document.body().html();
|
|
|
|
|
db.answer().updateAnswer(answer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|