dodano obsługę requestów do onPostExecute

This commit is contained in:
Naiki00 2021-02-17 22:54:25 +01:00
parent 39f009e31a
commit 89659f873d

View File

@ -102,6 +102,9 @@ public class MainActivity extends AppCompatActivity implements NoteListener {
protected void onPostExecute(List<NoteEntity> noteEntities) { protected void onPostExecute(List<NoteEntity> noteEntities) {
super.onPostExecute(noteEntities); super.onPostExecute(noteEntities);
//Log.d("NOTES", noteEntities.toString()); //Log.d("NOTES", noteEntities.toString());
// zamiast requestów
// bez możliwości edycji
/*
if (noteEntityList.size() == 0) { if (noteEntityList.size() == 0) {
noteEntityList.addAll(noteEntities); noteEntityList.addAll(noteEntities);
noteAdapter.notifyDataSetChanged(); noteAdapter.notifyDataSetChanged();
@ -110,6 +113,20 @@ public class MainActivity extends AppCompatActivity implements NoteListener {
noteAdapter.notifyItemInserted(0); noteAdapter.notifyItemInserted(0);
} }
noteRecycler.smoothScrollToPosition(0); noteRecycler.smoothScrollToPosition(0);
*/
if (requestCode == REQUEST_SHOW_NOTE) {
noteEntityList.addAll(noteEntities);
noteAdapter.notifyDataSetChanged();
} else if (requestCode == REQUEST_CODE_NEW_NOTE) {
noteEntityList.add(0, noteEntities.get(0));
noteAdapter.notifyItemInserted(0);
noteRecycler.smoothScrollToPosition(0);
} else if (requestCode == REQUEST_EDIT_NOTE) {
noteEntityList.remove(notePosition);
noteEntityList.add(notePosition, noteEntities.get(notePosition));
noteAdapter.notifyItemChanged(notePosition);
}
} }
} }
new GetNotesTask().execute(); new GetNotesTask().execute();