Interactive Ink

java.lang.IllegalArgumentException: invalid `pointerId`

Step: 

1st :I export the jiix infomation, and convert it to a java class by Gson

2nd :I select some items, change them to EventPoints like below codes, and post them to editor. 

    private void sendList(List<CharsBean> charsBeanList){
        for (CharsBean charsBean : charsBeanList) {
            for (ItemsBean itemsBean : charsBean.getItems()) {
                PointerEvent[] events = itemsToPointEvents(itemsBean, PointerType.PEN);
                editor.pointerEvents(events, false);
            }
        }
    } 

private PointerEvent[] itemsToPointEvents(ItemsBean itemsBean, PointerType type) {
        int count = itemsBean.getX().size();
        PointerEvent[] pointerEvents = new PointerEvent[count];
        for (int i = 0; i < count; i++) {
            PointerEvent pointerEvent = new PointerEvent();
            pointerEvent.pointerId = 0;
            pointerEvent.pointerType = type;
            pointerEvent.x = itemsBean.getX().get(i);
            pointerEvent.y = itemsBean.getY().get(i);
            pointerEvent.t = System.currentTimeMillis();
            pointerEvent.f = itemsBean.getF().get(i);
            if (i == 0) {
                pointerEvent.eventType = PointerEventType.DOWN;
            } else {
                pointerEvent.eventType = PointerEventType.MOVE;
            }
            pointerEvents[i] = pointerEvent;
        }
        pointerEvents[pointerEvents.length - 1].eventType = PointerEventType.UP;
        return pointerEvents;
    }

 Result:

Sometimes, i catched the exception "java.lang.IllegalArgumentException: invalid `pointerId`"

I don,t konw how to set the pointerId, can you help me?


Dear Huang Wentai,


thank you for contacting us and your question.


Currently, it seems there is a small mistake in your algorithm when setting the PointerEventType.UP pointer type.


Could you please try setting it as follows:


if (i == 0) {

    pointerEvent.eventType = PointerEventType.DOWN;
else if (i == length - 1) {

    pointerEvent.eventType = PointerEventType.UP;
} else {

    pointerEvent.eventType = PointerEventType.MOVE;
}
pointerEvents[i] = pointerEvent;
}

return pointerEvents;


Let us know if this helps.


Best regards,


Olivier

Dear Olivier:

thanks for your response.

In my codes,I had set the  PointerEventType.UP point outside the  for-loop,can you see it again for me?

int count = itemsBean.getX().size(); PointerEvent[] pointerEvents = new PointerEvent[count]; for (int i = 0; i < count; i++) { PointerEvent pointerEvent = new PointerEvent(); pointerEvent.pointerId = 0; pointerEvent.pointerType = type; pointerEvent.x = itemsBean.getX().get(i); pointerEvent.y = itemsBean.getY().get(i); pointerEvent.t = System.currentTimeMillis(); pointerEvent.f = itemsBean.getF().get(i); if (i == 0) { pointerEvent.eventType = PointerEventType.DOWN; } else { pointerEvent.eventType = PointerEventType.MOVE; } pointerEvents[i] = pointerEvent; } pointerEvents[pointerEvents.length - 1].eventType = PointerEventType.UP;

Dear Huang,


can you please try to set the PointerEventType just as I said?


Let us know if this works!


Best regards,


Olivier

Login or Signup to post a comment