Skip to content

Commit b677b20

Browse files
committed
Cleanup code
1 parent 434a1b0 commit b677b20

18 files changed

+47
-102
lines changed

app/src/main/java/info/appdev/chartexample/DynamicalAddingActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void addEntry() {
7777

7878
int cycleValue = (int) (lastSet.getEntryCount() % 100.0);
7979

80-
float value = (float) (sampleValues[cycleValue].floatValue() * 50) + 50f * (lastDataSetIndex + 1);
80+
float value = (sampleValues[cycleValue].floatValue() * 50) + 50f * (lastDataSetIndex + 1);
8181

8282
data.addEntry(new Entry(lastSet.getEntryCount(), value), lastDataSetIndex);
8383
data.notifyDataChanged();
@@ -130,7 +130,7 @@ private void addDataSet() {
130130
for (int i = 0; i < amount; i++) {
131131
int cycleValue = (int) (i % 100.0);
132132

133-
values.add(new Entry(i, (float) (sampleValues[cycleValue].floatValue() * 50f) + 50f * count));
133+
values.add(new Entry(i, (sampleValues[cycleValue].floatValue() * 50f) + 50f * count));
134134
}
135135

136136
LineDataSet set = new LineDataSet(values, "DataSet " + count);

app/src/main/java/info/appdev/chartexample/FilledLineActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ private void setData(float range) {
8686
Double[] sampleValues = DataTools.Companion.getValues(count + 2);
8787

8888
for (int i = 0; i < count; i++) {
89-
float val = (float) (sampleValues[i].floatValue() * range) + 50;
89+
float val = (sampleValues[i].floatValue() * range) + 50;
9090
values1.add(new Entry(i, val));
9191
}
9292

9393
ArrayList<Entry> values2 = new ArrayList<>();
9494

9595
for (int i = 0; i < count; i++) {
96-
float val = (float) (sampleValues[i+1].floatValue() * range) + 450;
96+
float val = (sampleValues[i+1].floatValue() * range) + 450;
9797
values2.add(new Entry(i, val));
9898
}
9999

app/src/main/java/info/appdev/chartexample/HalfPieChartActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void setData(float range) {
9797
Double[] sampleValues = DataTools.Companion.getValues(count);
9898

9999
for (int i = 0; i < count; i++) {
100-
values.add(new PieEntry((float) ((sampleValues[i].floatValue() * range) + range / 5), parties[i % parties.length]));
100+
values.add(new PieEntry((sampleValues[i].floatValue() * range) + range / 5, parties[i % parties.length]));
101101
}
102102

103103
PieDataSet dataSet = new PieDataSet(values, "Election Results");

app/src/main/java/info/appdev/chartexample/HorizontalBarChartActivity.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void setData(int count, float range) {
126126
Double[] sampleValues = DataTools.Companion.getValues(100);
127127

128128
for (int i = 0; i < count; i++) {
129-
float val = (float) (sampleValues[i].floatValue() * range);
129+
float val = sampleValues[i].floatValue() * range;
130130
values.add(new BarEntry(i * spaceForBar, val,
131131
getResources().getDrawable(R.drawable.star)));
132132
}
@@ -201,10 +201,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
201201
break;
202202
}
203203
case R.id.actionTogglePinch: {
204-
if (chart.isPinchZoomEnabled())
205-
chart.setPinchZoom(false);
206-
else
207-
chart.setPinchZoom(true);
204+
chart.setPinchZoom(!chart.isPinchZoomEnabled());
208205

209206
chart.invalidate();
210207
break;

app/src/main/java/info/appdev/chartexample/HorizontalBarNegativeChartActivity.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void setData(int count, float range) {
126126
Double[] sampleValues = DataTools.Companion.getValues(count + 2);
127127

128128
for (int i = 0; i < count; i++) {
129-
float val = (float) (sampleValues[i].floatValue() * range - range / 2);
129+
float val = sampleValues[i].floatValue() * range - range / 2;
130130
values.add(new BarEntry(i * spaceForBar, val,
131131
getResources().getDrawable(R.drawable.star)));
132132
}
@@ -201,10 +201,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
201201
break;
202202
}
203203
case R.id.actionTogglePinch: {
204-
if (chart.isPinchZoomEnabled())
205-
chart.setPinchZoom(false);
206-
else
207-
chart.setPinchZoom(true);
204+
chart.setPinchZoom(!chart.isPinchZoomEnabled());
208205

209206
chart.invalidate();
210207
break;

app/src/main/java/info/appdev/chartexample/InvertedLineChartActivity.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ private void setData(int count, float range) {
123123
Double[] sampleValues = DataTools.Companion.getValues(count + 2);
124124

125125
for (int i = 0; i < count; i++) {
126-
float xVal = (float) (sampleValues[i].floatValue() * range);
127-
float yVal = (float) (sampleValues[i + 1].floatValue() * range);
126+
float xVal = sampleValues[i].floatValue() * range;
127+
float yVal = sampleValues[i + 1].floatValue() * range;
128128
entries.add(new Entry(xVal, yVal));
129129
}
130130

@@ -188,10 +188,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
188188
for (ILineDataSet iSet : sets) {
189189

190190
LineDataSet set = (LineDataSet) iSet;
191-
if (set.isDrawFilledEnabled())
192-
set.setDrawFilled(false);
193-
else
194-
set.setDrawFilled(true);
191+
set.setDrawFilled(!set.isDrawFilledEnabled());
195192
}
196193
chart.invalidate();
197194
break;
@@ -203,10 +200,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
203200
for (ILineDataSet iSet : sets) {
204201

205202
LineDataSet set = (LineDataSet) iSet;
206-
if (set.isDrawCirclesEnabled())
207-
set.setDrawCircles(false);
208-
else
209-
set.setDrawCircles(true);
203+
set.setDrawCircles(!set.isDrawCirclesEnabled());
210204
}
211205
chart.invalidate();
212206
break;
@@ -225,10 +219,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
225219
break;
226220
}
227221
case R.id.actionTogglePinch: {
228-
if (chart.isPinchZoomEnabled())
229-
chart.setPinchZoom(false);
230-
else
231-
chart.setPinchZoom(true);
222+
chart.setPinchZoom(!chart.isPinchZoomEnabled());
232223

233224
chart.invalidate();
234225
break;

app/src/main/java/info/appdev/chartexample/LineChartDualAxisActivity.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,21 @@ private void setData(int count, float range) {
140140
Double[] sampleValues = DataTools.Companion.getValues(count);
141141

142142
for (int i = 0; i < count; i++) {
143-
float val = (float) (sampleValues[i].floatValue() * (range / 2f)) + 50;
143+
float val = (sampleValues[i].floatValue() * (range / 2f)) + 50;
144144
values1.add(new Entry(i, val));
145145
}
146146

147147
ArrayList<Entry> values2 = new ArrayList<>();
148148

149149
for (int i = 0; i < count; i++) {
150-
float val = (float) (sampleValues[i].floatValue() * range) + 450;
150+
float val = (sampleValues[i].floatValue() * range) + 450;
151151
values2.add(new Entry(i, val));
152152
}
153153

154154
ArrayList<Entry> values3 = new ArrayList<>();
155155

156156
for (int i = 0; i < count; i++) {
157-
float val = (float) (sampleValues[i].floatValue() * range) + 500;
157+
float val = (sampleValues[i].floatValue() * range) + 500;
158158
values3.add(new Entry(i, val));
159159
}
160160

@@ -266,10 +266,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
266266
for (ILineDataSet iSet : sets) {
267267

268268
LineDataSet set = (LineDataSet) iSet;
269-
if (set.isDrawFilledEnabled())
270-
set.setDrawFilled(false);
271-
else
272-
set.setDrawFilled(true);
269+
set.setDrawFilled(!set.isDrawFilledEnabled());
273270
}
274271
chart.invalidate();
275272
break;
@@ -281,10 +278,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
281278
for (ILineDataSet iSet : sets) {
282279

283280
LineDataSet set = (LineDataSet) iSet;
284-
if (set.isDrawCirclesEnabled())
285-
set.setDrawCircles(false);
286-
else
287-
set.setDrawCircles(true);
281+
set.setDrawCircles(!set.isDrawCirclesEnabled());
288282
}
289283
chart.invalidate();
290284
break;
@@ -332,10 +326,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
332326
break;
333327
}
334328
case R.id.actionTogglePinch: {
335-
if (chart.isPinchZoomEnabled())
336-
chart.setPinchZoom(false);
337-
else
338-
chart.setPinchZoom(true);
329+
chart.setPinchZoom(!chart.isPinchZoomEnabled());
339330

340331
chart.invalidate();
341332
break;

app/src/main/java/info/appdev/chartexample/ListViewBarChartActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private BarData generateData(int cnt) {
142142
Double[] sampleValues = DataTools.Companion.getValues(count);
143143

144144
for (int i = 0; i < count; i++) {
145-
entries.add(new BarEntry(i, (float) (sampleValues[i].floatValue() * 70) + 30));
145+
entries.add(new BarEntry(i, (sampleValues[i].floatValue() * 70) + 30));
146146
}
147147

148148
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);

app/src/main/java/info/appdev/chartexample/ListViewMultiChartActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private PieData generateDataPie() {
176176
Double[] sampleValues = DataTools.Companion.getValues(cnt);
177177

178178
for (int i = 0; i < cnt; i++) {
179-
entries.add(new PieEntry((float) ((sampleValues[i].floatValue() * 70) + 30), "Quarter " + (i+1)));
179+
entries.add(new PieEntry((sampleValues[i].floatValue() * 70) + 30, "Quarter " + (i+1)));
180180
}
181181

182182
PieDataSet d = new PieDataSet(entries, "");

app/src/main/java/info/appdev/chartexample/PerformanceLineChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private void setData(int count, float range) {
7575
Double[] sampleValues = DataTools.Companion.getMuchValues(count);
7676

7777
for (int i = 0; i < count; i++) {
78-
float val = (float) (sampleValues[i].floatValue() * (range + 1)) + 3;
78+
float val = (sampleValues[i].floatValue() * (range + 1)) + 3;
7979
values.add(new Entry(i * 0.001f, val));
8080
}
8181

0 commit comments

Comments
 (0)