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

Commit

Permalink
Code enhancement on code verification , closed #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Miladsalimiiiii committed Jul 28, 2019
1 parent aded398 commit 7b093c9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.netalic.peacock">
xmlns:tools="http://schemas.android.com/tools" package="de.netalic.peacock">

<uses-permission android:name="android.permission.INTERNET"/>

Expand All @@ -11,9 +11,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="de.netalic.MyApp">
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustPan">
android:name="de.netalic.MyApp"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/de/netalic/peacock/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class MainActivity : AppCompatActivity() {
supportFragmentManager.beginTransaction().add(R.id.frameLayout_mainActivity_fragmentContainer,
CodeVerificationFragment()).commit()
}

}
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 @@ -7,11 +7,13 @@ import androidx.fragment.app.Fragment
abstract class BaseFragment : Fragment() {

abstract fun initUiListener()
abstract fun initUiComponent()

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

initUiListener()
initUiComponent()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import io.reactivex.disposables.CompositeDisposable

open class BaseViewModel:ViewModel() {

var mCompositDisposable=CompositeDisposable()
var mCompositeDisposable=CompositeDisposable()

override fun onCleared() {
super.onCleared()
mCompositeDisposable.clear()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import de.netalic.peacock.R

import de.netalic.peacock.data.model.Status
import de.netalic.peacock.data.model.User
import de.netalic.peacock.ui.base.BaseFragment
import de.netalic.peacock.ui.util.CommonUtils
import kotlinx.android.synthetic.main.fragment_codeverification.*
import org.koin.android.viewmodel.ext.android.viewModel
import java.util.concurrent.TimeUnit


class CodeVerificationFragment : BaseFragment() {


companion object {

var sTimer = 30000
Expand All @@ -33,22 +32,20 @@ class CodeVerificationFragment : BaseFragment() {

private val mCodeVerificationViewModel: CodeVerificationViewModel by viewModel()

private val mImageView by lazy { imageView_codeVerification_icon }
private val mTextViewPhoneNumber by lazy { textView_codeVerification_phoneNumber }
private val mPinEntryEditText by lazy { pinEntryEditText_codeVerification_setPin }
private val mButton by lazy { button_codeVerification_continue }
private val mTextViewTimer by lazy { textView_codeVerification_resendTime }

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

mView = inflater.inflate(de.netalic.peacock.R.layout.fragment_codeverification, container, false)
mView = inflater.inflate(R.layout.fragment_codeverification, container, false)
return mView
}

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

observeViewModel()

setTimer()
disableButton()

Expand Down Expand Up @@ -84,6 +81,7 @@ class CodeVerificationFragment : BaseFragment() {
if (p0!!.length == 6) {

enableButton()
CommonUtils.hideSoftKeyboard(requireActivity())
} else {
disableButton()
}
Expand All @@ -92,6 +90,12 @@ class CodeVerificationFragment : BaseFragment() {

}

override fun initUiComponent() {

observeViewModel()

}

private fun bind() {

mCodeVerificationViewModel.bind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CodeVerificationViewModel(private val userRepository: UserRepository) : Ba

})

mCompositDisposable.add(disposable)
mCompositeDisposable.add(disposable)
}

}
17 changes: 17 additions & 0 deletions app/src/main/java/de/netalic/peacock/ui/util/CommonUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.netalic.peacock.ui.util

import android.app.Activity
import android.view.inputmethod.InputMethodManager
import androidx.fragment.app.FragmentActivity

object CommonUtils {

fun hideSoftKeyboard(activity: FragmentActivity) {
val inputMethodManager = activity.getSystemService(
Activity.INPUT_METHOD_SERVICE
) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(
activity.currentFocus!!.windowToken, 0
)
}
}

0 comments on commit 7b093c9

Please sign in to comment.