diff --git a/app/src/main/java/com/example/nemophila/MyPageActivity.java b/app/src/main/java/com/example/nemophila/MyPageActivity.java index 131f618..f90011a 100644 --- a/app/src/main/java/com/example/nemophila/MyPageActivity.java +++ b/app/src/main/java/com/example/nemophila/MyPageActivity.java @@ -1,5 +1,6 @@ package com.example.nemophila; +import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; @@ -99,11 +100,11 @@ } }); - /* ここからあんまわかっていない */ RecyclerView rv = findViewById(R.id.postsList); LinearLayoutManager llm = new LinearLayoutManager(this); List myPageActDataset = new ArrayList<>(); MyPageActAdapter adapter = new MyPageActAdapter(myPageActDataset) { + // 「(投稿)削除」ボタンを押した後、「Yes」を押すと対象の投稿を削除する @Override void onDeleteButtonClick(View view, int position, MyPageActDataModel dataModel) { new AlertDialog.Builder(MyPageActivity.this) @@ -127,6 +128,7 @@ rv.setLayoutManager(llm); rv.setAdapter(adapter); + // getAccountPostsLiveDataとの通信により今までにユーザーがしている投稿を表示する accountViewModel.getAccountPosts(uid); accountViewModel.getAccountPostsLiveData().observe(this, new Observer >() { @Override @@ -169,7 +171,7 @@ public MyPageActAdapter(List list) { this.list = list; } @Override - public MyPageActViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public MyPageActViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_my_page_activity_posts, parent,false); MyPageActViewHolder vh = new MyPageActViewHolder(inflate); @@ -185,7 +187,7 @@ } @Override - public void onBindViewHolder(MyPageActViewHolder holder, int position) { + public void onBindViewHolder(@NonNull MyPageActViewHolder holder, int position) { holder.dateView.setText(list.get(position).getDate()); holder.rateView.setText(list.get(position).getRate()); holder.genreView.setText(list.get(position).getGenre()); @@ -206,7 +208,7 @@ public TextView commentView; public ImageButton deleteButton; - public MyPageActViewHolder(View view) { + public MyPageActViewHolder(@NonNull View view) { super(view); dateView = (TextView) view.findViewById(R.id.date); rateView = (TextView) view.findViewById(R.id.rate); @@ -217,7 +219,7 @@ } // DataModel - public class MyPageActDataModel { + public static class MyPageActDataModel { private String date; private String rate; private String genre;