Guest User

Untitled

a guest
Jul 17th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. @Override
  2. public void onLoadFinished(Loader<ArrayList<GraphObject>> loader,
  3. ArrayList<GraphObject> graphObjects) {
  4.  
  5. if (graphObjects != null && !graphObjects.isEmpty()) {
  6. ArrayList<GraphObject> objects = new ArrayList<>(graphObjects);
  7. List<DataPoint> list = getDataPoint(graphObjects);
  8. LineGraphSeries<DataPoint> series = new LineGraphSeries<>
  9. (list.toArray(new DataPoint[1]));
  10. Log.e("Message", objects.get(0).getclose());
  11. graphView.addSeries(series);
  12.  
  13. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("LLLyy");
  14. graphView.getGridLabelRenderer().setLabelFormatter(new
  15. DateAsXAxisLabelFormatter(this,simpleDateFormat));
  16. graphView.getGridLabelRenderer().setNumHorizontalLabels(3);
  17.  
  18. graphView.getViewport().setMinX(list.get(0).getX());
  19. graphView.getViewport().setMaxX(list.get(list.size()-1).getX());
  20. graphView.getViewport().setXAxisBoundsManual(true);
  21. graphView.getGridLabelRenderer().setHumanRounding(false);
  22. }
  23.  
  24. }
  25.  
  26. private List<DataPoint> getDataPoint(ArrayList<GraphObject> graphObjects) {
  27. List<DataPoint> dataPoints = new ArrayList<>();
  28. for (GraphObject object : graphObjects) {
  29. String close_string = object.getclose();
  30. String string_time = object.getMtime();
  31. long time = Long.parseLong(string_time);
  32. time = time * 1000;
  33. Double close = Double.parseDouble(close_string);
  34. Date dateObject = new Date(time);
  35. dataPoints.add(new DataPoint(dateObject, close));
  36. }
  37. return dataPoints;
  38. }
Add Comment
Please, Sign In to add comment