How to get position of datafield at datascreen?

Hi,

I would like to do datafield with different display options. Because I want to display different thing and I don't to have many datafields app, I would like to have one datafield app that can be placed many times on datafield and I can select in connect IQ what each instance (or location) shows.

I almost have it, but I have difficulty to get information in onUpdate function about which datafield position is currently updated. Right now I use method that in  onCompute method I reset counter and then each onUpdate call I increase counter so I know which field is being drawn currently. This works well in simulator, but not in real device, because onUpdate is called sometimes more often than onUpdate (due to radar, touch, screen change etc).

Is there any way, how to determine which datafield is currently updated by onUpdate function? Or any index of updated field etc? I don't want to do many copies of my datafield app to be able to  configure each one in connect IQ.

Thanks,

Tomáš

  • You should be able to check the obscurity flags to make a guess, but that's not exact

    If the same DF is displayed twice on the same screen, you'll probably see onLayout called for each before onUpdate.  But if you consider a screen like this

        df1
    
     df2  df3
    
     df4  df5
    
        df6

    you can't tell if you are in df2 or df4 (left obscurity on a round watch)

    and df3 or df5 (right obscurity on a round watch)

  • Hi Jim,

    thanks for suggestion, unfortunately this is not usable for me. I also thought about it, but I've found, obscurity doesn't work on rectangular displays like Edge has that is my target device.

    Tomáš

  • You really don't have an option on a rectangular device (edge) where you can have a number of DFs that are all the same size.  You can't even guess at which one your app is running in.

    As others have done is to just having multiple apps that are the same except for the manifest id and have the user install, say two different copies.

  • This works well in simulator, but not in real device, because onUpdate is called sometimes more often than onUpdate (due to radar, touch, screen change etc).

    This is an example of a "hack". You should avoid these sorts of approaches because either they won't work in real-life (as you saw) or the arbitrary behavior you rely on changes (so it no longer works).

  • That's exactly reason, why I'm asking for better solution. I tried some myself (like onUpdate + onCompute or delay between onUpdate calling (longer delay should be before 1st datafield), but non of ideas worked reliably. Looks like there is no better way than use multiple instances of the same with different ids that's pity.