Screen not properly redraw

Hi all,

I have a strange redraw behaviour in my DataField

In my onUpdate method I have several dc.drawText() to write values that are fetched from Activity.info object. 

I don't know why but the first time values change previous values still below new ones. 

Any idea on how solve this? 

Thanks!

  • You brought the irrelevant part of the documentation into this thread, as there was no mention of layer previously and the code that was given doesn't use transparent background color for clear, only for drawText.

    That's true, I misread the code. My mistake!

    Then I guess it must be the case that for this code, the "background class" is not being drawn all the time. Otherwise dc.clear() (with the data field background colour) should be working as expected.

  • hmmm:

    dc.setColor(Graphics.COLOR_TRANSPARENT, getBackgroundColor());
    dc.clear();

    I never do this. I always pass the same color in both parameters (I don't use layers either).

    But maybe there is a bug either in the simulator or in the documentation of clear()

  • hmmm:

    dc.setColor(Graphics.COLOR_TRANSPARENT, getBackgroundColor());
    dc.clear();

    I never do this. I always pass the same color in both parameters (I don't use layers either).

    But maybe there is a bug either in the simulator or in the documentation of clear()

    Since dc.clear() is supposed to use the background colour for erasing the screen (i.e. the 2nd arg to setColor()), you are correct that clearing with a transparent colour is irrelevant to this topic. OP's issue was *drawing* with a transparent colour, apparently (and not clearing on every update).

    Nonetheless, I want to see what clearing with a transparent colour actually does. If I have a chance, I'll do some tests and report back.

  • Unfortunately I couldn't properly test clearing with a background colour of COLOR_TRANSPARENT properly, with my real fr955.

    - For a complex data field, in both the sim and real fr955, the dc is cleared before every onUpdate(). (Even if I have no layout and don't call View.onUpdate())

    - For a device app, the sim does not clear the dc before onUpdate() (and clearing with COLOR_TRANSPARENT does nothing, as you predicted). But on a real fr955, the the dc is cleared on every onUpdate()

    What I would really need to do is find a device with CIQ >= 3.1.0 that does not clear the dc automatically before onUpdate, to test this stuff properly. But the behaviour of the sim suggests that clearing with a background color of COLOR_TRANSPARENT is not supposed to do anything, as you suggested.

    Maybe I'll just file a doc bug report anyway, just to ask for clarification.

  • Hi There, thanks for all your comments. 

    I am using layouts.xml where I define my drawables. 
    Then I use View.findDrawableById("myDrawableId") to get my drawable object and set the dynamic property I need to be set. 

    So far so good but, my mistake, I was explicitly calling MyDrawable.draw(dc) in the DataField.onUpdate() method without knowing that the .draw() method is automatically called by the framework (probably when you call the parent View.onUpdate(dc) method to redraw the layout).

    That was causing the redrawing issue. 

    Now I basically:

    1) instantiate a background drawables where I set foreground and background color (dc.setColor(fg,bg)) and do dc.clear()

    2) in each drawables .draw() methods I eventually do setColor() with the fg color I need and transparent background

    Not sure if this is the proper way of doing things but it solved my layout issue! 

    Thank you all for the help!

  • Not sure I understand why you need the layout.xml. From the above comment it sounds like you don't need it, because you only use intentionally to inflate your drawables, and that can be done in code as well. But maybe I didn't understand it, there could be legitimate reasons to mix layouts and direct draws. I don't use layouts, because I don't see the value in them, especially that in my datafields I usually support all devices above CIQ 1.2.0 and the old ones have very limited memory, and using layouts usually needs more memory than drawing direcly.

  • Not sure either why I am using layout.xml

    I'm new to Connect IQ development and I started with the basic DataField example (that uses layout.xml).

    So you approach is to define x,y positions, color, font, etc of your drawables directly in the onUpdate method?