Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Create some methods for codes in initUiListener , add initObserver to…
Browse files Browse the repository at this point in the history
… base fragment , closed #26
  • Loading branch information
Miladsalimiiiii committed Jul 29, 2019
1 parent 164ecca commit fe9f6a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/de/netalic/peacock/ui/base/BaseFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ abstract class BaseFragment : Fragment() {

abstract fun initUiListener()
abstract fun initUiComponent()
abstract fun initObserver()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initUiListener()
initUiComponent()
initObserver()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit

class CodeVerificationFragment : BaseFragment() {


companion object {

var sTimer = 30000
Expand Down Expand Up @@ -51,11 +52,22 @@ class CodeVerificationFragment : BaseFragment() {
disableButton()
}

// TODO-Milad separate the codes in multiple functions
override fun initUiListener() {

buttonListener()
resendCodeListener()
pinEntryEditTextListener()

}

private fun buttonListener() {

mButton.setOnClickListener { bind() }

}

private fun resendCodeListener() {

mTextViewResendCode.setOnClickListener {

if (!mIsRunning) {
Expand All @@ -66,6 +78,9 @@ class CodeVerificationFragment : BaseFragment() {

}
}
}

private fun pinEntryEditTextListener() {

mPinEntryEditText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(p0: Editable?) {
Expand All @@ -87,14 +102,15 @@ class CodeVerificationFragment : BaseFragment() {
}
}
})
}

override fun initObserver() {

observeBindLiveData()
}

override fun initUiComponent() {

//TODO-Milad Add initObservers
observeViewModel()

}

private fun bind() {
Expand All @@ -118,14 +134,12 @@ class CodeVerificationFragment : BaseFragment() {
"082016"
)
)

}

private fun observeViewModel() {
private fun observeBindLiveData() {

mCodeVerificationViewModel.getBindLiveData().observe(this, Observer {


when (it.status) {
Status.LOADING -> {
}
Expand Down Expand Up @@ -180,5 +194,4 @@ class CodeVerificationFragment : BaseFragment() {

mButton.isEnabled = true
}

}

0 comments on commit fe9f6a6

Please sign in to comment.