I have been working on getting data from JSON API for wordpress from https://wordpress.org/plugins/json-api/other_notes/
I have used the follwing to fetch data. Everything is working fine except that it is taking about 30 seconds to load data on to the tabview.
try {
JSONObject jObj = new JSONObject(result);
int count = (jObj.getInt("count_total"));
JSONArray jArray = jObj.getJSONArray("posts");
// Toast.makeText(getApplicationContext(), "Year: " + date2.substring(0, 4) + "Hour: " + date2.substring(11, 13), Toast.LENGTH_SHORT).show();
// Toast.makeText(getApplicationContext(),"Hour: "+date2.substring(11,13),Toast.LENGTH_SHORT).show();
// Extract data from json and store into ArrayList as class objects
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
JSONArray jArray2 = json_data.getJSONArray("categories");
JSONObject json_data2 = jArray2.getJSONObject(0);
DataFish fishData = new DataFish();
fishData.fishImage = json_data.getString("thumbnail");
fishData.fishName = json_data.optString("title", "N/A");
String comment = json_data.optString("comment_count", "0");
fishData.comment = comment;
//fishData.fishName ="Title";
// fishData.sizeName = json_data.getString("size_name");
String category_array = json_data2.optString("title", "N/A");
fishData.sizeName = category_array;
fishData.price = 10;
fishData.url =
json_data.optString("url", "N/A");
data.add(fishData);
}
}
Any other way to fetch data faster so that user need not wait for awful 25-30 seconds to load data?