-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contact Activity & addCommentActivity add
커멘트 관련 옵션 메뉴가 보이지 않는 버그 수정중
- Loading branch information
Showing
15 changed files
with
197 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/kr/ac/konkuk/koogle/Adapter/CommentAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package kr.ac.konkuk.koogle.Adapter | ||
|
||
import android.annotation.SuppressLint | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import kr.ac.konkuk.koogle.Model.CommentModel | ||
import kr.ac.konkuk.koogle.R | ||
import kr.ac.konkuk.koogle.databinding.ItemCommentBinding | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
/* | ||
2021-05-27 주예진 작성 | ||
프로필에서 표시되는 후기 목록 Recycler View 의 row adapter | ||
유저 프로필 이미지, 유저네임, 리뷰 내용을 표시 | ||
현재 임시로 데이터를 문자열로 받아오게 구현함 수정 필요 | ||
*/ | ||
//class RecommendAdapter(val context: Context, val items: ArrayList<ArrayList<String>>) : | ||
// RecyclerView.Adapter<RecommendAdapter.ViewHolder>() { | ||
// | ||
// inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
// var recommendUserNameView: TextView = itemView.findViewById(R.id.recommendUserNameText) | ||
// var recommendTextView: TextView = itemView.findViewById(R.id.recommendText) | ||
// } | ||
// | ||
// override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendAdapter.ViewHolder { | ||
// val view = LayoutInflater.from(context).inflate(R.layout.row_recommend, parent, false) | ||
// return ViewHolder(view) | ||
// } | ||
// | ||
// override fun onBindViewHolder(holder: RecommendAdapter.ViewHolder, position: Int) { | ||
// holder.recommendUserNameView.text = items[position][0] | ||
// holder.recommendTextView.text = items[position][1] | ||
// } | ||
// | ||
// override fun getItemCount(): Int { | ||
// return items.size | ||
// } | ||
//} | ||
|
||
class CommentAdapter: ListAdapter<CommentModel, CommentAdapter.ViewHolder>(diffUtil){ | ||
inner class ViewHolder(private val binding: ItemCommentBinding): RecyclerView.ViewHolder(binding.root) { | ||
|
||
@SuppressLint("SimpleDateFormat") | ||
fun bind(commentModel: CommentModel) { | ||
val format = SimpleDateFormat("MM월 dd일") | ||
val date = Date(commentModel.commentCreatedAt) | ||
//createAt으로 현재 시간을 long타입으로 받아왔는데 그것을 Date타입으로 바꾼다음에 | ||
//simpleDateFormat을 통해 포매팅 완성 | ||
binding.recommendUserNameTextView.text = commentModel.writerName | ||
binding.recommendCreatedAtTextView.text = format.format(date).toString() | ||
binding.recommendContentTextView.text = commentModel.commentContent | ||
|
||
if(commentModel.writerProfileImageUrl.isNotEmpty()){ | ||
Glide.with(binding.recommendUserProfileImage) | ||
.load(commentModel.writerProfileImageUrl) | ||
.into(binding.recommendUserProfileImage) | ||
} | ||
else{ | ||
binding.recommendUserProfileImage.setImageResource(R.drawable.profile_image) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
//context는 parent에 있다 | ||
return ViewHolder(ItemCommentBinding.inflate(LayoutInflater.from(parent.context),parent,false)) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.bind(currentList[position]) | ||
} | ||
|
||
companion object { | ||
val diffUtil = object : DiffUtil.ItemCallback<CommentModel>() { | ||
override fun areItemsTheSame(oldModel: CommentModel, newModel: CommentModel): Boolean { | ||
return oldModel.commentId == newModel.commentId | ||
} | ||
|
||
override fun areContentsTheSame(oldModel: CommentModel, newModel: CommentModel): Boolean { | ||
return oldModel == newModel | ||
} | ||
} | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
app/src/main/java/kr/ac/konkuk/koogle/Adapter/RecommendAdapter.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.