yuruiyin / RichEditor

基于原生EditText+span实现的Android富文本编辑器
MIT License
317 stars 37 forks source link

如何删除指定元素, 比如我想在图片上面添加一个删除按钮, 如何可以点击删除 #15

Open manitozhang opened 7 months ago

manitozhang commented 7 months ago

调用了mRichUtils.removeBlockImageSpan(blockImageSpan);,报错 java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1331) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:685) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:677) at android.text.Selection.setSelection(Selection.java:95) at android.text.Selection.setSelection(Selection.java:79) at android.text.Selection.setSelection(Selection.java:154) at android.widget.Editor.onTouchUpEvent(Editor.java:2723) at android.widget.TextView.onTouchEvent(TextView.java:12847) at android.view.View.dispatchTouchEvent(View.java:15886) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3214) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2851) at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:577) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1908) at android.app.Activity.dispatchTouchEvent(Activity.java:4579) at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69) at com.android.tools.profiler.support.event.WindowProfilerCallback.dispatchTouchEvent(WindowProfilerCallback.java:69) at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:535) at android.view.View.dispatchPointerEvent(View.java:16169) at com.xiaomi.mirror.MiuiMirrorImpl.isHandled(MiuiMirrorImpl.java:152) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:8036) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7797) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7165) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7222) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7188) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7353) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7196) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7410) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7169) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7222) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7188) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7196) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7169) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10420) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10371) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10326) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:10586) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:306)