diff --git a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentAdapter.java b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentAdapter.java index 28cbe13..4ec85f4 100644 --- a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentAdapter.java +++ b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentAdapter.java @@ -53,9 +53,6 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, final int positio holder.commu_comment_like.setText(arrayList.get(position).getComment_like()); holder.commu_comment_comment_count.setText(arrayList.get(position).getComment_count()); -// 이 유저가 댓글에 '좋아요' 버튼을 눌렀었는지 판단 -// Log.d("position,boolean",String.valueOf(position) + "/" + String.valueOf(callback.checkLikePressed(position))); - FirebaseFirestore firestore = FirebaseFirestore.getInstance(); FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(); @@ -64,6 +61,7 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, final int positio String email = firebaseAuth.getCurrentUser().getEmail();; + // 이 유저가 댓글에 '좋아요' 버튼을 눌렀었는지 판단 firestore.collection(FirebaseID.Community).document(category).collection("sub_Community").document(title) .collection(FirebaseID.Community_Comment).document(arrayList.get(position).getComment()) .collection("comment_Like").document(email) @@ -76,38 +74,17 @@ public void onComplete(@NonNull Task task) { DocumentSnapshot document = task.getResult(); if (document.exists()) { Log.d("댓글 좋아요 버튼 판단", "True!!!"); - holder.btn_comment_like.setSelected(true); -// returnBoolean(position); } else { Log.d("댓글 좋아요 버튼 판단", "False!!!"); holder.btn_comment_like.setSelected(false); -// returnBoolean(position); } } else { Log.d("CommunityCommentFragment", "get failed with ", task.getException()); } } }); -// if( callback.checkLikePressed(position) == true) { -// holder.btn_comment_like.setSelected(true); -// Log.d("댓글 좋아요 값 넘어왔어요!", "True!!!"); -// } else { -// Log.d("댓글 좋아요 값 넘어왔어요!", "fasle!!!"); -//// holder.btn_comment_like.setSelected(false); -// } - -// callback.checkLikePressed(position); - -// if( callback.returnBoolean(position) == true) { -// holder.btn_comment_like.setSelected(true); -// Log.d("댓글 좋아요 값 넘어왔어요!", "True!!!"); -// } else { -// Log.d("댓글 좋아요 값 넘어왔어요!", "fasle!!!"); -// holder.btn_comment_like.setSelected(false); -// } - // '삭제' 버튼 클릭 시 데이터 삭제하기 holder.btn_commu_delete.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentFragment.java b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentFragment.java index a87be25..c94d7d4 100644 --- a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentFragment.java +++ b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityComment/CommunityCommentFragment.java @@ -233,46 +233,6 @@ public String getCategory(){ public String getTitle(){ return title; } -// // 댓글 좋아요 판단 메소드 -// @Override -// public boolean checkLikePressed(int position) { -// -// final boolean check; -// firestore.collection(FirebaseID.Community).document(category).collection("sub_Community").document(title) -// .collection(FirebaseID.Community_Comment).document(arrayList.get(position).getComment()) -// .collection("comment_Like").document(email) -// .get() -// .addOnCompleteListener(new OnCompleteListener() { -// @SuppressLint("LongLogTag") -// @Override -// public void onComplete(@NonNull Task task) { -// if (task.isSuccessful()) { -// DocumentSnapshot document = task.getResult(); -// if (document.exists()) { -// Log.d("댓글 좋아요 버튼 판단", "True!!!"); -// commentLikeCheck = true; -// returnBoolean(position); -// return; -// } -// else { -// Log.d("댓글 좋아요 버튼 판단", "False!!!"); -// commentLikeCheck = false; -// returnBoolean(position); -// } -// Log.d("commentLikiecheck-before",String.valueOf(commentLikeCheck)); -// } else { -// Log.d("CommunityCommentFragment", "get failed with ", task.getException()); -// } -// return commentLikeCheck; -// } -// }); -// -//// Log.d("commentLikiecheck-after",String.valueOf(commentLikeCheck)); -//// return commentLikeCheck; -// } - - - // 댓글 좋아요 판단 후 결과 return @Override diff --git a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityPostsFragment.java b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityPostsFragment.java index 7fbe2c1..ecb2e7e 100644 --- a/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityPostsFragment.java +++ b/app/src/main/java/com/abbsolute/ma_livu/Community/CommunityPostsFragment.java @@ -50,6 +50,7 @@ public class CommunityPostsFragment extends Fragment { // 값 받아오는 변수들 private String title, writer, content, date, category, commentCount, saveCount, likeCount, likebtnEmail,documentID; private TextView commu_title, commu_writer, commu_date, commu_content, commu_category, commu_like_count, commu_save_count, commu_comment_count; + private Button btn_delete; private ImageButton btn_back; private ImageButton btn_commu_like, btn_commu_save, btn_commu_comment,btn_more; private ImageView get_commu_img1, get_commu_img2, get_commu_img3,get_commu_img4,get_commu_img5; @@ -80,6 +81,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c commu_comment_count = view.findViewById(R.id.commu_comment_count); btn_back = view.findViewById(R.id.btn_back); + btn_delete = view.findViewById(R.id.btn_delete); btn_commu_like = view.findViewById(R.id.btn_commu_like); btn_commu_save = view.findViewById(R.id.btn_commu_save); btn_commu_comment = view.findViewById(R.id.btn_commu_comment); @@ -306,7 +308,6 @@ public void onClick(View v) { } public boolean checkUser(String documentID) { - if(firebaseAuth.getCurrentUser() !=null){ String uid = firebaseAuth.getCurrentUser().getUid(); if(documentID == uid) { diff --git a/app/src/main/res/layouts/Login/layout/fragment_community_posts.xml b/app/src/main/res/layouts/Login/layout/fragment_community_posts.xml index 34f5ba2..98ecfd8 100644 --- a/app/src/main/res/layouts/Login/layout/fragment_community_posts.xml +++ b/app/src/main/res/layouts/Login/layout/fragment_community_posts.xml @@ -31,7 +31,7 @@ @@ -147,6 +148,15 @@ android:text="2020.01.01" /> +