-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
50 changed files
with
2,376 additions
and
338 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
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
17 changes: 17 additions & 0 deletions
17
...rc/main/java/com/el/yello/presentation/main/profile/detail/SchoolProfileDetailActivity.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,17 @@ | ||
package com.el.yello.presentation.main.profile.detail | ||
|
||
import android.os.Bundle | ||
import com.el.yello.R | ||
import com.el.yello.databinding.ActivityProfileSchoolDetailBinding | ||
import com.example.ui.base.BindingActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class SchoolProfileDetailActivity : | ||
BindingActivity<ActivityProfileSchoolDetailBinding>(R.layout.activity_profile_school_detail) { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
app/src/main/java/com/el/yello/presentation/main/profile/detail/UnivProfileDetailActivity.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,112 @@ | ||
package com.el.yello.presentation.main.profile.detail | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.el.yello.R | ||
import com.el.yello.databinding.ActivityProfileUnivDetailBinding | ||
import com.el.yello.presentation.main.profile.mod.UnivProfileModActivity | ||
import com.el.yello.util.Utils.setImageOrBasicThumbnail | ||
import com.el.yello.util.context.yelloSnackbar | ||
import com.example.ui.activity.navigateTo | ||
import com.example.ui.base.BindingActivity | ||
import com.example.ui.context.toast | ||
import com.example.ui.view.UiState | ||
import com.example.ui.view.setOnSingleClickListener | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
@AndroidEntryPoint | ||
class UnivProfileDetailActivity : | ||
BindingActivity<ActivityProfileUnivDetailBinding>(R.layout.activity_profile_univ_detail) { | ||
|
||
private val viewModel by viewModels<UnivProfileDetailViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
binding.vm = viewModel | ||
initProfileModBtnListener() | ||
initChangeThumbnailBtnListener() | ||
initBackBtnListener() | ||
observeUserDataState() | ||
observeKakaoDataResult() | ||
observeModProfileState() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
|
||
viewModel.getUserDataFromServer() | ||
} | ||
|
||
private fun initProfileModBtnListener() { | ||
binding.btnModSchool.setOnSingleClickListener { | ||
this.navigateTo<UnivProfileModActivity>() | ||
viewModel.resetViewModelState() | ||
} | ||
binding.btnModSubgroup.setOnSingleClickListener { | ||
this.navigateTo<UnivProfileModActivity>() | ||
viewModel.resetViewModelState() | ||
} | ||
binding.btnModYear.setOnSingleClickListener { | ||
this.navigateTo<UnivProfileModActivity>() | ||
viewModel.resetViewModelState() | ||
} | ||
} | ||
|
||
private fun initChangeThumbnailBtnListener() { | ||
binding.btnChangeKakaoImage.setOnSingleClickListener { | ||
viewModel.getUserInfoFromKakao() | ||
} | ||
} | ||
|
||
private fun initBackBtnListener() { | ||
binding.btnProfileDetailBack.setOnSingleClickListener { finish() } | ||
} | ||
|
||
private fun observeUserDataState() { | ||
viewModel.getUserDataState.flowWithLifecycle(lifecycle).onEach { state -> | ||
when (state) { | ||
is UiState.Success -> { | ||
binding.ivProfileDetailThumbnail.setImageOrBasicThumbnail(state.data) | ||
} | ||
|
||
is UiState.Failure -> { | ||
toast(getString(R.string.profile_error_user_data)) | ||
} | ||
|
||
is UiState.Empty -> return@onEach | ||
|
||
is UiState.Loading -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private fun observeKakaoDataResult() { | ||
viewModel.getKakaoInfoResult.flowWithLifecycle(lifecycle).onEach { result -> | ||
if (!result) yelloSnackbar(binding.root, getString(R.string.msg_error)) | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private fun observeModProfileState() { | ||
viewModel.postToModProfileState.flowWithLifecycle(lifecycle).onEach { state -> | ||
when (state) { | ||
is UiState.Success -> { | ||
binding.ivProfileDetailThumbnail.setImageOrBasicThumbnail(state.data) | ||
toast(getString(R.string.profile_detail_image_change)) | ||
} | ||
|
||
is UiState.Failure -> { | ||
toast(getString(R.string.sign_in_error_connection)) | ||
} | ||
|
||
is UiState.Empty -> return@onEach | ||
|
||
is UiState.Loading -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
} |
Oops, something went wrong.