Skip to content

Commit

Permalink
[CHORE] #9-using extension fun toast
Browse files Browse the repository at this point in the history
  • Loading branch information
librarywon committed May 25, 2023
1 parent 481745a commit 221bf1f
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.sopt.carrot.presentation.review

import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import com.sopt.carrot.databinding.ActivityReviewBinding
import com.sopt.carrot.presentation.review.adapter.ReviewAdapter
import com.sopt.carrot.presentation.review.model.ReviewViewModel
import com.sopt.carrot.util.toast

class ReviewActivity : AppCompatActivity() {
private val viewModel by viewModels<ReviewViewModel>()
private var _binding: ActivityReviewBinding? = null
private val binding: ActivityReviewBinding
get() = requireNotNull(_binding) { "binding is null" }

private val context : Context = this
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = ActivityReviewBinding.inflate(layoutInflater)
Expand All @@ -37,20 +39,15 @@ class ReviewActivity : AppCompatActivity() {
}
}

// 통신처리 예정
viewModel.signUpResult.observe(this) { signUpResult ->
makeToastMessage(signUpResult.message)
context.toast(signUpResult.message)
}
viewModel.errorResult.observe(this) { errorResult ->
makeToastMessage(errorResult.message)
context.toast(errorResult.message)
}
}

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

private fun makeToastMessage(string: String) {
Toast.makeText(this, string, Toast.LENGTH_LONG).show()
}
}

0 comments on commit 221bf1f

Please sign in to comment.