Skip to content

Commit

Permalink
fix: 마이페이지에서 수정/삭제를 3dot으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Amepistheo committed Nov 9, 2023
1 parent 8fd3677 commit 2320c3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import com.eatssu.android.data.model.response.GetMyReviewResponseDto
import com.eatssu.android.data.service.ReviewService
import com.eatssu.android.databinding.ItemMyReviewBinding
import com.eatssu.android.view.review.FixedReviewActivity
import com.eatssu.android.view.review.MyReviewDialogActivity
import com.eatssu.android.view.review.OthersReviewDialogActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand Down Expand Up @@ -58,59 +60,14 @@ class MyReviewAdapter(private val dataList: List<GetMyReviewResponseDto.Data>) :
imageView.visibility = View.VISIBLE
}

binding.tvReviewItemUpdate.setOnClickListener() {
val intent = Intent(binding.tvReviewItemUpdate.context, FixedReviewActivity::class.java)
intent.putExtra("reviewId", dataList[position].reviewId.toLong())
intent.putExtra("menu", dataList[position].menuName)
ContextCompat.startActivity(binding.tvReviewItemUpdate.context, intent, null)
}

binding.tvReviewItemDelete.setOnClickListener() {
AlertDialog.Builder(binding.tvReviewItemDelete.context).apply {
setTitle("리뷰 삭제")
setMessage("작성한 리뷰를 삭제하시겠습니까?")
setNegativeButton("취소") { _, _ ->
Toast.makeText(
binding.tvReviewItemDelete.context,
"리뷰 삭제가 취소되었습니다",
Toast.LENGTH_SHORT
).show()
}
setPositiveButton("삭제") { _, _ ->
val service = RetrofitImpl.retrofit.create(ReviewService::class.java)

service.delReview(dataList[position].reviewId.toLong())
.enqueue(object : Callback<Void> {
override fun onResponse(call: Call<Void>, response: Response<Void>) {
if (response.isSuccessful) {
if (response.code() == 200) {
Log.d("post", "onResponse 성공: " + response.body().toString())
Toast.makeText(
binding.tvReviewItemDelete.context, "삭제가 완료되었습니다.", Toast.LENGTH_SHORT
).show()


} else {
Log.d("post", "onResponse 오류: " + response.body().toString())
Toast.makeText(
binding.tvReviewItemDelete.context, "삭제가 실패하였습니다.", Toast.LENGTH_SHORT
).show()
}
}
}
override fun onFailure(call: Call<Void>, t: Throwable) {
Log.d("post", "onFailure 에러: " + t.message.toString())
Toast.makeText(
binding.tvReviewItemDelete.context, "삭제가 실패하였습니다.", Toast.LENGTH_SHORT
).show()
}
})
}
show()
binding.btnDetail.setOnClickListener() {
val intent = Intent(binding.btnDetail.context, MyReviewDialogActivity::class.java)
intent.putExtra("reviewId", dataList[position].reviewId.toLong())
intent.putExtra("menu", dataList[position].menuName)
ContextCompat.startActivity(binding.btnDetail.context, intent, null)
}
}
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val viewBinding =
Expand Down
42 changes: 11 additions & 31 deletions app/src/main/res/layout/item_my_review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,39 +132,19 @@
android:layout_height="wrap_content"
android:text="2023.03.03"
android:layout_marginStart="5dp"
app:layout_constraintBottom_toTopOf="@+id/tv_review_item_delete"
app:layout_constraintEnd_toEndOf="@+id/tv_review_item_delete"
app:layout_constraintBottom_toTopOf="@+id/btn_detail"
app:layout_constraintEnd_toEndOf="@+id/btn_detail"
app:layout_constraintTop_toTopOf="@+id/tv_review_item_id"/>

<TextView
android:id="@+id/tv_review_item_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="수정"
android:textColor="@color/dark_gray"
app:layout_constraintBottom_toBottomOf="@+id/ll_review_item_rate"
app:layout_constraintEnd_toStartOf="@+id/tv_review_item"
app:layout_constraintTop_toTopOf="@+id/tv_review_item_id" />

<TextView
android:id="@+id/tv_review_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textColor="@color/dark_gray"
app:layout_constraintBottom_toBottomOf="@+id/ll_review_item_rate"
app:layout_constraintEnd_toStartOf="@+id/tv_review_item_delete"
app:layout_constraintTop_toTopOf="@+id/tv_review_item_id" />

<TextView
android:id="@+id/tv_review_item_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="삭제"
android:textColor="@color/dark_gray"
app:layout_constraintBottom_toBottomOf="@+id/ll_review_item_rate"
app:layout_constraintEnd_toEndOf="@+id/tv_review_item_comment"
app:layout_constraintTop_toTopOf="@+id/tv_review_item_id" />
<ImageButton
android:id="@+id/btn_detail"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@android:color/transparent"
android:scaleType="centerCrop"
android:src="@drawable/ic_three_dot"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_review_item_date" />

<TextView
android:id="@+id/tv_review_item_comment"
Expand Down

0 comments on commit 2320c3f

Please sign in to comment.