diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
index 40556a2..498ac9e 100644
--- a/.idea/deploymentTargetDropDown.xml
+++ b/.idea/deploymentTargetDropDown.xml
@@ -7,11 +7,11 @@
-
+
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 54ed16b..743778d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -10,9 +10,12 @@
+
+
+
diff --git a/app/src/main/java/com/example/nemophila/FriendActivity.java b/app/src/main/java/com/example/nemophila/FriendActivity.java
index 89066d2..d611634 100644
--- a/app/src/main/java/com/example/nemophila/FriendActivity.java
+++ b/app/src/main/java/com/example/nemophila/FriendActivity.java
@@ -8,6 +8,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -53,9 +55,19 @@
// getFriendsの通信が呼び出されて、フレンドの一覧をfriendsDatasetに格納し、Adapterにセットする
FriendActivityAdapter adapter = new FriendActivityAdapter(friendsDataset) {
@Override
- void onItemClick(View view, int position, FriendDataModel friend) {
- Toast.makeText(FriendActivity.this, friend.getName(), Toast.LENGTH_SHORT).show();
-// friendViewModel.deleteFriend(myUid, friend.getId(), myToken);
+ void onDeleteClick(View view, int position, FriendDataModel friend) {
+ new AlertDialog.Builder(FriendActivity.this)
+ .setTitle("フレンドから" + friend.getName() + "を削除しますか?")
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Toast.makeText(FriendActivity.this, friend.getName(), Toast.LENGTH_SHORT).show();
+// friendViewModel.deleteFriend(myUid, friend.getId(), myToken);
+ }
+ })
+ .setNegativeButton("キャンセル", null)
+ .create()
+ .show();
}
};
friendViewModel.getFriends(myUid); // 自身のフレンドの一覧を取得するメソッドを呼び出す
@@ -89,7 +101,7 @@
// ----------- RecyclerView用の内部クラス ------------//
// Adapter
- public class FriendActivityAdapter extends RecyclerView.Adapter {
+ abstract public class FriendActivityAdapter extends RecyclerView.Adapter {
private List friendDatas;
public FriendActivityAdapter(List friendDatas) {
@@ -114,7 +126,7 @@
public void onClick(View v) {
int position = vh.getBindingAdapterPosition();
// 処理はonItemClick()に丸投げ
- onItemClick(v, position, friendDatas.get(position));
+ onDeleteClick(v, position, friendDatas.get(position));
}
});
@@ -132,9 +144,7 @@
return friendDatas.size();
}
- void onItemClick(View view, int position, FriendDataModel friend) {
- // このメソッドをActivity内でオーバーライドして、クリックイベントの処理を設定する
- }
+ abstract void onDeleteClick(View view, int position, FriendDataModel friend);
}
// ViewHolder
diff --git a/app/src/main/res/layout/layout_friends_activity.xml b/app/src/main/res/layout/layout_friends_activity.xml
index d891315..7635bd4 100644
--- a/app/src/main/res/layout/layout_friends_activity.xml
+++ b/app/src/main/res/layout/layout_friends_activity.xml
@@ -25,4 +25,5 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="削除" />
+
\ No newline at end of file