Esempio n. 1
0
 public GainLossManager gainLossManager()
 {
     if (_gainLossManager == null)
     {
         _gainLossManager = new GainLossManager();
     }
     return(_gainLossManager);
 }
Esempio n. 2
0
        void loadGainload(xDataInput di)
        {
            int cnt = di.readInt();

            if (cnt > 50)
            {
                cnt = 50;
            }
            GainLossManager m = gainLossManager();

            if (cnt > 0)
            {
                m.clearAll();
            }
            for (int i = 0; i < cnt; i++)
            {
                String code  = di.readUTF();
                int    date  = di.readInt();
                float  price = di.readInt() / 1000.0f;
                int    vol   = di.readInt();

                if (date == 0)
                {
                    date = Utils.getDateAsInt();
                    GlobalData.vars().setValueBool("should_flush_userdata", true);
                }

                if (code != null && code.Length >= 3 && code.Length < 15)
                {
                    if (Context.getInstance() != null && Context.getInstance().mShareManager != null)
                    {
                        int id = Context.getInstance().mShareManager.getShareID(code);
                        if (id > 0)
                        {
                            m.addGainLoss(code, date, price, vol);
                        }
                    }

                    //m.addGainLoss(code, date, price, vol);
                }
            }
            m.sortList();
        }
Esempio n. 3
0
        public TablePriceboard(xIEventListener listener, GainLossManager gainlosses, int w, int rowH)
            : base(listener)
        {
            setBackgroundColor(C.COLOR_BLACK);

            int cnt = gainlosses.getTotal();

            int y = 0;

            Font   f = Context.getInstance().getFontText();
            xLabel l = xLabel.createSingleLabel("Lãi lỗ");

            l.setBackgroundColor(C.COLOR_ORANGE);
            l.setSize(w, (int)f.GetHeight() + 4);
            l.setPosition(0, 0);
            l.setTextColor(C.COLOR_GREEN);
            y = l.getBottom() + 1;

            addControl(l);

            for (int i = 0; i <= cnt; i++)
            {
                int idx = i - 1;
                int rH  = rowH;
                if (idx == -1)
                {
                    rH = 20;
                }

                RowGainloss r = new RowGainloss(listener, i, w, rH);

                if (idx >= 0)
                {
                    stGainloss g = (stGainloss)gainlosses.getGainLossAt(idx);

                    r.setData(g);
                }
                r.setParent(this);
                r.setPosition(0, y);

                addControl(r);
                vRows.addElement(r);

                y += rH + 1;
            }

            //	thong ke
            {
                GainLossSumary sumary = new GainLossSumary(w);
                sumary.setPosition(0, y);
                addControl(sumary);

                y += sumary.getH();
            }
            //  Help
            {
                xFillBackground bottom = xFillBackground.createFill(w, 1, C.COLOR_GRAY_LIGHT);
                bottom.setPosition(0, y);
                addControl(bottom);
                y += 1;

                l = xLabel.createSingleLabel("Click phím phải chuột để thêm/xóa mã hoặc nhóm");
                l.setTextColor(C.COLOR_WHITE);
                l.setPosition(l.getW() - 4, y + 3);
                addControl(l);

                y += l.getH() + 4;
            }

            xFillBackground fillBottom = xFillBackground.createFill(w, 2, C.COLOR_GRAY_LIGHT);

            fillBottom.setPosition(0, y);
            addControl(fillBottom);

            invalidate();
        }
Esempio n. 4
0
        public xDataOutput getUserDataAsStreamOldVersion()
        {
            xDataOutput o = new xDataOutput(5 * 1024);

            o.writeInt(FILE_ONLINE_USERDATA_VER);
            int i;

            xVector         v                = new xVector(10);
            xVector         mFavorGroups     = shareGroups();
            GainLossManager mGainLossManager = gainLossManager();

            int groupCnt = mFavorGroups.size() < 30?mFavorGroups.size():30;

            for (i = 0; i < groupCnt; i++)
            {
                stShareGroup p = (stShareGroup)mFavorGroups.elementAt(i);

                bool added = false;
                for (int j = 0; j < v.size(); j++)
                {
                    stShareGroup o1 = (stShareGroup)v.elementAt(j);
                    if (o1.getName().CompareTo(p.getName()) == 0)
                    {
                        added = true;
                        break;
                    }
                }

                if (added == false)
                {
                    v.addElement(p);
                }
            }

            o.writeInt(v.size());

            for (i = 0; i < v.size(); i++)
            {
                stShareGroup p = (stShareGroup)v.elementAt(i);

                p.save(o);
            }

            //  gainloss com.data
            o.writeInt(FILE_GAINLOSS_SIGNAL);
            o.writeInt(mGainLossManager.getTotal());
            for (i = 0; i < mGainLossManager.getTotal(); i++)
            {
                stGainloss g = mGainLossManager.getGainLossAt(i);

                o.writeUTF(g.code);
                o.writeInt(g.date);
                o.writeInt((int)g.price);
                o.writeInt(g.volume);
            }

            //  filter sets
            o.writeInt(FILE_FILTER_SET_VERSION);
            FilterManager.getInstance().saveFilterSets(o);

            //  down signal group
            //o.writeInt(FILE_DOWN_SIGNAL);
            //mAlarmGroup.save(o);

            return(o);
        }
Esempio n. 5
0
        public void loadUserDataOldVersion(xDataInput di)
        {
            int ver = 0;

            if (di != null)
            {
                ver = di.readInt();
            }

            xVector         mFavorGroups     = shareGroups();
            GainLossManager mGainLossManager = gainLossManager();

            if (di != null && (ver == FILE_VERSION_FAVORITE ||
                               ver == FILE_ONLINE_USERDATA_VER))
            {
                mFavorGroups.removeAllElements();
                mGainLossManager.clearAll();

                int cnt = di.readInt();

                for (int i = 0; i < cnt; i++)
                {
                    stShareGroup g = new stShareGroup();

                    g.load(di);
                    //g.setType(stShareGroup::GROUP_TYPE_FAVORITE);

                    mFavorGroups.addElement(g);
                }

                /*
                 * //  sort
                 * Collections.sort(mFavorGroups, new Comparator<stShareGroup>() {
                 *  @Override
                 *  public int compare(stShareGroup o1, stShareGroup o2) {
                 *      return o1.getName().compareToIgnoreCase(o2.getName());
                 *  }
                 * });
                 */

                //======this version does not support gainloss======
                if (di.available() > 0)
                {
                    ver = di.readInt();
                    if (ver == FILE_GAINLOSS_SIGNAL)
                    {
                        cnt = di.readInt();
                        mGainLossManager.clearAll();
                        for (int i = 0; i < cnt; i++)
                        {
                            String code  = di.readUTF();
                            int    date  = di.readInt();
                            int    price = di.readInt();
                            int    vol   = di.readInt();

                            if (date == 0)
                            {
                                GlobalData.vars().setValueBool("should_flush_userdata", true);
                            }

                            if (code != null && code.Length >= 3)
                            {
                                mGainLossManager.addGainLoss(code, date, price, vol);
                            }
                        }
                        mGainLossManager.sortList();

                        if (mGainLossManager.getTotal() > 0)
                        {
                            mGainLossManager.save();
                        }
                    }
                    ver = di.readInt();
                    if (ver == FILE_FILTER_SET_VERSION)
                    {
                        FilterManager.getInstance().loadFilterSets(di);
                    }
                }
            }
        }