Hi!
I am blocked on the meaning of the following line and I would like if you could help me:
function onSettingsChanged() is a normal function as follows:
Hi!
I am blocked on the meaning of the following line and I would like if you could help me:
function onSettingsChanged() is a normal function as follows:
Okay, I'll post some of the relevant code and explain what it does:
[https://github.com/warmsound/crystal-face/blob/master/source/CrystalView.mc#L134]
mDrawables[:Indicators] = View.findDrawableById("Indicators");
mDrawables[:Indicators] is assigned to the drawable with ID "Indicators". If we look at any one of the layout.xml files, we find:
https://github.com/warmsound/crystal-face/blob/master/resources/layouts/layout.xml#L41
<drawable id="Indicators" class="Indicators">
So the drawable with ID "Indicators" is an instance of the "Indicators" class. Looking at the Indicators class, we see that it has an onSettingsChanged() method. (Same as the other drawables.)
[https://github.com/warmsound/crystal-face/blob/master/source/Indicators.mc#L38]
function onSettingsChanged() {
mIndicator1Type = App.getApp().getProperty("Indicator1Type");
mIndicator2Type = App.getApp().getProperty("Indicator2Type");
mIndicator3Type = App.getApp().getProperty("Indicator3Type");
}
What's happening here is that each value in the mDrawables dictionary is a reference to a drawable. And each drawable is an instance of a (custom) class which has an onSettingsChanged() method.
To answer your question fully, a dictionary value can be any kind of Monkey C value, and in this case, the values stored in mDrawables are instances of custom classes which each extend Drawable and implement an onSettingsChanged() method.
Thank you a lot for your answer. Really clear. It is a nice way to load different classes in fonction of the resource used.
Thanks!