Skip to content

Commit

Permalink
#6 feat/메인화면 : SplashActivity 에서 MainActivity 노출을 위해 로그인이 실패할 경우에도 임의…
Browse files Browse the repository at this point in the history
…로 MainActivity 를 노출하도록 수정
  • Loading branch information
HayleyKim0716 committed Aug 1, 2022
1 parent c4c61c9 commit 1403ddf
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.ftw.hometerview.R
import com.ftw.hometerview.ui.main.MainActivity
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.launch
Expand All @@ -25,12 +26,16 @@ class SplashActivity : AppCompatActivity() {
lifecycleScope.launch {
viewModel.state.collect { state ->
when (state) {
SplashViewModel.State.Failure -> Toast.makeText(this@SplashActivity, getString(R.string.get_token_error), Toast.LENGTH_SHORT).show() // TODO: 로그인 화면으로 이동
SplashViewModel.State.Failure -> showLoginActivity() // TODO: 로그인 화면으로 이동
SplashViewModel.State.Success -> Toast.makeText(this@SplashActivity, "Get token is succeeded", Toast.LENGTH_SHORT).show() // TODO: MainActivity 로 이동
SplashViewModel.State.Loading -> Toast.makeText(this@SplashActivity, "Loading", Toast.LENGTH_SHORT).show()
else -> {}
}
}
}
}

private fun showLoginActivity() {
startActivity(MainActivity.newIntent(this))
finish()
}
}

0 comments on commit 1403ddf

Please sign in to comment.