Ver Fonte

yu.jie 分时图

Administrator há 4 anos atrás
pai
commit
87571494cb

+ 48 - 1
RMA/app/src/main/java/cn/muchinfo/rma/global/data/chart/ChartTSData.kt

@@ -9,4 +9,51 @@ data class ChartTSData(
     val preSettle: String? = "",//                              昨结
     val startTime: String? = "",//                              开始时间
     val tradeDate: String? = ""//                               交易日
-)
+){
+    /**
+     * 获取用于分时图的收盘价列表
+     */
+    fun getTimeChartPriceData() : List<Double> {
+        return if(historyDatas != null && historyDatas.isNotEmpty()){
+            historyDatas.map {
+                it.c!!.toDouble()
+            }
+        }else{
+            arrayListOf();
+        }
+    }
+
+    /**
+     * 获取用于分时图的时间列表
+     */
+    fun getTimeChartPriceTime() : List<String> {
+        return if(historyDatas != null && historyDatas.isNotEmpty()){
+            historyDatas.map {
+                it.ts!!
+            }
+        }else{
+            arrayListOf();
+        }
+    }
+
+    /**
+     * 如果均线数据是补得数据  则计算数值时直接沿用上一口价格
+     * 计算分时图 AVG10
+     */
+    fun getTimeChartAVG10() : List<Double>{
+        var avg10 = arrayListOf<Double>()
+        if(historyDatas != null && historyDatas.isNotEmpty()){
+            for(index in historyDatas.indices){
+                if(index == 0){
+                    avg10.add(historyDatas[index].c!!.toDouble())
+                }else{
+                    if(historyDatas[index - 1].c.equals(historyDatas[index].c)){
+                        continue
+                    }
+                    avg10.add(((historyDatas[index - 1].c!!.toDouble() * historyDatas.size) + historyDatas[index].c!!.toDouble()) / (historyDatas.size + 1))
+                }
+            }
+        }
+        return avg10;
+    }
+}

+ 11 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartDataAdapter.kt

@@ -1,6 +1,7 @@
 package cn.muchinfo.rma.view.base.chart;
 
 import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.GoodsInfoAndQuotes
 
 /**
  * 数据在这里适配
@@ -11,4 +12,14 @@ class ChartDataAdapter {
         return GlobalDataCollection.instance
     }
 
+    /**
+     * 获取商品盘面
+     * 这里如果是分时图 这个是用goodsCode  其他的全部传outGoodsCode
+     */
+    fun getGoodsInfoMarket(goodsCode : String) : GoodsInfoAndQuotes? {
+        return GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find {
+            it.outgoodscode == goodsCode
+        }
+    }
+
 }

+ 17 - 446
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/TimeChartFragment.java

@@ -172,67 +172,16 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
         initListeners();
         initDatas();
         handleMessage();
-
         initComplete = true;//2732 x 2048
-//        if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() != MTPEnums.TRADEMODE_OPTION && goodsInfoAndQuotes.getTradeMode() != MTPEnums.TRADEMODE_TRADEMODESALE) {
             new Handler().postDelayed(new Runnable() {
                 public void run() {
-//                    if (mtp.polymer.com.main.chart.ParamConfigData.DisplayMode == 2) {
-//                        mode_kind.setVisibility(View.VISIBLE);
-//                        ll_displayMode.setVisibility(View.VISIBLE);
-//                        market_five_data.setText(getString(R.string.chart_pankou));
-//                    } else {
                         mode_kind.setVisibility(View.GONE);
                         ll_displayMode.setVisibility(View.GONE);
-//                        market_five_data.setText(getString(R.string.chart_five_data));
-//                    }
-                    initModeData();
                 }
             }, 400);
-
-            fetchOptionQty();
-//        }
-        // 竞价的、挂摘牌的、挂牌点选,有买卖报价大厅
-        loadSaleHall();
         return view;
     }
 
