Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
6
600SeriesAndroidUploader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cgm
uploader
600SeriesAndroidUploader
Commits
9c35bd9f
Commit
9c35bd9f
authored
8 years ago
by
Volker Richert
Browse files
Options
Downloads
Patches
Plain Diff
fix colored point "bug" by using anonymous class & some origial code
parent
7e4682b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/info/nightscout/android/medtronic/MainActivity.java
+67
-8
67 additions, 8 deletions
.../java/info/nightscout/android/medtronic/MainActivity.java
with
67 additions
and
8 deletions
app/src/main/java/info/nightscout/android/medtronic/MainActivity.java
+
67
−
8
View file @
9c35bd9f
...
@@ -10,6 +10,7 @@ import android.content.Intent;
...
@@ -10,6 +10,7 @@ import android.content.Intent;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.hardware.usb.UsbDevice
;
import
android.hardware.usb.UsbDevice
;
import
android.hardware.usb.UsbManager
;
import
android.hardware.usb.UsbManager
;
...
@@ -51,6 +52,9 @@ import com.github.mikephil.charting.formatter.IValueFormatter;
...
@@ -51,6 +52,9 @@ import com.github.mikephil.charting.formatter.IValueFormatter;
import
com.github.mikephil.charting.interfaces.datasets.IScatterDataSet
;
import
com.github.mikephil.charting.interfaces.datasets.IScatterDataSet
;
import
com.github.mikephil.charting.listener.ChartTouchListener
;
import
com.github.mikephil.charting.listener.ChartTouchListener
;
import
com.github.mikephil.charting.listener.OnChartGestureListener
;
import
com.github.mikephil.charting.listener.OnChartGestureListener
;
import
com.github.mikephil.charting.renderer.ScatterChartRenderer
;
import
com.github.mikephil.charting.renderer.scatter.IShapeRenderer
;
import
com.github.mikephil.charting.utils.Transformer
;
import
com.github.mikephil.charting.utils.ViewPortHandler
;
import
com.github.mikephil.charting.utils.ViewPortHandler
;
import
com.mikepenz.google_material_typeface_library.GoogleMaterial
;
import
com.mikepenz.google_material_typeface_library.GoogleMaterial
;
import
com.mikepenz.materialdrawer.AccountHeaderBuilder
;
import
com.mikepenz.materialdrawer.AccountHeaderBuilder
;
...
@@ -96,7 +100,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
...
@@ -96,7 +100,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private
static
long
activePumpMac
;
private
static
long
activePumpMac
;
boolean
mEnableCgmService
=
true
;
boolean
mEnableCgmService
=
true
;
SharedPreferences
prefs
=
null
;
SharedPreferences
prefs
=
null
;
private
PumpInfo
mActivePump
;
private
PumpInfo
mActivePump
;
...
@@ -330,6 +333,56 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
...
@@ -330,6 +333,56 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
yAxis
.
setTextColor
(
Color
.
WHITE
);
yAxis
.
setTextColor
(
Color
.
WHITE
);
mChart
.
getLegend
().
setEnabled
(
false
);
// Hide the legend
mChart
.
getLegend
().
setEnabled
(
false
);
// Hide the legend
// TODO: remove if if "coloring bug" in MPAndroidChart is fixed
// see: https://github.com/PhilJay/MPAndroidChart/issues/2682
mChart
.
setRenderer
(
new
ScatterChartRenderer
(
mChart
,
mChart
.
getAnimator
(),
mChart
.
getViewPortHandler
())
{
float
[]
mPixelBuffer
=
new
float
[
2
];
@Override
protected
void
drawDataSet
(
Canvas
c
,
IScatterDataSet
dataSet
)
{
ViewPortHandler
viewPortHandler
=
mViewPortHandler
;
Transformer
trans
=
mChart
.
getTransformer
(
dataSet
.
getAxisDependency
());
float
phaseY
=
mAnimator
.
getPhaseY
();
IShapeRenderer
renderer
=
dataSet
.
getShapeRenderer
();
if
(
renderer
==
null
)
{
Log
.
i
(
"MISSING"
,
"There's no IShapeRenderer specified for ScatterDataSet"
);
return
;
}
int
max
=
(
int
)(
Math
.
min
(
Math
.
ceil
((
float
)
dataSet
.
getEntryCount
()
*
mAnimator
.
getPhaseX
()),
(
float
)
dataSet
.
getEntryCount
()));
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
Entry
e
=
dataSet
.
getEntryForIndex
(
i
);
mPixelBuffer
[
0
]
=
e
.
getX
();
mPixelBuffer
[
1
]
=
e
.
getY
()
*
phaseY
;
trans
.
pointValuesToPixel
(
mPixelBuffer
);
if
(!
viewPortHandler
.
isInBoundsRight
(
mPixelBuffer
[
0
]))
break
;
if
(!
viewPortHandler
.
isInBoundsLeft
(
mPixelBuffer
[
0
])
||
!
viewPortHandler
.
isInBoundsY
(
mPixelBuffer
[
1
]))
continue
;
mRenderPaint
.
setColor
(
dataSet
.
getColor
(
i
));
renderer
.
renderShape
(
c
,
dataSet
,
mViewPortHandler
,
mPixelBuffer
[
0
],
mPixelBuffer
[
1
],
mRenderPaint
);
}
}
});
}
}
@Override
@Override
...
@@ -783,6 +836,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
...
@@ -783,6 +836,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
pos
=
entries
.
size
();
pos
=
entries
.
size
();
entries
.
add
(
new
Entry
(
pumpStatus
.
getEventDate
().
getTime
(),
pumpStatus
.
getSgv
()));
entries
.
add
(
new
Entry
(
pumpStatus
.
getEventDate
().
getTime
(),
pumpStatus
.
getSgv
()));
//TODO: need to be configurable
if
(
sgv
<
80
)
if
(
sgv
<
80
)
colors
[
pos
]
=
Color
.
RED
;
colors
[
pos
]
=
Color
.
RED
;
else
if
(
sgv
<=
180
)
else
if
(
sgv
<=
180
)
...
@@ -795,11 +849,10 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
...
@@ -795,11 +849,10 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
if
(
mChart
.
getData
()
==
null
)
{
if
(
mChart
.
getData
()
==
null
)
{
mChart
.
setMinimumHeight
(
200
);
mChart
.
setMinimumHeight
(
200
);
ScatterDataSet
dataSet
=
new
ScatterDataSet
(
entries
,
null
);
ScatterDataSet
dataSet
=
new
ScatterDataSet
(
entries
,
null
);
//
dataSet.setColors(colors); // disabled tue to a bug(??) in MPAndroid Chart
dataSet
.
setColors
(
colors
);
// disabled tue to a bug(??) in MPAndroid Chart
dataSet
.
setColor
(
Color
.
LTGRAY
);
//
dataSet.setColor(Color.LTGRAY);
dataSet
.
setValueTextColor
(
Color
.
WHITE
);
dataSet
.
setValueTextColor
(
Color
.
WHITE
);
dataSet
.
setScatterShape
(
ScatterChart
.
ScatterShape
.
CIRCLE
);
dataSet
.
setScatterShape
(
ScatterChart
.
ScatterShape
.
CIRCLE
);
dataSet
.
setScatterShapeSize
(
7.2f
);
dataSet
.
setScatterShapeSize
(
7.2f
);
...
@@ -828,14 +881,20 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
...
@@ -828,14 +881,20 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
mChart
.
setData
(
lineData
);
mChart
.
setData
(
lineData
);
}
else
{
}
else
{
((
ScatterDataSet
)
mChart
.
getScatterData
().
getDataSets
().
get
(
0
)).
setValues
(
entries
);
((
ScatterDataSet
)
mChart
.
getScatterData
().
getDataSets
().
get
(
0
)).
setValues
(
entries
);
//((ScatterDataSet)mChart.getScatterData().getDataSets().get(0)).setColors(colors); // disabled tue to a bug(??) in MPAndroid Chart
((
ScatterDataSet
)
mChart
.
getScatterData
().
getDataSets
().
get
(
0
)).
setColors
(
colors
);
// disabled tue to a bug(??) in MPAndroid Chart
//dataSet.notifyDataSetChanged();
}
}
//TODO: make the display timespan configurable
//TODO: make the display timespan configurable
mChart
.
getXAxis
().
setAxisMaximum
(
System
.
currentTimeMillis
());
//long now = System.currentTimeMillis();
mChart
.
getXAxis
().
setAxisMinimum
(
mChart
.
getXAxis
().
getAxisMaximum
()
-
24
*
60
*
60
*
1000
);
//Log.d(TAG, "Graph limits: " + (new Date(now - 24 * 60 * 60 * 1000) + " - " + (new Date(now))));
//mChart.setVisibleXRangeMaximum(12);
//mChart.setVisibleXRangeMinimum(0);
//mChart.getXAxis().setAxisMaximum((now + 0*60*1000));
//mChart.getXAxis().setAxisMinimum(now - 35 * 60 * 1000);
//mChart.moveViewToX(now - 35*60*1000); // - 24 * 60 * 60 * 1000);
//mChart.invalidate();
mChart
.
postInvalidate
();
mChart
.
postInvalidate
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment