wyświetlanie notatki z bazy na ekranie

This commit is contained in:
Naiki00 2021-02-16 12:40:24 +01:00
parent 6d81329448
commit 521c796075

View File

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
@ -135,9 +136,25 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onPostExecute(List<NoteEntity> 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();
}
@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();
}
}
}