MarkDEditor
MarkDEditor copied to clipboard
Cannot add an image
When I click to select an image, I get the following error.
--------- beginning of crash
2019-03-21 15:00:49.839 4492-4492/com.ovicko.testeditor E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ovicko.testeditor, PID: 4492
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=110, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:36475 flg=0x1 }} to activity {com.ovicko.testeditor/com.ovicko.testeditor.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'xute.markdeditor.models.BaseComponentModel xute.markdeditor.models.ComponentTag.getComponent()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:5041)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5084)
at android.app.ActivityThread.-wrap20(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'xute.markdeditor.models.BaseComponentModel xute.markdeditor.models.ComponentTag.getComponent()' on a null object reference
at xute.markdeditor.components.ImageComponentItem.setCaption(ImageComponentItem.java:255)
at xute.markdeditor.components.ImageComponentItem.setImageInformation(ImageComponentItem.java:113)
at xute.markdeditor.components.ImageComponent.getNewImageComponentItem(ImageComponent.java:15)
at xute.markdeditor.MarkDEditor.insertImage(MarkDEditor.java:385)
at com.ovicko.testeditor.MainActivity.addImage(MainActivity.java:73)
at com.ovicko.testeditor.MainActivity.onActivityResult(MainActivity.java:66)
at android.app.Activity.dispatchActivityResult(Activity.java:7701)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5037)
The issue seems to start from this function
public void addImage(String filePath) {
markDEditor.insertImage(filePath);
}
Same issue Here
java.lang.ClassCastException: xute.markdeditor.components.ImageComponentItem cannot be cast to xute.markdeditor.components.TextComponentItem at xute.markdeditor.MarkDCore.invalidateComponentMode(MarkDCore.java:102) at xute.markdeditor.MarkDCore.refreshViewOrder(MarkDCore.java:33) at xute.markdeditor.MarkDEditor.addTextComponent(MarkDEditor.java:128) at xute.markdeditor.MarkDEditor.onExitFromCaptionAndInsertNewTextComponent(MarkDEditor.java:513) at xute.markdeditor.components.ImageComponentItem.checkReturnPressToInsertNewTextComponent(ImageComponentItem.java:141) at xute.markdeditor.components.ImageComponentItem.access$1000(ImageComponentItem.java:23) at xute.markdeditor.components.ImageComponentItem$4.onTextChanged(ImageComponentItem.java:99) at android.widget.TextView.sendOnTextChanged(TextView.java:9754) at android.widget.TextView.handleTextChanged(TextView.java:9851) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:12509) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1263) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:575) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:506) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:36) at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:843) at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:197) at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:341) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:85) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6692) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'xute.markdeditor.models.BaseComponentModel xute.markdeditor.models.ComponentTag.getComponent()' on a null object reference at xute.markdeditor.components.ImageComponentItem.setCaption(ImageComponentItem.java:255) at xute.markdeditor.components.ImageComponentItem.setImageInformation(ImageComponentItem.java:113) at xute.markdeditor.components.ImageComponent.getNewImageComponentItem(ImageComponent.java:15) at xute.markdeditor.MarkDEditor.insertImage(MarkDEditor.java:385) at com.blogging.Quarterpillers.BlogCreation.BlogEditorActivity.addImage(BlogEditorActivity.kt:145) at com.blogging.Quarterpillers.BlogCreation.BlogEditorActivity.onActivityResult(BlogEditorActivity.kt:139) at android.app.Activity.dispatchActivityResult(Activity.java:7458) at android.app.ActivityThread.deliverResults(ActivityThread.java:4354)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'xute.markdeditor.models.BaseComponentModel xute.markdeditor.models.ComponentTag.getComponent()' on a null object reference at xute.markdeditor.components.ImageComponentItem.setCaption(ImageComponentItem.java:255) at xute.markdeditor.components.ImageComponentItem.setImageInformation(ImageComponentItem.java:113) at xute.markdeditor.components.ImageComponent.getNewImageComponentItem(ImageComponent.java:15) at xute.markdeditor.MarkDEditor.insertImage(MarkDEditor.java:385) at com.example.editorgit.MainActivity.addImage(MainActivity.java:132) at com.example.editorgit.MainActivity.onActivityResult(MainActivity.java:126) at android.app.Activity.dispatchActivityResult(Activity.java:7701) at android.app.ActivityThread.deliverResults(ActivityThread.java:5037) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5084) at android.app.ActivityThread.-wrap20(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7529) at java.lang.reflect.Method.invoke(Native Method)
I've noticed the insertImage()
function has 3 params
public void insertImage(int insertIndex, String filePath, boolean uploaded, String caption){
}
Maybe an issue with params?
I think it has to do with the serverUrl parameter when you instantiate the markDeditor, it should be a link
@ovicko did you solve this issue?