Ciortea Razvan
Lurker
I try to make a graph with the Json date's recived from an API and i can't pass by this error. The URL is 100% VALID, i get the entire file. This is the URL: https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCRON. This is the method for the request and plot of the graph:
Java:
private void drawChart() {
String tag_string_req = "req_chart";
StringRequest strReq = new StringRequest(Method.GET, BTC_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Response graph dates: " + response);
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("open");
for (int i = 0; i < jsonArray.length(); i++) {
int hour = jsonObject.getInt("hour");
String date = jsonObject.getString("day");
x.add(new Entry(hour, i));
y.add(date);
}
LineDataSet set1 = new LineDataSet(x, "NAV Data Value");
set1.setLineWidth(1.5f);
set1.setCircleRadius(4f);
LineData data = new LineData(y, set1);
mChart.setData(data);
mChart.invalidate();
} catch (Exception e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error: " + error.getMessage());
}
});
strReq.setRetryPolicy(new RetryPolicy() {
@Override
public void retry(VolleyError arg0) throws VolleyError {
}
@Override
public int getCurrentTimeout() {
return 0;
}
@Override
public int getCurrentRetryCount() {
return 0;
}
});
strReq.setShouldCache(false);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}