-    /**
-     * 买卖报价大厅
-     */
-    private void loadSaleHall() {
-//        if (goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING ||
-//                goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_ENTRUSTBID ||
-//                goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_ENTRUST_HEDGE) {
-//
-//            SaleHall saleHall = new SaleHall();
-//            Bundle bundle = new Bundle();
-//            bundle.putInt("goodsId", goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
-//            saleHall.setArguments(bundle);
-//            FragmentManager fragmentManager = getFragmentManager();
-//            FragmentTransaction transaction = fragmentManager.beginTransaction();
-//            transaction.add(R.id.sale_hall_area, saleHall);
-//            transaction.commit();
-//            //FIXME: 暂时隐藏
-//            sale_hall_area.setVisibility(View.GONE);
-//        } else if (goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_TRADEMODESALE) {
-//            // 挂牌期权也有报价大厅
-//            OptionHall optionHall = new OptionHall();
-//            Bundle bundle = new Bundle();
-//            bundle.putInt("optionType", goodsInfoAndQuotes.getGoodsInfo().getOptiontype());
-//            bundle.putInt("goodsId", goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
-//            optionHall.setArguments(bundle);
-//            FragmentManager fragmentManager = getFragmentManager();
-//            FragmentTransaction transaction = fragmentManager.beginTransaction();
-//            transaction.replace(R.id.sale_hall_area, optionHall);
-//            transaction.commit();
-//
-//            sale_hall_area.setVisibility(View.VISIBLE);
-//        } else {
-            sale_hall_area.setVisibility(View.GONE);
-//        }
-    }
-
 
     /**
      * 这个方法用来处理当fragment还没加载出来使用控件为空的情况。 将命令加入队列,等加载完fragment再handle
@@ -266,11 +215,7 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
      */
     private void initViews() {
         linear_lay = view.findViewById(R.id.linear_lay);
-//        if(Config.Chart_Color){
-//            linear_lay.setBackground(getResources().getDrawable(R.color.manager_body_bg));
-//        }else{
-            linear_lay.setBackground(getResources().getDrawable(R.color.p_global_bg_color));
-//        }
+        linear_lay.setBackground(getResources().getDrawable(R.color.p_global_bg_color));
         none = view.findViewById(R.id.time_none);
         market_one_data = view.findViewById(R.id.market_one_data);
         market_five_data = view.findViewById(R.id.market_five_data);
@@ -345,13 +290,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
     @Override
     public void onDestroy() {
         super.onDestroy();
-        if (attornDataControl != null) {
-            attornDataControl.destory();
-        }
-//        if (fetchGoodsRemainQty != null) {
-//            fetchGoodsRemainQty.stop();
-//            fetchGoodsRemainQty = null;
-//        }
     }
 
     @Override
@@ -423,341 +361,26 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
         if (bar.getVisibility() != View.GONE) {
             bar.setVisibility(View.GONE);
         }
-//        if (goodsInfoAndQuotes != null
-//                && (goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING)) {// 竞价或者混合,有5档行情
-            fiveDataControl = new FiveDataControl(goodsInfoAndQuotes.getGoodsInfo().getGoodsid(), this.getActivity());
-//            if (goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING ) {// 竞价点价方式
-//                attornDataControl = new AttornDataControl(getActivity(), goodsInfoAndQuotes);
-//                // FIXME :
-//                mtp_five_container.addView(attornDataControl.getView());
-//            } else {
-            market_five_data.setVisibility(View.VISIBLE);
-            market_one_data.setVisibility(View.VISIBLE);
-            fiveDataControl.setDatas(goodsInfoAndQuotes.getGoodsInfo().getGoodsid());
-            // FIXME : 显示五档行情
-            mtp_five_container.addView(fiveView);
-            reFreshFiveData();
-//            }
-            market_five_data.setVisibility(View.VISIBLE);
-            market_one_data.setVisibility(View.VISIBLE);
-            setSelectData(R.id.market_five_data);
-            market_five_data.setSelected(true);
-            list.setVisibility(View.GONE);
-            showFiveZDT();
-//        }
-//        else {
-//            adapter = new TikAdapter(getActivity(), goodsInfoAndQuotes);
-//            market_five_data.setVisibility(View.GONE);
-//            market_one_data.setVisibility(View.VISIBLE);
-//            market_one_data.setClickable(false);
-//            adapter.setDatas(tikLists, goodsInfoAndQuotes);
-//            list.setVisibility(View.VISIBLE);
-//            list.setAdapter(adapter);
-//            hideZDT();
-//        }
-        if (detailView.getVisibility() == View.VISIBLE) {
-            setRightUpDatas();
-        }
-
-        loadAndRefreshFiveArea();
-    }
-
-    /**
-     * 加载option type tab 同时加载和类型分类
-     */
-    private void initOptionModeData() {
-//        String[] titles;
-//        optionType = GlobalDataCollention.getInstance().getOptionTypeWithGoodsId(goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
-//        String upTitle = getResources().getString(R.string.p_option_up);
-//        String downTitle = getResources().getString(R.string.p_option_down);
-//        switch (optionType) {
-//            case MTPEnums.OPTION_TYPE_C:// 认购
-//                titles = new String[1];
-//                titles[0] = upTitle;
-//                break;
-//            case MTPEnums.OPTION_TYPE_P:// 认沽
-//                titles = new String[1];
-//                titles[0] = downTitle;
-//                break;
-//            default:
-//                titles = new String[2];
-//                titles[0] = upTitle;
-//                titles[1] = downTitle;
-//                break;
-//        }
-//        mtp_tab_host.show(titles, false);// 加载
-//        mtp_tab_host.selectTab(mtp_tab_host.getColumnSelectIndex());
-//        mtp_tab_host.setOnMtpTabHostListener(new MTPTabHostListener() {
-//            @Override
-//            public void onTabChanged(int current, int last, View view) {
-//                if (current == 0) {
-//                    fiveAdapter.showCOrP("C");
-//                } else if (current == 1) {
-//                    fiveAdapter.showCOrP("P");
-//                }
-//            }
-//        });
-    }
-
-    /**
-     * 挂摘牌模式
-     */
-    private void initModeData() {
-//        if (mtp.polymer.com.main.chart.ParamConfigData.DisplayMode == 2) {
-//            mtp_tab_host.show(PolApplication.getInstance().getResources().getStringArray(R.array.chart_display_mode), false);// 加载
-//            mtp_tab_host.selectTab(mtp_tab_host.getColumnSelectIndex());
-//            //交易模式不同显示的字段也不相同
-//            if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_MARKETMAKE) {
-//                mode_price.setVisibility(View.VISIBLE);
-//                application_method.setVisibility(View.VISIBLE);
-//                //价格:行情源价格,需实时刷新;----交易服务、交易端
-//                //申报方:显示该账户的对手会员的企业名称,且第一个字显示,其他以3个*表示,其中,若是有多个对手会员,则默认显示第一个;---由交易端根据实时的对手关系来显示对手会员(对手关系修改、新增已有接口,需要前置服务将对手关系的更新信息推送给交易端);
-//            } else if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING) {
-//                application_number.setVisibility(View.VISIBLE);
-//                mode_count.setVisibility(View.VISIBLE);
-//                application_method.setVisibility(View.VISIBLE);
-//                mode_price.setVisibility(View.VISIBLE);
-////                if (PolApplication.getInstance().isBidAttornMode(goodsInfoAndQuotes.getGoodsInfo().getGoodsId())) {
-//                // handle.setVisibility(View.VISIBLE);
-////                }
-//                //申报编号:显示该字段;
-//                //数量:显示该申报委托的未成交的挂牌数量;
-//                //申报方:若该账户是投资者账户,则显示投资者名称,且仅显示第一个字显示,其他以3个*表示;
-//                //       若是会员账户,显示该账户的企业名称,且第一个字显示,其他以3个*表示;
-//                //操作:点价成交时,显示该字段,且当为买挂牌时,按钮为“出售”,为卖挂牌时,按钮为“购买”;
-//                //     撮合成交时,不显示该字段。
-//            } else if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING) {
-//                mode_price.setVisibility(View.VISIBLE);
-//                mode_count.setVisibility(View.VISIBLE);
-//                application_method.setVisibility(View.VISIBLE);
-//                //价格、数量:若是行情源价格,则数量字段显示(按照已有的规则由系统给出),
-//                // 且申报方字段显示该账户的对手会员的企业名称,且第一个字显示,其他以3个*表示,---若是有多个对手会员,则默认显示第一个;
-//                //若不是行情源价格,则数量字段显示该申报委托的未成交的挂牌数量,且申报方字段显示该账户的投资者名称,且仅显示第一个字显示,其他以3个*表示;
-//
-//            }
-//            //设置数据在适配器上,默认加载购买申报大厅
-            refreshHallData(0);
-//        }
-    }
-
-    private void refreshHallData(int type) {
-        String customername = "";
-//        ArrayList<TraderelationInfoData> traderelationInfoData = GlobalDataCollention.getInstance().getTraderelationInfoData();
-//        if (traderelationInfoData != null && traderelationInfoData.size() > 0) {
-//            if (traderelationInfoData.get(0).getCustomername() != null && Utils.isEmpty(traderelationInfoData.get(0).getCustomername())) {
-//                customername = new AESCrypto().decrypt(traderelationInfoData.get(0).getCustomername());
-//            } else {
-//                customername = "--";
-//            }
-//        } else {
-//        if (GlobalDataCollention.getInstance().getAccountInfoData() == null) {
-//            customername = "";
-//        } else {
-//            customername = GlobalDataCollention.getInstance().getAccountInfoData().getAccountName();
-//        }
-//        }
-        //组装数据
-        ArrayList<PurcaseOrSellData> purcase = new ArrayList<>();
-//        if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING) {
-//
-//            BidQuoteDay quoteTik = (BidQuoteDay) goodsInfoAndQuotes.getQuoteDay();
-//            if (quoteTik == null) {
-//                return;
-//            }
-//
-//            if (mtp_tab_host.getCurrentIndxe() == MTPEnums.DIRECTION_BUY) {
-//
-//                ArrayList<ListingBidStoreOrderData> bidStoreOrderDatas = null;
-//                String bidQueueInfo = quoteTik.getBidQueueInfo();
-//                if (bidQueueInfo != null && !bidQueueInfo.equals("")) {// 买委托列队
-//                    boolean ret = QuoteCollention.getInstance().addBidStoreOrderDatas(bidQueueInfo);// 添加到本地列队中...
-//                    if (!ret) {
-//                        bidStoreOrderDatas = QuoteCollention.getInstance().getBidStoreOrderDatas();//买挂牌
-//                    }
-//                } else {
-//                    QuoteCollention.getInstance().getBidStoreOrderDatas().clear();
-//                    bidStoreOrderDatas = QuoteCollention.getInstance().getBidStoreOrderDatas();//买挂牌
-//                }
-//                for (ListingBidStoreOrderData bid : bidStoreOrderDatas) {
-//                    PurcaseOrSellData psd = new PurcaseOrSellData();
-//                    psd.setHallDr(customername);//申报人
-//                    psd.setGoodsInfoAndQuotes(goodsInfoAndQuotes);
-//                    psd.setHallId(bid.getOrderid());//申报编号
-//                    psd.setPrice(bid.getOrderprice());//价格
-//                    psd.setNum(bid.getEnableqty());//数量
-//                    psd.setOperate(bid.getOperatetype());//操作
-//                    purcase.add(psd);
-//                    //>>买、卖挂牌信息默认显示5条。
-//                    if (purcase.size() > 5) {
-//                        break;
-//                    }
-//
-//                }
-//            } else {
-//
-//                ArrayList<ListingAskStoreOrderData> askStoreOrderDatas = null;
-//                String bidQueueInfo = quoteTik.getAskQueueInfo();
-//                if (bidQueueInfo != null && !bidQueueInfo.equals("")) {// 买委托列队
-//                    boolean ret = QuoteCollention.getInstance().addAskStoreOrderDatas(bidQueueInfo);// 添加到本地列队中...
-//                    if (!ret) {
-//                        askStoreOrderDatas = QuoteCollention.getInstance().getAskStoreOrderDatas();
-//                    }
-//                } else {
-//                    QuoteCollention.getInstance().getBidStoreOrderDatas().clear();
-//                    askStoreOrderDatas = QuoteCollention.getInstance().getAskStoreOrderDatas();
-//                }
-//                for (ListingAskStoreOrderData bid : askStoreOrderDatas) {
-//                    PurcaseOrSellData psd = new PurcaseOrSellData();
-//                    psd.setHallDr(customername);//申报人
-//                    psd.setGoodsInfoAndQuotes(goodsInfoAndQuotes);
-//                    psd.setHallId(bid.getOrderid());//申报编号
-//                    psd.setPrice(bid.getOrderprice());//价格
-//                    psd.setNum(bid.getEnableqty());//数量
-//                    psd.setOperate(bid.getOperatetype());//操作
-//                    purcase.add(psd);
-//                    //>>买、卖挂牌信息默认显示5条。
-//                    if (purcase.size() > 5) {
-//                        break;
-//                    }
-//
-//                }
-//            }
-//
-//        } else if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING) {
-//            if (fiveDataControl != null && fiveDataControl.getItems() != null && fiveDataControl.getItems().size() > 0) {
-//                for (int i = 0; i < fiveDataControl.getItems().size(); i++) {
-//                    String fivePrice = getFivePrice(fiveDataControl.getItems().get(i).getValue());
-//                    if (!fivePrice.equals("0")) {
-//                        if (type == MTPEnums.DIRECTION_BUY) {
-//                            if (i > 4) {
-//                                PurcaseOrSellData psd = new PurcaseOrSellData();
-//                                psd.setNum(fiveDataControl.getItems().get(i).getSum());
-//                                psd.setPrice(fivePrice);
-//                                psd.setHallDr(customername);//申报人
-//                                psd.setGoodsInfoAndQuotes(goodsInfoAndQuotes);
-//                                psd.setType(type);
-//                                purcase.add(psd);
-//                            }
-//                        } else {
-//                            if (i <= 4) {
-//                                PurcaseOrSellData psd = new PurcaseOrSellData();
-//                                psd.setNum(fiveDataControl.getItems().get(i).getSum());
-//                                psd.setPrice(fivePrice);
-//                                psd.setHallDr(customername);//申报人
-//                                psd.setGoodsInfoAndQuotes(goodsInfoAndQuotes);
-//                                psd.setType(type);
-//                                purcase.add(psd);
-//                            }
-//                        }
-//
-//                    }
-//
-//                }
-//
-//            }
-//        } else {
-//            PurcaseOrSellData psd = new PurcaseOrSellData();
-//            psd.setHallDr(customername);//申报人
-//            psd.setGoodsInfoAndQuotes(goodsInfoAndQuotes);
-//            psd.setType(type);
-//            purcase.add(psd);
-//        }
-//        if (mtp_message.getAdapter() == null) {
-//            mtp_message.setAdapter(new PurcaseOrSellAdapter(purcase, getActivity()));
-//        } else {
-//            if (mtp_message.getAdapter() instanceof PurcaseOrSellAdapter) {
-//                ((PurcaseOrSellAdapter) mtp_message.getAdapter()).setDatas(purcase, getActivity());
-//            }
-//        }
-
-
-    }
 
-    private String getFivePrice(String value) {
-        String fprice = "0";
-//        if (Utils.isEmpty(value) && value.contains(":")) {
-//            String[] split = value.split("[:]");
-//            fprice = split[1];
-//        }
-        return fprice;
+        fiveDataControl = new FiveDataControl(goodsInfoAndQuotes.getGoodsInfo().getGoodsid(), this.getActivity());
 
-    }
+        market_five_data.setVisibility(View.VISIBLE);
+        market_one_data.setVisibility(View.VISIBLE);
+        fiveDataControl.setDatas(goodsInfoAndQuotes.getGoodsInfo().getGoodsid());
+        // FIXME : 显示五档行情
+        mtp_five_container.addView(fiveView);
+        reFreshFiveData();
 
-    /**
-     * 显示竞价的涨跌停
-     */
-    private void showFiveZDT() {
-        ArrayList<FiveDataItemData> dataItemDatas = fiveDataControl.getDataItemDatas();
-        mtp_up_value.setText(dataItemDatas.get(0).getValue());
-        mtp_down_value.setText(dataItemDatas.get(0).getSum());
-        mtp_up_sum.setText(dataItemDatas.get(1).getValue());
-        mtp_down_sum.setText(dataItemDatas.get(1).getSum());
-//        if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_BIDDING) {
-//            mtp_change_sum.setVisibility(View.GONE);
-//            mtp_change_value.setVisibility(View.GONE);
-//            mtp_up_value.setVisibility(View.GONE);
-//            mtp_down_value.setVisibility(View.GONE);
-//            mtp_up_sum.setVisibility(View.GONE);
-//            mtp_down_sum.setVisibility(View.GONE);
-//        } else {
-            mtp_up_value.setVisibility(View.VISIBLE);
-            mtp_down_value.setVisibility(View.VISIBLE);
-            mtp_up_sum.setVisibility(View.VISIBLE);
-            mtp_down_sum.setVisibility(View.VISIBLE);
-//        }
-//        mtp_change_value.setText(R.string.chart_change_total);
-//        if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getQuoteDay() == null) {
-//            mtp_change_sum.setText("--");
-//        } else {
-//            mtp_change_sum.setText(((BidQuoteDay) goodsInfoAndQuotes.getQuoteDay()).getChangeVolumeRange().equals("-1") ? "--" : Utils
-//                    .roundNum(((BidQuoteDay) goodsInfoAndQuotes.getQuoteDay()).getChangeVolumeRange(), 2) + "%");
-//            // mtp_change_sum.setText(goodsInfoAndQuotes.getTurnoverRate() ==
-//            // null ? "--" : (goodsInfoAndQuotes.getTurnoverRate() + "%"));
-//        }
-//        mtp_total_value.setText(R.string.chart_bid_total);
-        // 总量
-        if (goodsInfoAndQuotes == null || goodsInfoAndQuotes.getQuoteDayData() == null) {
-            mtp_total_sum.setText("0");
-        } else {
-//            mtp_total_sum.setText(scientific(((BidQuoteDay) goodsInfoAndQuotes.getQuoteDayData()).getTotalVolume()));
-        }
-        // 总额
-        if (goodsInfoAndQuotes == null || goodsInfoAndQuotes.getQuoteDayData() == null) {
-            mtp_totalturnover.setText("0");
-        } else {
-//            mtp_totalturnover.setText(scientific(((BidQuoteDay) goodsInfoAndQuotes.getQuoteDayData()).getTotalTurnover()));
+        market_five_data.setVisibility(View.VISIBLE);
+        market_one_data.setVisibility(View.VISIBLE);
+        setSelectData(R.id.market_five_data);
+        market_five_data.setSelected(true);
+        list.setVisibility(View.GONE);
+        if (detailView.getVisibility() == View.VISIBLE) {
+            setRightUpDatas();
         }
-        mtp_zdt_area.setVisibility(View.VISIBLE);
-//        if (mtp.polymer.com.main.chart.ParamConfigData.DisplayMode == 2) {
-            mtp_five_container.setVisibility(View.GONE);
-//        } else {
-//            mtp_five_container.setVisibility(View.VISIBLE);
-//        }
-    }
 
-    // 科学计数法转换
-    private String scientific(String value) {
-//        if (!Utils.isEmpty(value)) {
-            if (value.contains("E")) {
-                String[] split = value.split("[E]");
-                double v = Double.parseDouble(split[0]);
-                int i = Integer.parseInt(split[1]);
-                double mv = v * Math.pow(10, i);
-                // 将资金转化为千万
-                if (mv > 10000000) {
-                    // 取四位小数点
-                    double c = mv / 10000;
-                    DecimalFormat format = new DecimalFormat("#.####");
-                    String fm = format.format(c);
-                    return fm + "万";
-                } else {
-//                    return Utils.roundNum(mv, 2);
-                }
-            } else {
-                return value;
-            }
-//        }
-        return "--";
+        loadAndRefreshFiveArea();
     }
 
     /**
@@ -768,14 +391,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
         mtp_five_container.setVisibility(View.GONE);
     }
 
-    MTPTabHostListener hostListener = new MTPTabHostListener() {
-        @Override
-        public void onTabChanged(int current, int last, View view) {
-            // FIXME:切换
-            refreshHallData(current);
-        }
-    };
-
     private void setSelectData(int id) {
         market_one_data.setSelected(id == R.id.market_one_data);
         market_five_data.setSelected(id == R.id.market_five_data);
@@ -1075,8 +690,7 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
 //            } else {
 //                fiveAdapter.setData(fiveOption, goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
 //            }
-
-            initOptionModeData();
+//
 //            ll_displayMode.setVisibility(View.VISIBLE);
 //            View view = LayoutInflater.from(getActivity()).inflate(R.layout.option_five_head, null);
 //            mode_kind.addView(view);
@@ -1092,12 +706,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
         if (goodsInfoAndQuotes == null) {
             return;
         }
-//        if (fetchGoodsRemainQty == null) {
-//            List<Integer> integers = new LinkedList<>();
-//            integers.add(goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
-//            fetchGoodsRemainQty = new FetchGoodsRemainQty(integers);
-//        }
-//        fetchGoodsRemainQty.start();
     }
 
     public void activityResult() {
@@ -1107,46 +715,17 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
 
     private void loadFiveData() {
         // fixme 获取五档商品信息
-//        fiveOption = GlobalDataCollention.getInstance().getFiveOption(goodsInfoAndQuotes.getGoodsInfo().getGoodsId());
-//        if (goodsInfoAndQuotes != null && goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_OPTION) {
-//            Collections.sort(fiveOption, new Comparator<GoodsInfoAndQuotes>() {
-//                @Override
-//                public int compare(GoodsInfoAndQuotes o1, GoodsInfoAndQuotes o2) {
-//                    if (!o1.getGoodsInfo().getGoodsCode().contains("@") ||
-//                            !o2.getGoodsInfo().getGoodsCode().contains("@")) {
-//                        return 0;
-//                    }
-//                    int o11 = Integer.parseInt(o1.getGoodsInfo().getGoodsCode().split("@")[1].replace("C", "").replace("P", ""));
-//                    int o22 = Integer.parseInt(o2.getGoodsInfo().getGoodsCode().split("@")[1].replace("C", "").replace("P", ""));
-//                    if (o11 > o22) {
-//                        return 1;
-//                    } else {
-//                        return -1;
-//                    }
-//                }
-//            });
-//        }
-
     }
 
     @Override
     public void onResume() {
         onRefresh(false);
-//        if (goodsInfoAndQuotes.getTradeMode() == MTPEnums.TRADEMODE_TRADEMODESALE) {
-//            // 挂牌期权刷新报价大厅数据
-//            loadSaleHall();
-//        }
         super.onResume();
     }
 
     @Override
     public void notifyEvent(int eventId, GridChart chart) {
         try {
-//            if(getActivity() instanceof ManagerChartAcitivity){
-//                ((ManagerChartAcitivity) getActivity()).notifyEvent(eventId, chart);
-//            }else {
-//                ((OTCChartActivity) getActivity()).notifyEvent(eventId, chart);
-//            }
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -1187,8 +766,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
         mtp_sum_buy_four.setText(fiveDataControl.getItems().get(8).getSum());
         mtp_value_buy_five.setText(fiveDataControl.getItems().get(9).getValue());
         mtp_sum_buy_five.setText(fiveDataControl.getItems().get(9).getSum());
-
-        showFiveZDT();
     }
 
     @Override
@@ -1205,7 +782,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
                 fiveDataControl.setDatas(goodsInfoAndQuotes.getGoodsInfo().getGoodsid());
                 // FIXME : 显示五档行情
                 reFreshFiveData();
-                showFiveZDT();
                 list.setVisibility(View.GONE);
                 break;
             case R.id.market_one_data:// 明细
@@ -1219,11 +795,6 @@ public class TimeChartFragment extends Fragment implements ITouchEventResponse,
                 hideZDT();
                 break;
             case R.id.time_none: {
-//                if (getActivity() instanceof OTCChartActivity) {
-//                    ((OTCChartActivity) getActivity()).requestTimeChartData();
-//                } else if (getActivity() instanceof ManagerChartAcitivity) {
-//                    ((ManagerChartAcitivity) getActivity()).requestTimeChartData();
-//                }
                 none.setVisibility(View.INVISIBLE);
             }
             break;

+ 103 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/TimeChartView.java

@@ -0,0 +1,103 @@
+package cn.muchinfo.rma.view.base.chart.old.timeCharts;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.FrameLayout;
+import com.desfate.chart.LineChart;
+import com.desfate.chart.entity.LineEntity;
+import java.util.ArrayList;
+import java.util.List;
+import cn.muchinfo.rma.R;
+import cn.muchinfo.rma.global.data.chart.ChartTSData;
+import cn.muchinfo.rma.view.base.chart.ChartDataAdapter;
+
+/**
+ * 我负责抽离混乱的分时图逻辑
+ */
+public class TimeChartView extends FrameLayout {
+
+    View view;
+    Context context;
+    ChartTSData timeChartData;
+    LineChart lineChart;
+
+    public TimeChartView(Context context) {
+        super(context);
+        this.context = context;
+        initView();
+    }
+
+    public TimeChartView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        this.context = context;
+        initView();
+    }
+
+    private void initView(){
+        view = LayoutInflater.from(context).inflate(R.layout.time_chart_view, null);
+        lineChart = view.findViewById(R.id.line_chart_view);
+        setLineConfig();
+    }
+
+    private void setLineConfig(){
+        lineChart.setAxisXColor(Color.LTGRAY);
+        lineChart.setAxisYColor(Color.LTGRAY);
+        lineChart.setBorderColor(Color.LTGRAY);
+        int fontSize = getResources().getDimensionPixelSize(R.dimen.chart_font_size);
+        lineChart.setLongitudeFontSize(fontSize);
+        lineChart.setLatitudeFontSize(fontSize);
+        lineChart.setLongitudeColor(Color.GRAY);
+        lineChart.setLongitudeFontColor(Color.GRAY);
+        // 纬线数量
+        lineChart.setLatitudeNum(4);
+        // 经线数量
+        lineChart.setLongitudeNum(1);
+        lineChart.setStartIndex(1);
+        lineChart.setLatitudeColor(Color.GRAY);
+        lineChart.setLatitudeFontColor(Color.GRAY);
+        lineChart.setBackgroundColor(getResources().getColor(R.color.manager_body_bg));
+        // 设置屏幕最多显示多少条数据,如果多余这个数字将要滑动才能看见
+        lineChart.setMaxPointNum(1440);
+        lineChart.setDisplayAxisXTitle(true);
+        lineChart.setDisplayAxisYTitle(true);
+        lineChart.setDisplayLatitude(true);
+        lineChart.setDisplayLongitude(true);
+        lineChart.setDisplayCrossXOnTouch(true);
+        lineChart.setDisplayCrossYOnTouch(true);
+        lineChart.addNotify((eventId, chart) -> {
+
+        });
+    }
+
+    /**
+     * 设置分时图数据
+     */
+    private void setData(ChartTSData timeChartData){
+        this.timeChartData = timeChartData;
+        if(timeChartData == null || timeChartData.getHistoryDatas() == null) return; // 没有数据
+        // 这是需要画的线
+        List<LineEntity> lines = new ArrayList<>();
+        // 分钟线
+        LineEntity minutesLine = new LineEntity();
+        minutesLine.setTitle("M");
+        minutesLine.setLineData(timeChartData.getTimeChartPriceData());
+        minutesLine.setLineColor(getResources().getColor(R.color.mtp_chart_t_m5_m1));
+        minutesLine.setLineTime(timeChartData.getTimeChartPriceTime());
+        // 十日均线
+        LineEntity avg10Line = new LineEntity();
+        avg10Line.setTitle("AVG10");
+        avg10Line.setLineData(timeChartData.getTimeChartAVG10());
+        avg10Line.setLineTime(timeChartData.getTimeChartPriceTime());
+        avg10Line.setLineColor(getResources().getColor(R.color.mtp_chart_t_avg));
+        // 这里是通过起始点和结束点 确认当前显示的宽高
+        lineChart.initAxisY(timeChartData.getPreSettle(),
+                String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(timeChartData.getGoodsCode()).getQuoteDayData().getLast()),
+                timeChartData.getDecimalPlace());
+        lineChart.setDecimalNum(Integer.parseInt(timeChartData.getDecimalPlace()));
+        lineChart.setLineData(lines);
+    }
+
+}

+ 18 - 0
RMA/app/src/main/res/layout/time_chart_view.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <com.desfate.chart.LineChart
+        android:id="@+id/line_chart_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        />
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>