Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. class LoginFragment : Fragment() {
  2.  
  3. override fun onCreateView(
  4. inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  5. val view = inflater.inflate(R.layout.shr_login_fragment, container, false)
  6. view.next_button.setOnClickListener {
  7. if (!isPasswordValid(password_edit_text.text!!)) {
  8. password_text_input.error = getString(R.string.shr_error_password)
  9. } else {
  10. password_text_input.error = null
  11. (activity as NavigationHost).navigateTo(ProductGridFragment(), false)
  12. }
  13. }
  14.  
  15. view.password_edit_text.setOnKeyListener { _, _, _ ->
  16. if (isPasswordValid(password_edit_text.text!!)) {
  17. password_text_input.error = null
  18. }
  19. false
  20. }
  21.  
  22. return view
  23. }
  24.  
  25. private fun isPasswordValid(text: Editable?): Boolean {
  26. return text != null && text.length >= 8
  27. }
  28.  
  29. }
Add Comment
Please, Sign In to add comment