Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onLoadFinished(Loader<ArrayList<GraphObject>> loader,
- ArrayList<GraphObject> graphObjects) {
- if (graphObjects != null && !graphObjects.isEmpty()) {
- ArrayList<GraphObject> objects = new ArrayList<>(graphObjects);
- List<DataPoint> list = getDataPoint(graphObjects);
- LineGraphSeries<DataPoint> series = new LineGraphSeries<>
- (list.toArray(new DataPoint[1]));
- Log.e("Message", objects.get(0).getclose());
- graphView.addSeries(series);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("LLLyy");
- graphView.getGridLabelRenderer().setLabelFormatter(new
- DateAsXAxisLabelFormatter(this,simpleDateFormat));
- graphView.getGridLabelRenderer().setNumHorizontalLabels(3);
- graphView.getViewport().setMinX(list.get(0).getX());
- graphView.getViewport().setMaxX(list.get(list.size()-1).getX());
- graphView.getViewport().setXAxisBoundsManual(true);
- graphView.getGridLabelRenderer().setHumanRounding(false);
- }
- }
- private List<DataPoint> getDataPoint(ArrayList<GraphObject> graphObjects) {
- List<DataPoint> dataPoints = new ArrayList<>();
- for (GraphObject object : graphObjects) {
- String close_string = object.getclose();
- String string_time = object.getMtime();
- long time = Long.parseLong(string_time);
- time = time * 1000;
- Double close = Double.parseDouble(close_string);
- Date dateObject = new Date(time);
- dataPoints.add(new DataPoint(dateObject, close));
- }
- return dataPoints;
- }
Add Comment
Please, Sign In to add comment