iink SDK on Device

Answered

EditorView.invalidate is called by native method?

Below is the call stack I printed

at com.myscript.iink.uireferenceimplementation.LayerView.update(LayerView.java:212)

at com.myscript.iink.uireferenceimplementation.EditorView.invalidate(EditorView.java:264)

at com.myscript.iink.NativeFunctions.pointerEvents(Native Method)

at com.myscript.iink.Editor.pointerEvents(Editor.java:490)

at com.myscript.iink.uireferenceimplementation.InputController.handleOnTouchForPointer(InputController.java:124)

at com.myscript.iink.uireferenceimplementation.InputController.onTouch(InputController.java:175)

at android.view.View.dispatchTouchEvent(View.java:12509)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3024)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2705)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)

at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)

at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:443)

at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1830)

at android.app.Activity.dispatchTouchEvent(Activity.java:3466)

at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)

at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:401)

at android.view.View.dispatchPointerEvent(View.java:12752)

at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5272)

at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5075)

at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4592)

at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4645)

at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4611)

at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4751)

at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4619)

at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4808)

at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4592)

at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4645)

at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4611)

at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4619)

at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4592)

at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7286)

at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7255)

at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7216)

at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7416)

at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:239)

at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)

at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:210)

at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:7387)

at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:7439)

at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103)

at android.view.Choreographer.doCallbacks(Choreographer.java:909)

at android.view.Choreographer.doFrame(Choreographer.java:817)

at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:1018)

at android.os.Handler.dispatchMessage(Handler.java:110)

at android.os.Looper.loop(Looper.java:223)

at android.app.ActivityThread.main(ActivityThread.java:6822)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:605)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:906)


Best Answer

Dear User,


as you can see in the above log, the invalidate function is called in the EditorView.java file, in particular in the "onSizeChanged" function (you can refer to file):

  @Override
  protected void onSizeChanged(int newWidth, int newHeight, int oldWidth, int oldHeight)
  {
    viewWidth = newWidth;
    viewHeight = newHeight;

    if (editor != null)
    {
      editor.setViewSize(newWidth, newHeight);
      invalidate(renderer, EnumSet.allOf(IRenderTarget2.LayerType.class));
    }

    super.onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
  }



Best regards,


Olivier


Dear User,


currently, the invalidate function is an Android function, which is called to force a re-draw: https://developer.android.com/reference/android/view/View#invalidate()


In the ImageDrawer.java, we then override the default Android function to force a re-draw.


Best regards,


Olivier

Thank you.

I understand the function of the invalidate method. 

What I want to know is, is it called by you in the demo? Which method is it called by?

image


Answer

Dear User,


as you can see in the above log, the invalidate function is called in the EditorView.java file, in particular in the "onSizeChanged" function (you can refer to file):

  @Override
  protected void onSizeChanged(int newWidth, int newHeight, int oldWidth, int oldHeight)
  {
    viewWidth = newWidth;
    viewHeight = newHeight;

    if (editor != null)
    {
      editor.setViewSize(newWidth, newHeight);
      invalidate(renderer, EnumSet.allOf(IRenderTarget2.LayerType.class));
    }

    super.onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
  }



Best regards,


Olivier