From 2e027a577e333fee10f13b87e571006ff3fbe5d2 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Mon, 8 Jun 2020 10:51:35 +0200 Subject: [PATCH] Use List instead of ArrayList as parameters where possible --- .../java/im/dacer/androidcharts/BarView.java | 15 ++++++------ .../java/im/dacer/androidcharts/LineView.java | 23 ++++++++++--------- .../java/im/dacer/androidcharts/PieView.java | 5 ++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/AndroidCharts/src/main/java/im/dacer/androidcharts/BarView.java b/AndroidCharts/src/main/java/im/dacer/androidcharts/BarView.java index d4aba10..3fb89b5 100644 --- a/AndroidCharts/src/main/java/im/dacer/androidcharts/BarView.java +++ b/AndroidCharts/src/main/java/im/dacer/androidcharts/BarView.java @@ -8,6 +8,7 @@ import android.util.AttributeSet; import android.view.View; import java.util.ArrayList; +import java.util.List; /** * Created by Dacer on 11/11/13. @@ -19,8 +20,8 @@ public class BarView extends View { private final int TEXT_COLOR = Color.parseColor("#9B9A9B"); private final int BACKGROUND_COLOR = Color.parseColor("#F6F6F6"); private final int FOREGROUND_COLOR = Color.parseColor("#FC496D"); - private ArrayList percentList; - private ArrayList targetPercentList; + private List percentList; + private List targetPercentList; private Paint textPaint; private Paint bgPaint; private Paint fgPaint; @@ -30,7 +31,7 @@ public class BarView extends View { private boolean autoSetWidth = true; private int topMargin; private int bottomTextHeight; - private ArrayList bottomTextList = new ArrayList(); + private List bottomTextList = new ArrayList(); private Runnable animator = new Runnable() { @Override public void run() { boolean needNewFrame = false; @@ -82,9 +83,9 @@ public BarView(Context context, AttributeSet attrs) { /** * dataList will be reset when called is method. * - * @param bottomStringList The String ArrayList in the bottom. + * @param bottomStringList The String List in the bottom. */ - public void setBottomTextList(ArrayList bottomStringList) { + public void setBottomTextList(List bottomStringList) { // this.dataList = null; this.bottomTextList = bottomStringList; Rect r = new Rect(); @@ -107,9 +108,9 @@ public void setBottomTextList(ArrayList bottomStringList) { } /** - * @param list The ArrayList of Integer with the range of [0-max]. + * @param list The List of Integer with the range of [0-max]. */ - public void setDataList(ArrayList list, int max) { + public void setDataList(List list, int max) { targetPercentList = new ArrayList(); if (max == 0) max = 1; diff --git a/AndroidCharts/src/main/java/im/dacer/androidcharts/LineView.java b/AndroidCharts/src/main/java/im/dacer/androidcharts/LineView.java index 109f83d..889a270 100644 --- a/AndroidCharts/src/main/java/im/dacer/androidcharts/LineView.java +++ b/AndroidCharts/src/main/java/im/dacer/androidcharts/LineView.java @@ -18,6 +18,7 @@ import android.view.View; import java.util.ArrayList; import java.util.Collections; +import java.util.List; /** * Created by Dacer on 11/4/13. @@ -48,11 +49,11 @@ public class LineView extends View { private boolean autoSetGridWidth = true; private int dataOfAGird = 10; private int bottomTextHeight = 0; - private ArrayList bottomTextList = new ArrayList(); - private ArrayList> dataLists; - private ArrayList xCoordinateList = new ArrayList(); - private ArrayList yCoordinateList = new ArrayList(); - private ArrayList> drawDotLists = new ArrayList>(); + private List bottomTextList = new ArrayList(); + private List> dataLists; + private List xCoordinateList = new ArrayList(); + private List yCoordinateList = new ArrayList(); + private List> drawDotLists = new ArrayList>(); private Paint bottomTextPaint = new Paint(); private int bottomTextDescent; private Paint popupTextPaint = new Paint(); @@ -128,9 +129,9 @@ public void setColorArray(int[] colors) { /** * dataList will be reset when called is method. * - * @param bottomTextList The String ArrayList in the bottom. + * @param bottomTextList The String List in the bottom. */ - public void setBottomTextList(ArrayList bottomTextList) { + public void setBottomTextList(List bottomTextList) { this.bottomTextList = bottomTextList; Rect r = new Rect(); @@ -165,14 +166,14 @@ public void setBottomTextList(ArrayList bottomTextList) { } /** - * @param dataLists The Float ArrayLists for showing, + * @param dataLists The Float Lists for showing, * dataList.size() must be smaller than bottomTextList.size() */ - public void setFloatDataList(ArrayList> dataLists) { + public void setFloatDataList(List> dataLists) { setFloatDataList(dataLists, true); } - public void setDataList(ArrayList> dataLists) { + public void setDataList(List> dataLists) { ArrayList> newList = new ArrayList<>(); for (ArrayList list : dataLists) { ArrayList tempList = new ArrayList<>(); @@ -184,7 +185,7 @@ public void setDataList(ArrayList> dataLists) { setFloatDataList(newList, false); } - public void setFloatDataList(ArrayList> dataLists, + public void setFloatDataList(List> dataLists, boolean showFloatNumInPopup) { selectedDot = null; this.showFloatNumInPopup = showFloatNumInPopup; diff --git a/AndroidCharts/src/main/java/im/dacer/androidcharts/PieView.java b/AndroidCharts/src/main/java/im/dacer/androidcharts/PieView.java index af6b8cc..da94002 100644 --- a/AndroidCharts/src/main/java/im/dacer/androidcharts/PieView.java +++ b/AndroidCharts/src/main/java/im/dacer/androidcharts/PieView.java @@ -10,6 +10,7 @@ import android.view.MotionEvent; import android.view.View; import java.util.ArrayList; +import java.util.List; /** * Created by Dacer on 9/26/14. @@ -85,7 +86,7 @@ public void setOnPieClickListener(OnPieClickListener listener) { onPieClickListener = listener; } - public void setDate(ArrayList helperList) { + public void setDate(List helperList) { initPies(helperList); pieHelperList.clear(); removeSelectedPie(); @@ -110,7 +111,7 @@ public void setDate(ArrayList helperList) { /** * Set startDegree and endDegree for each PieHelper */ - private void initPies(ArrayList helperList) { + private void initPies(List helperList) { float totalAngel = 270; for (PieHelper pie : helperList) { pie.setDegree(totalAngel, totalAngel + pie.getSweep());