wyświetlanie notatki z bazy na ekranie
This commit is contained in:
parent
6d81329448
commit
521c796075
@ -6,6 +6,7 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||||
@ -135,9 +136,25 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
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());
|
||||||
|
if (noteEntityList.size() == 0) {
|
||||||
|
noteEntityList.addAll(noteEntities);
|
||||||
|
noteAdapter.notifyDataSetChanged();
|
||||||
|
} else {
|
||||||
|
noteEntityList.add(0, noteEntities.get(0));
|
||||||
|
noteAdapter.notifyItemInserted(0);
|
||||||
|
}
|
||||||
|
noteRecycler.smoothScrollToPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new GetNotesTask().execute();
|
new GetNotesTask().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == REQUEST_CODE_NEW_NOTE && requestCode == RESULT_OK) {
|
||||||
|
getAllNotes();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user