From feba44e679657f6344a667b3f3c482bd92fbaca2 Mon Sep 17 00:00:00 2001 From: stefan-niedermann Date: Sun, 12 Jan 2020 15:01:16 +0100 Subject: [PATCH] Remove ReactiveX wrapper --- app/build.gradle | 2 -- .../android/fragment/NoteEditFragment.java | 32 ++++--------------- .../owncloud/notes/util/MarkDownUtil.java | 6 ++-- app/src/main/res/layout/activity_edit.xml | 2 +- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 09bad47e..a4e75867 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,8 +35,6 @@ android { dependencies { implementation "com.github.nextcloud:Android-SingleSignOn:0.5.0-rc1" - implementation 'io.reactivex:rxandroid:1.2.1' - implementation 'io.reactivex:rxjava:1.3.8' implementation 'com.yydcdut:markdown-processor:0.1.3' implementation 'com.yydcdut:rxmarkdown-wrapper:0.1.3' diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java index 1aa3a542..a6372bb9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java @@ -17,13 +17,12 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; import androidx.annotation.Nullable; +import com.yydcdut.markdown.MarkdownEditText; +import com.yydcdut.markdown.MarkdownProcessor; import com.yydcdut.markdown.syntax.edit.EditFactory; -import com.yydcdut.rxmarkdown.RxMDEditText; -import com.yydcdut.rxmarkdown.RxMarkdown; import java.util.Objects; @@ -34,7 +33,6 @@ import it.niedermann.owncloud.notes.model.CloudNote; import it.niedermann.owncloud.notes.util.ICallback; import it.niedermann.owncloud.notes.util.MarkDownUtil; import it.niedermann.owncloud.notes.util.StyleCallback; -import rx.Subscriber; public class NoteEditFragment extends BaseNoteFragment { @@ -43,7 +41,7 @@ public class NoteEditFragment extends BaseNoteFragment { private static final long DELAY = 2000; // Wait for this time after typing before saving private static final long DELAY_AFTER_SYNC = 5000; // Wait for this time after saving before checking for next save @BindView(R.id.editContent) - RxMDEditText editContent; + MarkdownEditText editContent; private Handler handler; private boolean saveActive, unsavedEdit; private final Runnable runAutoSave = new Runnable() { @@ -138,26 +136,10 @@ public class NoteEditFragment extends BaseNoteFragment { editContent.setText(note.getContent()); editContent.setEnabled(true); - RxMarkdown.live(editContent) - .config(MarkDownUtil.getMarkDownConfiguration(editContent.getContext()).build()) - .factory(EditFactory.create()) - .intoObservable() - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - // Nothing to do here - } - - @Override - public void onError(Throwable e) { - e.printStackTrace(); - } - - @Override - public void onNext(CharSequence charSequence) { - editContent.setText(charSequence, TextView.BufferType.SPANNABLE); - } - }); + MarkdownProcessor markdownProcessor = new MarkdownProcessor(getActivity()); + markdownProcessor.config(MarkDownUtil.getMarkDownConfiguration(editContent.getContext()).build()); + markdownProcessor.factory(EditFactory.create()); + markdownProcessor.live(editContent); editContent.setCustomSelectionActionModeCallback(new StyleCallback(this.editContent)); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java index 86ec6dbe..e641a6bb 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java @@ -4,8 +4,8 @@ import android.content.Context; import androidx.core.content.res.ResourcesCompat; -import com.yydcdut.rxmarkdown.RxMDConfiguration; -import com.yydcdut.rxmarkdown.RxMDConfiguration.Builder; +import com.yydcdut.markdown.MarkdownConfiguration; +import com.yydcdut.markdown.MarkdownConfiguration.Builder; import it.niedermann.owncloud.notes.R; @@ -26,7 +26,7 @@ public class MarkDownUtil { } public static Builder getMarkDownConfiguration(Context context, Boolean darkTheme) { - return new RxMDConfiguration.Builder(context) + return new MarkdownConfiguration.Builder(context) .setUnOrderListColor(ResourcesCompat.getColor(context.getResources(), darkTheme ? R.color.widget_fg_dark_theme : R.color.widget_fg_default, null)) .setHeader2RelativeSize(1.35f) diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 3a63390f..9078800f 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -7,7 +7,7 @@ android:orientation="vertical" tools:context="it.niedermann.owncloud.notes.android.activity.EditNoteActivity"> -