Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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)
Expand All @@ -76,38 +74,17 @@ public void onComplete(@NonNull Task<DocumentSnapshot> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocumentSnapshot>() {
// @SuppressLint("LongLogTag")
// @Override
// public void onComplete(@NonNull Task<DocumentSnapshot> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 18 additions & 8 deletions app/src/main/res/layouts/Login/layout/fragment_community_posts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ImageButton
android:id="@+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="20dp"
android:layout_gravity="right|center_vertical"
android:layout_marginTop="4dp"
android:layout_marginRight="30dp"
Expand Down Expand Up @@ -124,8 +124,9 @@
app:srcCompat="@drawable/bluecircle" />

<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center|left"
android:orientation="vertical">

Expand All @@ -147,6 +148,15 @@
android:text="2020.01.01" />
</LinearLayout>

<Button
android:id="@+id/btn_delete"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:background="@drawable/half_round_border"
android:text="삭제"
android:textStyle="bold" />

</LinearLayout>

<View
Expand Down Expand Up @@ -252,8 +262,8 @@

<ImageButton
android:id="@+id/btn_commu_like"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_event_like" />

Expand All @@ -265,8 +275,8 @@

<ImageButton
android:id="@+id/btn_commu_save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_event_save" />

Expand All @@ -278,8 +288,8 @@

<ImageButton
android:id="@+id/btn_commu_comment"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginRight="5dp"
android:background="@drawable/icon_comment"
android:text="댓글" />
Expand Down