Skip to content

Commit

Permalink
Merge pull request #212 from TeamDMU/feature/setting-selected-depart
Browse files Browse the repository at this point in the history
Feat : ํ•™๊ณผ ์„ค์ • ์ง„์ž…์‹œ ์ด์ „ ํ•™๊ณผ ํ™œ์„ฑํ™”
  • Loading branch information
huiwoo-jo authored Mar 28, 2024
2 parents a90b7c1 + 5b4595e commit b943e18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ class DepartRepository {
SharedPreference.setCode(department.code)
}
fun getIsFirstLaunch(): Boolean = SharedPreference.getIsFirstLaunch()

fun getUserDepartment(): String {
return SharedPreference.getDepartment()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class DepartActivity : BaseActivity<ActivityDepartBinding, DepartViewModel>(), D

}

override fun initDataBinding() = Unit
override fun initDataBinding() {
viewModel.myDepartment.observe(this) { department ->
viewModel.setSelectPosition(items.indexOf(department))
}
}

override fun initAfterBinding() {
viewModel.selectDepartPosition.observe(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ class DepartViewModel(private val departRepository: DepartRepository) : BaseView
private val _isFirstLaunch: MutableLiveData<Boolean> = MutableLiveData(false)
val isFirstLaunch: LiveData<Boolean> get() = _isFirstLaunch

private val _myDepartment: MutableLiveData<String> = MutableLiveData()
val myDepartment: LiveData<String> get() = _myDepartment

private val _selectDepartPosition = MutableLiveData(-1)
val selectDepartPosition: LiveData<Int> get() = _selectDepartPosition
init {
getUserDepartment()
}

private fun getUserDepartment() {
val myDepartment = departRepository.getUserDepartment()
_myDepartment.postValue(myDepartment)
}

fun setDepartment(department: String) {
departRepository.setDepartment(department)
Expand Down

0 comments on commit b943e18

Please sign in to comment.