UPDATED JSON FILE IS HERE
{"posts":[{"post_id":"58","post_desc":"\ud83d\ude0d\ud83d\ude0a","firstname":"karan","lastname":"qq","created_at":"2017-05-30 12:12:36","files":[]},{"post_id":"57","post_desc":"Good Morning","firstname":"karan","lastname":"qq","created_at":"2017-05-30 11:29:43","files":[]},{"post_id":"56","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-26 16:50:49","files":[]},{"post_id":"55","post_desc":"","firstname":"jaxi","lastname":"chawda","created_at":"2017-05-26 16:50:04","files":[]},{"post_id":"54","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-26 16:47:24","files":[{"file_name":"1495797444_IMG_20170522_191006_842.jpg","file_type":"1"}]},{"post_id":"53","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-26 16:45:18","files":[]},{"post_id":"52","post_desc":"","firstname":"jaxi","lastname":"chawda","created_at":"2017-05-26 16:32:24","files":[]},{"post_id":"51","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-26 16:18:31","files":[]},{"post_id":"50","post_desc":"","firstname":"karan","lastname":"qq","created_at":"2017-05-23 17:37:19","files":[{"file_name":"1495541239_VID-20170518-WA0029.mp4","file_type":"2"}]},{"post_id":"49","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-16 16:19:13","files":[{"file_name":"1494931753_IMG_3919.mp4","file_type":"2"}]},{"post_id":"48","post_desc":"","firstname":"jaxi","lastname":"chawda","created_at":"2017-05-16 15:09:32","files":[{"file_name":"1494927572_Technology in the Future.mp4","file_type":"2"}]},{"post_id":"47","post_desc":"","firstname":"pankti","lastname":"shah","created_at":"2017-05-16 13:30:09","files":[{"file_name":"1494921609_Tom and Jerry - Little School Mouse.mp4","file_type":"2"}]},{"post_id":"46","post_desc":"","firstname":"pankti","lastname":"shah","created_at":"2017-05-16 13:16:34","files":[{"file_name":"1494920794_Tubelight _ Official Teaser _ Salman Khan _ Kabir Khan.mp4","file_type":"2"}]},{"post_id":"45","post_desc":"","firstname":"pankti","lastname":"shah","created_at":"2017-05-16 13:13:51","files":[{"file_name":"1494920631_small.mp4","file_type":"2"}]},{"post_id":"44","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-13 16:45:08","files":[{"file_name":"1494674108_IMG_4126.JPG","file_type":"1"}]},{"post_id":"43","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-13 16:24:30","files":[{"file_name":"1494672870_IMG_4123.JPG","file_type":"1"}]},{"post_id":"42","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-13 16:23:25","files":[{"file_name":"1494672805_IMG_4124.JPG","file_type":"1"}]},{"post_id":"41","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-13 15:48:39","files":[{"file_name":"1494670719_IMG_4121.JPG","file_type":"1"}]},{"post_id":"40","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 22:53:24","files":[{"file_name":"1494609804_IMG_4119.JPG","file_type":"1"}]},{"post_id":"39","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 18:28:28","files":[{"file_name":"1494593908_IMG_4015.JPG","file_type":"1"}]},{"post_id":"38","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 14:13:20","files":[{"file_name":"1494578600_IMG_4113.PNG","file_type":"1"}]},{"post_id":"37","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 14:13:18","files":[{"file_name":"1494578598_IMG_4113.PNG","file_type":"1"}]},{"post_id":"36","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 14:13:15","files":[{"file_name":"1494578595_IMG_4113.PNG","file_type":"1"}]},{"post_id":"35","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 14:13:12","files":[{"file_name":"1494578592_IMG_4113.PNG","file_type":"1"}]},{"post_id":"34","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-12 14:13:09","files":[{"file_name":"1494578589_IMG_4113.PNG","file_type":"1"}]},{"post_id":"33","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:43:42","files":[{"file_name":"1494526422_IMG_3950.JPG","file_type":"1"}]},{"post_id":"32","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:43:10","files":[{"file_name":"1494526390_IMG_3944.JPG","file_type":"1"}]},{"post_id":"31","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:26:24","files":[{"file_name":"1494525384_IMG_3127.JPG","file_type":"1"}]},{"post_id":"30","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:26:20","files":[{"file_name":"1494525380_IMG_3127.JPG","file_type":"1"}]},{"post_id":"29","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:24:12","files":[{"file_name":"1494525252_IMG_2600.JPG","file_type":"1"}]},{"post_id":"28","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:24:06","files":[{"file_name":"1494525246_IMG_2600.JPG","file_type":"1"}]},{"post_id":"27","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:22:04","files":[{"file_name":"1494525124_IMG_3113.JPG","file_type":"1"}]},{"post_id":"26","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:21:11","files":[{"file_name":"1494525071_1491304854804.jpeg","file_type":"1"}]},{"post_id":"25","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:20:26","files":[{"file_name":"1494525026_IMG_4050.JPG","file_type":"1"}]},{"post_id":"24","post_desc":"Ganesh Mahotsav 2016 ","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:20:01","files":[{"file_name":"1494525001_IMG_4045.PNG","file_type":"1"}]},{"post_id":"23","post_desc":"","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-11 23:19:03","files":[{"file_name":"1494524943_IMG_4016.JPG","file_type":"1"}]},{"post_id":"22","post_desc":"\ud83d\ude0d\n","firstname":"karan","lastname":"qq","created_at":"2017-05-10 14:57:16","files":[]},{"post_id":"21","post_desc":"\ud83d\ude0a\n","firstname":"karan","lastname":"qq","created_at":"2017-05-04 11:06:07","files":[]},{"post_id":"20","post_desc":"\ud83d\ude0a\n","firstname":"karan","lastname":"qq","created_at":"2017-05-04 11:06:03","files":[]},{"post_id":"19","post_desc":"Good morning","firstname":"karan","lastname":"qq","created_at":"2017-05-04 11:05:27","files":[]},{"post_id":"18","post_desc":"https:\/\/www.youtube.com\/watch?v=Qtp42J9IOUo","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:39:53","files":[]},{"post_id":"17","post_desc":"\ud83d\ude1c\ud83d\ude1c\ud83d\ude1c\ud83d\ude1c\ud83d\ude1c\ud83d\ude1c\ud83d\ude1c","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:38:40","files":[]},{"post_id":"16","post_desc":"hi hello","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:30:35","files":[]},{"post_id":"15","post_desc":"\ud83d\ude0e\ud83d\ude34\ud83d\ude01","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:30:19","files":[]},{"post_id":"14","post_desc":"\ud83d\ude0e\ud83d\ude34\ud83d\ude01","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:30:17","files":[]},{"post_id":"13","post_desc":"\ud83d\ude0e\ud83d\ude34\ud83d\ude01","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:30:17","files":[]},{"post_id":"12","post_desc":"\ud83d\ude0e\ud83d\ude34\ud83d\ude01","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:30:16","files":[]},{"post_id":"11","post_desc":"\ud83d\ude0e\ud83d\ude34\ud83d\ude01","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:30:16","files":[]},{"post_id":"10","post_desc":"\ud83d\ude0a\ud83d\ude0a\ud83d\ude04\ud83d\ude04\u263a\ufe0f\ud83d\ude01\ud83d\ude01","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:30:14","files":[]},{"post_id":"9","post_desc":"Going to receive loads of money....","firstname":"Manish","lastname":"Amin","created_at":"2017-05-02 16:08:58","files":[]},{"post_id":"8","post_desc":"\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:08:57","files":[]},{"post_id":"7","post_desc":"\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:08:55","files":[]},{"post_id":"6","post_desc":"\ud83d\ude02\ud83d\ude02\ud83d\ude02\ud83d\ude02","firstname":"Abc","lastname":"Xyz","created_at":"2017-05-02 16:08:47","files":[]},{"post_id":"5","post_desc":"\ud83c\udfe1\ud83c\udfeb","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:05:40","files":[]},{"post_id":"4","post_desc":"\ud83d\udc4d\ud83d\udc4d\ud83d\ude0a\ud83d\ude12\ud83d\udc2e\ud83d\ude48\ud83d\ude1c\ud83d\ude09\ud83d\ude03","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 16:02:21","files":[]},{"post_id":"3","post_desc":"\ud83d\ude12\ud83d\ude0a","firstname":"Rushin","lastname":"Patel","created_at":"2017-05-02 15:58:42","files":[]},{"post_id":"2","post_desc":"\ud83d\ude33\ud83d\ude33\ud83d\ude33","firstname":"jaxi","lastname":"chawda","created_at":"2017-05-02 15:57:31","files":[]},{"post_id":"1","post_desc":"hii....good afternoon...\ud83d\ude04\ud83d\ude04\ud83d\ude04","firstname":"jaxi","lastname":"chawda","created_at":"2017-05-02 15:55:49","files":[]}]}
ANDROID CODE IS HERE I UPDATED BT IMAGEs ARE REPEATING WITH DIFFERENT USERS IN ANDROID APP PLEASE HELP TO SOLVE THIS SILLY ERROR!!
public class Sample extends AppCompatActivity {
private static final String URL_DATA = "www.sample.com/home_webservice.php";
LinearLayout linearLayout;
private RecyclerView recyclerView;
private RecyclerView.Adapter adapter;
private List<Data_SAerver> data_sAervers;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recyclerview);
linearLayout = (LinearLayout) findViewById(R.id.linaralayout1);
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Sample.this, Posts_DATA.class);
startActivity(i);
}
});
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
data_sAervers = new ArrayList<>();
loadRecyclerViewData();
}
private void loadRecyclerViewData() {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Loading...");
progressDialog.show();
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_DATA,
new Response.Listener<String>() {
@Override
public void onResponse(String s) {
progressDialog.dismiss();
String filename = "";
String filetype = "";
try {
JSONObject jsonObject = new JSONObject(s);
JSONArray posts = jsonObject.getJSONArray("posts");
if (posts != null && posts.length() > 0) {
for (int i = 0; i < posts.length(); i++) {
JSONObject fileObj = posts.getJSONObject(i);
String fName = fileObj.getString("firstname");
String created_at = fileObj.getString("created_at");
String post_desc = fileObj.getString("post_desc");
Log.e("Details", fName + "" + created_at + "" + post_desc);
JSONArray files = fileObj.getJSONArray("files");
if (files != null && files.length() > 0) {
for (int j = 0; j < files.length(); j++) {
JSONObject Jsonfilename = files.getJSONObject(j);
filename = Jsonfilename.getString("file_name");
filetype = Jsonfilename.getString("file_type");
filename = "http://uat.ziplife.in/img/Post/compress/" + filename;
//filename = "http://uat.ziplife.in/img/Post/" + filename;
Log.e("Files", "" + filename);
}
} else
{
filename = "";
filetype = "";
}
Data_SAerver item = new Data_SAerver(fName, created_at, post_desc, filename, filetype);
data_sAervers.add(item);
}
}
adapter = new MyAdapter(data_sAervers, getApplicationContext());
recyclerView.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
}
Here only I got "posts" data. Please help me to get "files" data.
Thank You