Skip to content

Commit

Permalink
[CHORE] #9-setting for Intent
Browse files Browse the repository at this point in the history
  • Loading branch information
librarywon committed May 25, 2023
1 parent 3055df3 commit 481745a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package com.sopt.carrot.data.review

import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.Path



interface ReviewService {
@Headers("Authorization: 1") // 정적 헤더 설정
@GET("/employer/{userId}/reviews?size=10")
fun getReviewList(
@Header("Authorization") Authorization: String = "1",
@Path(value = "userId") userId: Int = 3
@Path(value = "userId") userId: Long //userId 받아올준비 완료
): Call<ResponseReviewDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ReviewActivity : AppCompatActivity() {
binding.rcReviewReviews.addItemDecoration(CustomItemDecoration())
binding.rcReviewReviews.adapter = reviewAdapter

viewModel.getReview(getUserIdFromPage())

//아이템 개수에 따라 뷰전환
viewModel.reviews.observe(this) { reviews ->
if (reviews.isEmpty()) {
Expand All @@ -44,6 +46,10 @@ class ReviewActivity : AppCompatActivity() {
}
}

private fun getUserIdFromPage(): Long {
return 3L //임시 데이터 3
}

private fun makeToastMessage(string: String) {
Toast.makeText(this, string, Toast.LENGTH_LONG).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import androidx.lifecycle.ViewModel
import com.sopt.carrot.data.ApiPool
import com.sopt.carrot.data.review.ResponseReviewDto
import com.sopt.carrot.util.enqueueUtil
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class ReviewViewModel : ViewModel() {

Expand All @@ -22,13 +19,9 @@ class ReviewViewModel : ViewModel() {
private val _errorResult: MutableLiveData<ResponseReviewDto> = MutableLiveData()
val errorResult: LiveData<ResponseReviewDto> = _errorResult

init {
getReview()
}

fun getReview() {
fun getReview(userId: Long) {
val reviewService = ApiPool.reviewService
reviewService.getReviewList().enqueueUtil(
reviewService.getReviewList(userId).enqueueUtil(
onSuccess = { response ->
val data = response.data?.reviews
_reviews.value = data!!
Expand Down

0 comments on commit 481745a

Please sign in to comment.