示例#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);
                }
            }
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#6
0
 public void removeAlarm(stAlarm a)
 {
     mAlarms.removeElement(a);
 }
示例#7
0
 public void addAlarm(stAlarm a)
 {
     mAlarms.addElement(a);
 }