Skip to content

Commit

Permalink
Added an internet check connectivty to register page
Browse files Browse the repository at this point in the history
  • Loading branch information
V1rex committed Feb 10, 2019
1 parent 2624296 commit 75c7324
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.v1rex.smartincubator.Activities

import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.support.design.widget.TextInputLayout
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
Expand Down Expand Up @@ -58,7 +60,10 @@ class RegisterActivity : AppCompatActivity() {
val password = password_register_edit_text.text.toString()


if (TextUtils.isEmpty(password)) {
if(!isNetworkAvailable()){
input_layout_password_register.error = getString(R.string.error_internet_required)
cancel = true
} else if (TextUtils.isEmpty(password)) {
input_layout_password_register.error = getString(R.string.error_field_password_required)
cancel = true
} else if (!isPasswordValid(password)) {
Expand Down Expand Up @@ -96,6 +101,12 @@ class RegisterActivity : AppCompatActivity() {
}
}

private fun isNetworkAvailable(): Boolean {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
return activeNetworkInfo != null && activeNetworkInfo.isConnected
}

/**
* Check if the email is good
* @param email
Expand Down

0 comments on commit 75c7324

Please sign in to comment.