Esempio n. 1
0
        public void loadAlarms()
        {
            xDataInput di = xFileManager.readFile(Context.FILE_ALARM, false);

            if (di == null)
            {
                return;
            }

            int ver = 0;

            if (di != null)
            {
                ver = di.readInt();
            }
            if (ver >= Context.FILE_VERSION_33)
            {
                int cnt = di.readInt();
                for (int i = 0; i < cnt; i++)
                {
                    stAlarm a = new stAlarm();
                    a.code       = di.readUTF();
                    a.date       = di.readInt();
                    a.lowerPrice = di.readInt();
                    a.upperPrice = di.readInt();

                    a.comment = di.readUTF();

                    mAlarms.addElement(a);
                }
            }
        }
Esempio n. 2
0
        public stAlarm getAlarm(String code)
        {
            int cnt = mAlarms.size();

            for (int i = 0; i < cnt; i++)
            {
                stAlarm a = (stAlarm)mAlarms.elementAt(i);
                if (a.code.CompareTo(code) == 0)
                {
                    return(a);
                }
            }

            return(null);
        }
Esempio n. 3
0
        public bool hasTriggerredAlarm()
        {
            int cnt = getAlarmCount();

            for (int i = 0; i < cnt; i++)
            {
                stAlarm a = getAlarmAt(i);
                if (a.hasTriggerredAlarm())
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public bool isAlarmInstalled(String code)
        {
            int cnt = getAlarmCount();

            for (int i = 0; i < cnt; i++)
            {
                stAlarm a = getAlarmAt(i);
                if (a.code.CompareTo(code) == 0)
                {
                    if (a.lowerPrice > 0 || a.upperPrice > 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 5
0
        public void saveAlarms()
        {
            xDataOutput o = new xDataOutput(2048);

            o.writeInt(Context.FILE_VERSION_LATEST);

            int cnt = mAlarms.size();

            o.writeInt(cnt);
            for (int i = 0; i < cnt; i++)
            {
                stAlarm a = (stAlarm)mAlarms.elementAt(i);
                o.writeUTF(a.code);
                o.writeInt(a.date);
                o.writeInt(a.lowerPrice);
                o.writeInt(a.upperPrice);

                o.writeUTF(a.comment);
            }

            xFileManager.saveFile(o, Context.FILE_ALARM);
        }
Esempio n. 6
0
 public void removeAlarm(stAlarm a)
 {
     mAlarms.removeElement(a);
 }
Esempio n. 7
0
 public void addAlarm(stAlarm a)
 {
     mAlarms.addElement(a);
 }