Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first call data -> A B C D are added to the recyclerview
- second call data -> A B C D E F
- compare data from call 1 with call 2 and add E F because they are different
- the final result to be shown in the recyclerview would be the following A B C D E F
- mData.remove(position);
- notifyItemRemoved(position);
- notifyItemRangeChanged(position, mData.size());
- notifyDataSetChanged();
- //this lines deletes the final button, and after add the new data
- JSONArray res = response_json.getJSONArray("res");
- for(int i=0;i<mData.size();i++){
- if(i >= row_index){ //row_index I identify the index of the page to update from it
- for(int j=0;j<res.length();j++){
- JSONObject item = res.getJSONObject(j);
- if(mData.get(i).getId() != item.getInt("id")){
- //add diferent data
- obj = new Obj();
- obj.setId_pedido(item.getInt("id"));
- obj.setValor(item.getString("valor"));
- mData.add(obj);
- notifyDataSetChanged();
- }
- }
- }
- }
- Obj mas = new Obj();
- mas.setId_pedido(0);
- mas.setValor("OBtener mas data");
- mData.add(mas);
- //Add the final button
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement