Exemplo n.º 1
0
        //==========================================
        void loadShareGroup(xDataInput di)
        {
            int cnt = di.readInt();

            if (cnt > stShareGroup.MAX_SHARES_IN_GROUP)
            {
                cnt = stShareGroup.MAX_SHARES_IN_GROUP;
            }
            xVector v = shareGroups();

            if (cnt > 0)
            {
                v.removeAllElements();
            }
            for (int i = 0; i < cnt; i++)
            {
                stShareGroup g = new stShareGroup();
                g.load(di);

                if (g.getType() == stShareGroup.ID_GROUP_GAINLOSS || g.getName() == null || g.getName().Length == 0)
                {
                    continue;
                }
                v.addElement(g);
            }
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }