Commit 4d51724ee8a7d52f29303e9a63c34122eeab9b73

Authored by 姚旭斌
1 parent b45abd57

no message

.idea/modules.xml
@@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
4 <modules> 4 <modules>
5 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> 5 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
6 <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> 6 <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" />
7 - <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" />  
8 <module fileurl="file://F:\parentwork\parentWorkHolper.iml" filepath="F:\parentwork\parentWorkHolper.iml" /> 7 <module fileurl="file://F:\parentwork\parentWorkHolper.iml" filepath="F:\parentwork\parentWorkHolper.iml" />
  8 + <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" />
9 <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> 9 <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" />
10 <module fileurl="file://F:\parentWorkHolper\parentwork.iml" filepath="F:\parentWorkHolper\parentwork.iml" /> 10 <module fileurl="file://F:\parentWorkHolper\parentwork.iml" filepath="F:\parentWorkHolper\parentwork.iml" />
11 <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" /> 11 <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" />
app/libs/processor.jar
No preview for this file type
app/src/main/java/com/shunzhi/parent/ui/activity/report/ReportSceneActivity.java
@@ -20,9 +20,9 @@ import com.shunzhi.parent.ui.fragment.report.ReportSceneFragment; @@ -20,9 +20,9 @@ import com.shunzhi.parent.ui.fragment.report.ReportSceneFragment;
20 */ 20 */
21 21
22 public class ReportSceneActivity extends BaseMVPCompatActivity implements View.OnClickListener { 22 public class ReportSceneActivity extends BaseMVPCompatActivity implements View.OnClickListener {
23 - public static void getInstance(Context context,int screenID) { 23 + public static void getInstance(Context context,int sceneID) {
24 Intent intent = new Intent(context, ReportSceneActivity.class); 24 Intent intent = new Intent(context, ReportSceneActivity.class);
25 - intent.putExtra("screenID",screenID); 25 + intent.putExtra("sceneID",sceneID);
26 context.startActivity(intent); 26 context.startActivity(intent);
27 } 27 }
28 28
@@ -54,9 +54,9 @@ public class ReportSceneActivity extends BaseMVPCompatActivity implements View.O @@ -54,9 +54,9 @@ public class ReportSceneActivity extends BaseMVPCompatActivity implements View.O
54 center_title = findViewById(R.id.center_title); 54 center_title = findViewById(R.id.center_title);
55 center_title.setText("场景详情"); 55 center_title.setText("场景详情");
56 ivBack.setOnClickListener(this); 56 ivBack.setOnClickListener(this);
57 - int screenID = getIntent().getIntExtra("screenID",0); 57 + int sceneID = getIntent().getIntExtra("sceneID",0);
58 Bundle bundle=new Bundle(); 58 Bundle bundle=new Bundle();
59 - bundle.putInt("screenID",screenID); 59 + bundle.putInt("sceneID",sceneID);
60 reportSceneFragment.setArguments(bundle); 60 reportSceneFragment.setArguments(bundle);
61 fragmentTransaction = getSupportFragmentManager().beginTransaction(); 61 fragmentTransaction = getSupportFragmentManager().beginTransaction();
62 fragmentTransaction.add(R.id.frame_scene, reportSceneFragment) 62 fragmentTransaction.add(R.id.frame_scene, reportSceneFragment)
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
@@ -4,33 +4,20 @@ package com.shunzhi.parent.ui.fragment; @@ -4,33 +4,20 @@ package com.shunzhi.parent.ui.fragment;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.os.Message; 6 import android.os.Message;
7 -import android.support.annotation.NonNull;  
8 import android.support.annotation.Nullable; 7 import android.support.annotation.Nullable;
9 import android.support.design.widget.TabLayout; 8 import android.support.design.widget.TabLayout;
10 import android.support.v4.app.Fragment; 9 import android.support.v4.app.Fragment;
11 import android.support.v4.app.FragmentManager; 10 import android.support.v4.app.FragmentManager;
12 import android.support.v4.app.FragmentPagerAdapter; 11 import android.support.v4.app.FragmentPagerAdapter;
13 import android.support.v4.view.ViewPager; 12 import android.support.v4.view.ViewPager;
14 -import android.support.v7.widget.LinearLayoutManager;  
15 -import android.support.v7.widget.RecyclerView;  
16 import android.view.View; 13 import android.view.View;
17 import android.widget.TextView; 14 import android.widget.TextView;
18 15
19 -import com.amy.monthweek.materialcalendarview.MonthWeekMaterialCalendarView;  
20 -import com.prolificinteractive.materialcalendarview.CalendarDay;  
21 -import com.prolificinteractive.materialcalendarview.MaterialCalendarView;  
22 -import com.share.mvpsdk.base.BasePresenter;  
23 import com.share.mvpsdk.base.fragment.BaseCompatFragment; 16 import com.share.mvpsdk.base.fragment.BaseCompatFragment;
24 -import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment;  
25 -import com.share.mvpsdk.utils.ToastUtils;  
26 import com.shunzhi.parent.R; 17 import com.shunzhi.parent.R;
27 -import com.shunzhi.parent.adapter.ReportAdapter;  
28 -import com.shunzhi.parent.bean.ReportBean;  
29 -import com.shunzhi.parent.contract.report.ReportContract;  
30 import com.shunzhi.parent.popu.ShaiXuanPop; 18 import com.shunzhi.parent.popu.ShaiXuanPop;
31 -import com.shunzhi.parent.presenter.report.ReportPresenter; 19 +import com.shunzhi.parent.ui.activity.report.ReportSceneActivity;
32 import com.shunzhi.parent.ui.fragment.report.ChengZhangFragment; 20 import com.shunzhi.parent.ui.fragment.report.ChengZhangFragment;
33 -import com.shunzhi.parent.views.CustomLinearLayoutManager;  
34 21
35 import java.util.List; 22 import java.util.List;
36 23
@@ -45,7 +32,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi @@ -45,7 +32,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi
45 32
46 ChengZhangFragment chengZhangFragment1 = null, chengZhangFragment2 = null;//成长、报告页面 33 ChengZhangFragment chengZhangFragment1 = null, chengZhangFragment2 = null;//成长、报告页面
47 34
48 - ShaiXuanPop shaiXuanPop=null; 35 + ShaiXuanPop shaiXuanPop = null;
49 36
50 @Override 37 @Override
51 public int getLayoutId() { 38 public int getLayoutId() {
@@ -60,6 +47,9 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi @@ -60,6 +47,9 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi
60 tvNoData = view.findViewById(R.id.tvNoData); 47 tvNoData = view.findViewById(R.id.tvNoData);
61 tabLayout = view.findViewById(R.id.tabLayout); 48 tabLayout = view.findViewById(R.id.tabLayout);
62 49
  50 +
  51 +
  52 + tvNoData.setOnClickListener(this);
63 tvShaiXuan.setOnClickListener(this); 53 tvShaiXuan.setOnClickListener(this);
64 54
65 myFragmentAdapter = new MyFragmentAdapter(getChildFragmentManager()); 55 myFragmentAdapter = new MyFragmentAdapter(getChildFragmentManager());
@@ -77,7 +67,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi @@ -77,7 +67,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi
77 67
78 @Override 68 @Override
79 public void onPageSelected(int position) { 69 public void onPageSelected(int position) {
80 - if (position==0)tvShaiXuan.setVisibility(View.GONE); 70 + if (position == 0) tvShaiXuan.setVisibility(View.GONE);
81 else tvShaiXuan.setVisibility(View.VISIBLE); 71 else tvShaiXuan.setVisibility(View.VISIBLE);
82 } 72 }
83 73
@@ -91,15 +81,17 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi @@ -91,15 +81,17 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi
91 81
92 @Override 82 @Override
93 public void onClick(View view) { 83 public void onClick(View view) {
94 - switch (view.getId()){ 84 + switch (view.getId()) {
95 case R.id.tvShaiXuan: 85 case R.id.tvShaiXuan:
96 if (null == shaiXuanPop) shaiXuanPop = new ShaiXuanPop(getActivity()); 86 if (null == shaiXuanPop) shaiXuanPop = new ShaiXuanPop(getActivity());
97 chengZhangFragment2.showShaixuan(handler); 87 chengZhangFragment2.showShaixuan(handler);
98 break; 88 break;
  89 + case R.id.tvNoData:
  90 + ReportSceneActivity.getInstance(getActivity(), 3);
99 } 91 }
100 } 92 }
101 93
102 - Handler handler=new Handler(){ 94 + Handler handler = new Handler() {
103 @Override 95 @Override
104 public void handleMessage(Message msg) { 96 public void handleMessage(Message msg) {
105 super.handleMessage(msg); 97 super.handleMessage(msg);
@@ -111,7 +103,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi @@ -111,7 +103,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi
111 @Override 103 @Override
112 public void onDestroy() { 104 public void onDestroy() {
113 super.onDestroy(); 105 super.onDestroy();
114 - if (handler!=null)handler=null; 106 + if (handler != null) handler = null;
115 } 107 }
116 108
117 private class MyFragmentAdapter extends FragmentPagerAdapter { 109 private class MyFragmentAdapter extends FragmentPagerAdapter {
app/src/main/java/com/shunzhi/parent/ui/fragment/report/ReportSceneFragment.java
1 package com.shunzhi.parent.ui.fragment.report; 1 package com.shunzhi.parent.ui.fragment.report;
2 2
3 -import android.annotation.SuppressLint;  
4 import android.content.res.Resources; 3 import android.content.res.Resources;
5 import android.os.Bundle; 4 import android.os.Bundle;
6 import android.support.annotation.NonNull; 5 import android.support.annotation.NonNull;
7 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
8 import android.support.v7.widget.LinearLayoutManager; 7 import android.support.v7.widget.LinearLayoutManager;
9 import android.support.v7.widget.RecyclerView; 8 import android.support.v7.widget.RecyclerView;
  9 +import android.util.Log;
10 import android.view.View; 10 import android.view.View;
11 import android.widget.TextView; 11 import android.widget.TextView;
12 12
@@ -77,6 +77,11 @@ public class ReportSceneFragment extends BaseMVPCompatFragment&lt;ReportSceneContra @@ -77,6 +77,11 @@ public class ReportSceneFragment extends BaseMVPCompatFragment&lt;ReportSceneContra
77 77
78 @Override 78 @Override
79 public void showChart(List<ChatBean> list1, List<ChatBean> list2, List<ChatBean> list3) { 79 public void showChart(List<ChatBean> list1, List<ChatBean> list2, List<ChatBean> list3) {
  80 + Log.e("11111", "1111----====");
  81 + if(list1==null||list2==null||list3==null) {
  82 + Log.e("11111", "----====");
  83 + return ;
  84 + }
80 chartView.setColors(R.color.textColor, R.color.huodong_blue, R.color.gray); 85 chartView.setColors(R.color.textColor, R.color.huodong_blue, R.color.gray);
81 List<InputData> inputDataList1 = new ArrayList<>(); 86 List<InputData> inputDataList1 = new ArrayList<>();
82 List<InputData> inputDataList2 = new ArrayList<>(); 87 List<InputData> inputDataList2 = new ArrayList<>();
mvpsdk/src/main/java/com/share/mvpsdk/utils/ValueUtils.java
@@ -3,8 +3,6 @@ package com.share.mvpsdk.utils; @@ -3,8 +3,6 @@ package com.share.mvpsdk.utils;
3 import android.support.annotation.NonNull; 3 import android.support.annotation.NonNull;
4 import android.support.annotation.Nullable; 4 import android.support.annotation.Nullable;
5 import android.support.v4.app.NotificationCompat; 5 import android.support.v4.app.NotificationCompat;
6 -import android.util.Log;  
7 -  
8 6
9 import com.share.mvpsdk.view.chartview.data.Chart; 7 import com.share.mvpsdk.view.chartview.data.Chart;
10 import com.share.mvpsdk.view.chartview.data.ChartPath; 8 import com.share.mvpsdk.view.chartview.data.ChartPath;
@@ -14,12 +12,11 @@ import com.share.mvpsdk.view.chartview.data.InputData; @@ -14,12 +12,11 @@ import com.share.mvpsdk.view.chartview.data.InputData;
14 import java.util.ArrayList; 12 import java.util.ArrayList;
15 import java.util.List; 13 import java.util.List;
16 import java.util.ListIterator; 14 import java.util.ListIterator;
17 -import java.util.concurrent.TimeUnit;  
18 15
19 public class ValueUtils { 16 public class ValueUtils {
20 17
21 - public static long getCorrectedMaxValue(long maxValue) {  
22 - for (long value = maxValue; value >= Chart.CHART_PART_VALUE; value--) { 18 + public static float getCorrectedMaxValue(float maxValue) {
  19 + for (float value = maxValue; value >= Chart.CHART_PART_VALUE; value--) {
23 if (isRightValue(value)) { 20 if (isRightValue(value)) {
24 return value; 21 return value;
25 } 22 }
@@ -28,8 +25,8 @@ public class ValueUtils { @@ -28,8 +25,8 @@ public class ValueUtils {
28 return maxValue; 25 return maxValue;
29 } 26 }
30 27
31 - public static long max(@Nullable List<ChartPath> dataList) {  
32 - long maxValue = 0; 28 + public static float max(@Nullable List<ChartPath> dataList) {
  29 + float maxValue = 0;
33 30
34 if (dataList == null || dataList.isEmpty()) { 31 if (dataList == null || dataList.isEmpty()) {
35 return maxValue; 32 return maxValue;
@@ -46,29 +43,42 @@ public class ValueUtils { @@ -46,29 +43,42 @@ public class ValueUtils {
46 return maxValue; 43 return maxValue;
47 } 44 }
48 45
49 - private static long maxOne(List<InputData> dataList) {  
50 - long maxValue = 0; 46 + private static long getMax(long max) {
  47 + if (max < 10) {
  48 + max = 10;
  49 + } else if (max / 10 < 10) {
  50 + max = (max / 10 + 1) * 10;
  51 + } else if (max / 100 < 10) {
  52 + max = (max / 100 + 1) * 100;
  53 + } else if (max / 1000 < 10) {
  54 + max = (max / 1000 + 1) * 1000;
  55 + }
  56 + return max;
  57 + }
  58 +
  59 + private static float maxOne(List<InputData> dataList) {
  60 + float maxValue = 0;
51 61
52 if (dataList == null || dataList.isEmpty()) { 62 if (dataList == null || dataList.isEmpty()) {
53 return maxValue; 63 return maxValue;
54 } 64 }
55 - for (InputData data : dataList) {  
56 - if (data.valueY > maxValue) {  
57 - maxValue = data.valueY;  
58 - } 65 + for (InputData data : dataList) {
  66 + if (data.valueY > maxValue) {
  67 + maxValue = data.valueY;
59 } 68 }
  69 + }
60 70
61 return maxValue; 71 return maxValue;
62 } 72 }
63 73
64 - private static boolean isRightValue(long value) {  
65 - long valueResidual = value % Chart.CHART_PART_VALUE; 74 + private static boolean isRightValue(float value) {
  75 + float valueResidual = value % Chart.CHART_PART_VALUE;
66 return valueResidual == 0; 76 return valueResidual == 0;
67 } 77 }
68 78
69 @NotificationCompat.NotificationVisibility 79 @NotificationCompat.NotificationVisibility
70 public static List<DrawData> getDrawData(@Nullable Chart chart) { 80 public static List<DrawData> getDrawData(@Nullable Chart chart) {
71 - if (chart == null || chart.getInputDataList().isEmpty()) { 81 + if (chart == null || chart.getInputDataList()==null||chart.getInputDataList().isEmpty()) {
72 return new ArrayList<>(); 82 return new ArrayList<>();
73 } 83 }
74 84
@@ -78,7 +88,7 @@ public class ValueUtils { @@ -78,7 +88,7 @@ public class ValueUtils {
78 } 88 }
79 89
80 @NotificationCompat.NotificationVisibility 90 @NotificationCompat.NotificationVisibility
81 - public static List<DrawData> getDrawDatas(@Nullable List<InputData> inputDataList,@NonNull Chart chart) { 91 + public static List<DrawData> getDrawDatas(@Nullable List<InputData> inputDataList, @NonNull Chart chart) {
82 return createDrawDataList(chart, createValueList(inputDataList)); 92 return createDrawDataList(chart, createValueList(inputDataList));
83 } 93 }
84 94
@@ -111,13 +121,22 @@ public class ValueUtils { @@ -111,13 +121,22 @@ public class ValueUtils {
111 iterator.next(); 121 iterator.next();
112 } 122 }
113 } 123 }
114 - static long topValue=0; 124 +
  125 + public static float topValue = 0.00f;
  126 +
  127 + public static void calMax(List<ChartPath> chartPathList) {
  128 +
  129 + for (int i = 0; i < chartPathList.size(); i++) {
  130 + createValueList(chartPathList.get(i).inputDataList);
  131 + }
  132 + }
  133 +
115 private static List<Float> createValueList(@NonNull List<InputData> dataList) { 134 private static List<Float> createValueList(@NonNull List<InputData> dataList) {
116 List<Float> valueList = new ArrayList<>(); 135 List<Float> valueList = new ArrayList<>();
117 - topValue=topValue > ValueUtils.maxOne(dataList)?topValue:ValueUtils.maxOne(dataList);//取最大值 136 + topValue = topValue > ValueUtils.maxOne(dataList) ? topValue : ValueUtils.maxOne(dataList);//取最大值
118 137
119 for (InputData data : dataList) { 138 for (InputData data : dataList) {
120 - float value = (float) data.valueY / topValue; 139 + float value = data.valueY / topValue;
121 valueList.add(value); 140 valueList.add(value);
122 } 141 }
123 142
@@ -142,8 +161,8 @@ public class ValueUtils { @@ -142,8 +161,8 @@ public class ValueUtils {
142 } 161 }
143 162
144 float value = valueList.get(position); 163 float value = valueList.get(position);
145 - int startX = getCoordinateX(chart, position);  
146 - int startY = getCoordinateY(chart, value); 164 + float startX = getCoordinateX(chart, position);
  165 + float startY = getCoordinateY(chart, value);
147 drawData.startX = startX; 166 drawData.startX = startX;
148 drawData.startY = startY; 167 drawData.startY = startY;
149 // drawData.setStartX(startX); 168 // drawData.setStartX(startX);
@@ -151,8 +170,8 @@ public class ValueUtils { @@ -151,8 +170,8 @@ public class ValueUtils {
151 int nextPosition = position + 1; 170 int nextPosition = position + 1;
152 if (nextPosition < valueList.size()) { 171 if (nextPosition < valueList.size()) {
153 float nextValue = valueList.get(nextPosition); 172 float nextValue = valueList.get(nextPosition);
154 - int stopX = getCoordinateX(chart, nextPosition);  
155 - int stopY = getCoordinateY(chart, nextValue); 173 + float stopX = getCoordinateX(chart, nextPosition);
  174 + float stopY = getCoordinateY(chart, nextValue);
156 175
157 // drawData.setStopX(stopX); 176 // drawData.setStopX(stopX);
158 // drawData.setStopY(stopY); 177 // drawData.setStopY(stopY);
@@ -165,13 +184,13 @@ public class ValueUtils { @@ -165,13 +184,13 @@ public class ValueUtils {
165 } 184 }
166 185
167 @SuppressWarnings("UnnecessaryLocalVariable") 186 @SuppressWarnings("UnnecessaryLocalVariable")
168 - private static int getCoordinateX(@NonNull Chart chart, int index) {  
169 - int width = chart.width;  
170 - int titleWidth = chart.titleWidth; 187 + private static float getCoordinateX(@NonNull Chart chart, int index) {
  188 + float width = chart.width;
  189 + float titleWidth = chart.titleWidth;
171 190
172 - int widthCorrected = width - titleWidth;  
173 - int partWidth = widthCorrected / (Chart.MAX_ITEMS_COUNT - 1);  
174 - int coordinate = titleWidth + (partWidth * index); 191 + float widthCorrected = width - titleWidth;
  192 + float partWidth = widthCorrected / (Chart.MAX_ITEMS_COUNT - 1);
  193 + float coordinate = titleWidth + (partWidth * index);
175 194
176 if (coordinate < 0) { 195 if (coordinate < 0) {
177 coordinate = 0; 196 coordinate = 0;
@@ -184,13 +203,11 @@ public class ValueUtils { @@ -184,13 +203,11 @@ public class ValueUtils {
184 } 203 }
185 204
186 @SuppressWarnings("UnnecessaryLocalVariable") 205 @SuppressWarnings("UnnecessaryLocalVariable")
187 - private static int getCoordinateY(@NonNull Chart chart, float value) {  
188 - int height = chart.height - chart.padding - chart.textSize;  
189 - int heightOffset = chart.heightOffset;  
190 -  
191 - int heightCorrected = height - heightOffset;  
192 - int coordinate = (int) (heightCorrected - (heightCorrected * value));  
193 - 206 + private static float getCoordinateY(@NonNull Chart chart, float value) {
  207 + float height = chart.height - chart.padding - chart.textSize;
  208 + float heightOffset = chart.heightOffset;
  209 + float heightCorrected = height - heightOffset;
  210 + float coordinate = (heightCorrected - (heightCorrected * value));
194 if (coordinate < 0) { 211 if (coordinate < 0) {
195 coordinate = 0; 212 coordinate = 0;
196 213
@@ -201,4 +218,5 @@ public class ValueUtils { @@ -201,4 +218,5 @@ public class ValueUtils {
201 coordinate += heightOffset; 218 coordinate += heightOffset;
202 return coordinate; 219 return coordinate;
203 } 220 }
  221 +
204 } 222 }
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/ChartView.java
@@ -2,13 +2,9 @@ package com.share.mvpsdk.view.chartview; @@ -2,13 +2,9 @@ package com.share.mvpsdk.view.chartview;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.graphics.Canvas; 4 import android.graphics.Canvas;
5 -import android.graphics.Color;  
6 -import android.graphics.DashPathEffect;  
7 import android.graphics.Paint; 5 import android.graphics.Paint;
8 import android.graphics.Path; 6 import android.graphics.Path;
9 import android.graphics.PathDashPathEffect; 7 import android.graphics.PathDashPathEffect;
10 -import android.graphics.RectF;  
11 -import android.graphics.Shader;  
12 import android.support.annotation.NonNull; 8 import android.support.annotation.NonNull;
13 import android.support.annotation.Nullable; 9 import android.support.annotation.Nullable;
14 import android.util.AttributeSet; 10 import android.util.AttributeSet;
@@ -16,13 +12,13 @@ import android.util.Log; @@ -16,13 +12,13 @@ import android.util.Log;
16 import android.view.View; 12 import android.view.View;
17 13
18 import com.share.mvpsdk.R; 14 import com.share.mvpsdk.R;
19 -import com.share.mvpsdk.utils.DateUtils;  
20 import com.share.mvpsdk.utils.ValueUtils; 15 import com.share.mvpsdk.utils.ValueUtils;
21 import com.share.mvpsdk.view.chartview.data.Chart; 16 import com.share.mvpsdk.view.chartview.data.Chart;
22 import com.share.mvpsdk.view.chartview.data.ChartPath; 17 import com.share.mvpsdk.view.chartview.data.ChartPath;
23 import com.share.mvpsdk.view.chartview.data.DrawData; 18 import com.share.mvpsdk.view.chartview.data.DrawData;
24 import com.share.mvpsdk.view.chartview.data.InputData; 19 import com.share.mvpsdk.view.chartview.data.InputData;
25 20
  21 +import java.text.DecimalFormat;
26 import java.util.ArrayList; 22 import java.util.ArrayList;
27 import java.util.List; 23 import java.util.List;
28 24
@@ -97,7 +93,11 @@ public class ChartView extends View { @@ -97,7 +93,11 @@ public class ChartView extends View {
97 chart.setInputDataList(inputData); 93 chart.setInputDataList(inputData);
98 chart.titleWidth = getTitleWidth(); 94 chart.titleWidth = getTitleWidth();
99 invalidate(); 95 invalidate();
  96 + }
100 97
  98 + public void setDrawData(){
  99 +// chart.setDrawDataList(ValueUtils.getDrawData(chart));
  100 + invalidate();
101 } 101 }
102 102
103 /** 103 /**
@@ -163,11 +163,11 @@ public class ChartView extends View { @@ -163,11 +163,11 @@ public class ChartView extends View {
163 return; 163 return;
164 } 164 }
165 165
166 - long maxValue = ValueUtils.max(chartPathList);  
167 - long correctedMaxValue = ValueUtils.getCorrectedMaxValue(maxValue); 166 + float maxValue = ValueUtils.max(chartPathList);
  167 + float correctedMaxValue = ValueUtils.getCorrectedMaxValue(maxValue);
168 float value = (float) correctedMaxValue / maxValue; 168 float value = (float) correctedMaxValue / maxValue;
169 169
170 - long heightOffset = chart.heightOffset; 170 + float heightOffset = chart.heightOffset;
171 int padding = chart.padding; 171 int padding = chart.padding;
172 int textSize = chart.textSize; 172 int textSize = chart.textSize;
173 int titleWidth = chart.titleWidth; 173 int titleWidth = chart.titleWidth;
@@ -177,7 +177,7 @@ public class ChartView extends View { @@ -177,7 +177,7 @@ public class ChartView extends View {
177 float chartPartHeight = ((height - heightOffset) * value) / Chart.CHART_PARTS; 177 float chartPartHeight = ((height - heightOffset) * value) / Chart.CHART_PARTS;
178 178
179 float currHeight = height; 179 float currHeight = height;
180 - int currTitle = 0; 180 + float currTitle = 0.0f;
181 181
182 for (int i = 0; i <= Chart.CHART_PARTS; i++) { 182 for (int i = 0; i <= Chart.CHART_PARTS; i++) {
183 float titleY = currHeight; 183 float titleY = currHeight;
@@ -192,12 +192,13 @@ public class ChartView extends View { @@ -192,12 +192,13 @@ public class ChartView extends View {
192 if (i > 0) { 192 if (i > 0) {
193 // canvas.drawLine(titleWidth, currHeight, width, currHeight, frameInternalPaint); 193 // canvas.drawLine(titleWidth, currHeight, width, currHeight, frameInternalPaint);
194 //横向间隔线 194 //横向间隔线
195 - canvas.drawLine(titleWidth-5,titleY-textSize/2,width,titleY-textSize/2,textPaint); 195 + textPaint.setColor(0xFFE7E5E7);
  196 + canvas.drawLine(titleWidth - 5, titleY - textSize / 2, width, titleY - textSize / 2, textPaint);
196 } 197 }
197 -  
198 - String title = String.valueOf(currTitle);  
199 - canvas.drawText(title, padding, titleY, textPaint); 198 + DecimalFormat decimalFormat = new DecimalFormat("0.0");
  199 + String title = String.valueOf(decimalFormat.format(currTitle));
200 textPaint.setColor(getResources().getColor(R.color.gray)); 200 textPaint.setColor(getResources().getColor(R.color.gray));
  201 + canvas.drawText(title, padding - textSize / 2, titleY, textPaint);
201 202
202 currHeight -= chartPartHeight; 203 currHeight -= chartPartHeight;
203 currTitle += correctedMaxValue / Chart.CHART_PARTS; 204 currTitle += correctedMaxValue / Chart.CHART_PARTS;
@@ -205,11 +206,15 @@ public class ChartView extends View { @@ -205,11 +206,15 @@ public class ChartView extends View {
205 } 206 }
206 207
207 private void drawChartHorizontal(@NonNull Canvas canvas) { 208 private void drawChartHorizontal(@NonNull Canvas canvas) {
  209 + if (null!=chartPathList){
  210 + ValueUtils.calMax(chartPathList);
208 for (int j = 0; j < chartPathList.size(); j++) { 211 for (int j = 0; j < chartPathList.size(); j++) {
209 chagerColor(j); 212 chagerColor(j);
210 List<InputData> inputDataList = chart.getInputDataList(); 213 List<InputData> inputDataList = chart.getInputDataList();
211 // List<DrawData> drawDataList = chart.getDrawDataList(); 214 // List<DrawData> drawDataList = chart.getDrawDataList();
212 List<DrawData> drawDataList = ValueUtils.getDrawDatas(chartPathList.get(j).inputDataList, chart); 215 List<DrawData> drawDataList = ValueUtils.getDrawDatas(chartPathList.get(j).inputDataList, chart);
  216 +// Log.e("111111", "chartPathList.get(j).inputDataList----===="+chartPathList.get(j).inputDataList);
  217 +// Log.e("111111", "drawDataList----===="+drawDataList);
213 if (inputDataList == null || inputDataList.isEmpty() || drawDataList == null || drawDataList.isEmpty()) { 218 if (inputDataList == null || inputDataList.isEmpty() || drawDataList == null || drawDataList.isEmpty()) {
214 return; 219 return;
215 } 220 }
@@ -219,7 +224,7 @@ public class ChartView extends View { @@ -219,7 +224,7 @@ public class ChartView extends View {
219 // String date = DateUtils.format(inputData.valueX); 224 // String date = DateUtils.format(inputData.valueX);
220 String date = inputData.valueX; 225 String date = inputData.valueX;
221 int dateWidth = (int) axisPaint.measureText(date); 226 int dateWidth = (int) axisPaint.measureText(date);
222 - int x; 227 + float x;
223 if (drawDataList.size() > i) { 228 if (drawDataList.size() > i) {
224 DrawData drawData = drawDataList.get(i); 229 DrawData drawData = drawDataList.get(i);
225 x = drawData.startX; 230 x = drawData.startX;
@@ -246,7 +251,7 @@ public class ChartView extends View { @@ -246,7 +251,7 @@ public class ChartView extends View {
246 251
247 //画圆点 252 //画圆点
248 canvas.drawCircle(startX, startY, 10, valuesPaint); 253 canvas.drawCircle(startX, startY, 10, valuesPaint);
249 - 254 + Log.e("11111", "startX----===="+startX+"startY="+startY);
250 //点之间的连线 255 //点之间的连线
251 if (i < drawDataList.size() - 1) { 256 if (i < drawDataList.size() - 1) {
252 canvas.drawLine(startX, startY, drawDataList.get(i + 1).startX - chart.padding - chart.textSize, drawDataList.get(i + 1).startY, valuesPaint); 257 canvas.drawLine(startX, startY, drawDataList.get(i + 1).startX - chart.padding - chart.textSize, drawDataList.get(i + 1).startY, valuesPaint);
@@ -257,10 +262,11 @@ public class ChartView extends View { @@ -257,10 +262,11 @@ public class ChartView extends View {
257 } 262 }
258 } 263 }
259 } 264 }
  265 + }
260 } 266 }
261 267
262 private void chagerColor(int j) { 268 private void chagerColor(int j) {
263 - switch (j){ 269 + switch (j) {
264 case 0: 270 case 0:
265 valuesPaint.setColor(getResources().getColor(R.color.theme_day_blue)); 271 valuesPaint.setColor(getResources().getColor(R.color.theme_day_blue));
266 break; 272 break;
@@ -280,7 +286,7 @@ public class ChartView extends View { @@ -280,7 +286,7 @@ public class ChartView extends View {
280 286
281 int height = chart.height - textSize - padding; 287 int height = chart.height - textSize - padding;
282 int width = chart.width - textSize - padding; 288 int width = chart.width - textSize - padding;
283 - int titleWidth = chart.titleWidth-5; 289 + int titleWidth = chart.titleWidth - 5;
284 int heightOffset = chart.heightOffset; 290 int heightOffset = chart.heightOffset;
285 291
286 canvas.drawLine(titleWidth, heightOffset, titleWidth, height, axisPaint); 292 canvas.drawLine(titleWidth, heightOffset, titleWidth, height, axisPaint);
@@ -292,7 +298,7 @@ public class ChartView extends View { @@ -292,7 +298,7 @@ public class ChartView extends View {
292 super.onMeasure(widthMeasureSpec, heightMeasureSpec); 298 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
293 299
294 int width = MeasureSpec.getSize(widthMeasureSpec); 300 int width = MeasureSpec.getSize(widthMeasureSpec);
295 - int height = MeasureSpec.getSize(heightMeasureSpec) / 2; 301 + int height = MeasureSpec.getSize(heightMeasureSpec);
296 chart.width = width; 302 chart.width = width;
297 chart.height = height; 303 chart.height = height;
298 setMeasuredDimension(width, height); 304 setMeasuredDimension(width, height);
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/Chart.java
@@ -9,7 +9,7 @@ import java.util.List; @@ -9,7 +9,7 @@ import java.util.List;
9 9
10 public class Chart { 10 public class Chart {
11 11
12 - public static final int CHART_PARTS = 5; 12 + public static final float CHART_PARTS = 5.0f;
13 public static final int MAX_ITEMS_COUNT = 7; 13 public static final int MAX_ITEMS_COUNT = 7;
14 public static final int CHART_PART_VALUE = 10; 14 public static final int CHART_PART_VALUE = 10;
15 public static final int TEXT_SIZE_OFFSET = 10; 15 public static final int TEXT_SIZE_OFFSET = 10;
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/DrawData.java
@@ -6,11 +6,11 @@ package com.share.mvpsdk.view.chartview.data; @@ -6,11 +6,11 @@ package com.share.mvpsdk.view.chartview.data;
6 6
7 public class DrawData { 7 public class DrawData {
8 8
9 - public int startX;  
10 - public int startY; 9 + public float startX;
  10 + public float startY;
11 11
12 - public int stopX;  
13 - public int stopY; 12 + public float stopX;
  13 + public float stopY;
14 14
15 @Override 15 @Override
16 public String toString() { 16 public String toString() {
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/InputData.java
@@ -9,9 +9,9 @@ public class InputData { @@ -9,9 +9,9 @@ public class InputData {
9 9
10 public String valueX; 10 public String valueX;
11 11
12 - public long valueY; 12 + public float valueY;
13 13
14 - public InputData(String valueX,long valueY){ 14 + public InputData(String valueX,float valueY){
15 this.valueX=valueX; 15 this.valueX=valueX;
16 this.valueY=valueY; 16 this.valueY=valueY;
17 } 17 }