Commit 6d0def63 by Paktalin

Removed views initialization in Kotlin SignInActivity

parent f0b97423
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="errors">
<ArgumentParseErrors />
</option>
</component>
</project>
\ No newline at end of file
...@@ -22,7 +22,7 @@ dependencies { ...@@ -22,7 +22,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02' implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.2.30" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'com.google.firebase:firebase-core:16.0.3' implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1' implementation 'com.google.firebase:firebase-database:16.0.1'
...@@ -36,3 +36,4 @@ dependencies { ...@@ -36,3 +36,4 @@ dependencies {
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
\ No newline at end of file
...@@ -5,31 +5,23 @@ import android.support.v7.app.AppCompatActivity ...@@ -5,31 +5,23 @@ import android.support.v7.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast import android.widget.Toast
import com.google.android.gms.signin.SignIn import com.google.android.gms.signin.SignIn
import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseAuth
import kotlinx.android.synthetic.main.activity_sign_in.*
class SignInActivity : AppCompatActivity() { class SignInActivity : AppCompatActivity() {
private var mEmailEt: EditText? = null
private var mPasswordEt: EditText? = null
private var mSignInBtn: Button? = null
private var mSignUpBtn: Button? = null
private var mAuth: FirebaseAuth? = null private var mAuth: FirebaseAuth? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_in) setContentView(R.layout.activity_sign_in)
initializeViews()
mAuth = FirebaseAuth.getInstance() mAuth = FirebaseAuth.getInstance()
mSignInBtn!!.setOnClickListener({ signIn() }) btnSignIn!!.setOnClickListener({ signIn() })
mSignUpBtn!!.setOnClickListener({ signUp() }) btnSignUp!!.setOnClickListener({ signUp() })
} }
override fun onStart() { override fun onStart() {
...@@ -38,16 +30,9 @@ class SignInActivity : AppCompatActivity() { ...@@ -38,16 +30,9 @@ class SignInActivity : AppCompatActivity() {
if (currentUser != null) startUserActivity() if (currentUser != null) startUserActivity()
} }
private fun initializeViews() {
mEmailEt = findViewById(R.id.email)
mPasswordEt = findViewById(R.id.password)
mSignInBtn = findViewById(R.id.btn_sign_in)
mSignUpBtn = findViewById(R.id.btn_sign_up)
}
private fun signIn() { private fun signIn() {
val email = mEmailEt!!.text.toString() val email = etEmail!!.text.toString()
val password = mPasswordEt!!.text.toString() val password = etPassword!!.text.toString()
if (fieldsNotEmpty(email, password)) { if (fieldsNotEmpty(email, password)) {
mAuth!!.signInWithEmailAndPassword(email, password) mAuth!!.signInWithEmailAndPassword(email, password)
...@@ -64,8 +49,8 @@ class SignInActivity : AppCompatActivity() { ...@@ -64,8 +49,8 @@ class SignInActivity : AppCompatActivity() {
} }
private fun signUp() { private fun signUp() {
val email = mEmailEt!!.text.toString() val email = etEmail!!.text.toString()
val password = mPasswordEt!!.text.toString() val password = etPassword!!.text.toString()
if (fieldsNotEmpty(email, password)) { if (fieldsNotEmpty(email, password)) {
mAuth!!.createUserWithEmailAndPassword(email, password) mAuth!!.createUserWithEmailAndPassword(email, password)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
tools:context=".SignInActivity"> tools:context=".SignInActivity">
<EditText <EditText
android:id="@+id/email" android:id="@+id/etEmail"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
android:ems="10" android:ems="10"
android:hint="@string/email_hint" android:hint="@string/email_hint"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
app:layout_constraintBottom_toTopOf="@+id/password" app:layout_constraintBottom_toTopOf="@+id/etPassword"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" /> app:layout_constraintVertical_chainStyle="packed" />
<EditText <EditText
android:id="@+id/password" android:id="@+id/etPassword"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
android:ems="10" android:ems="10"
android:hint="@string/password_hint" android:hint="@string/password_hint"
android:inputType="textPassword" android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/btn_sign_in" app:layout_constraintBottom_toTopOf="@+id/btnSignIn"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/email" /> app:layout_constraintTop_toBottomOf="@+id/etEmail" />
<Button <Button
android:id="@+id/btn_sign_in" android:id="@+id/btnSignIn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
...@@ -56,13 +56,13 @@ ...@@ -56,13 +56,13 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/sign_in_text" android:text="@string/sign_in_text"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_sign_up" app:layout_constraintEnd_toStartOf="@id/btnSignUp"
app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password" /> app:layout_constraintTop_toBottomOf="@+id/etPassword" />
<Button <Button
android:id="@+id/btn_sign_up" android:id="@+id/btnSignUp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:text="Sign Up" android:text="Sign Up"
app:layout_constraintBottom_toBottomOf="@+id/btn_sign_in" app:layout_constraintBottom_toBottomOf="@+id/btnSignIn"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btn_sign_in" app:layout_constraintStart_toEndOf="@+id/btnSignIn"
app:layout_constraintTop_toTopOf="@+id/btn_sign_in" /> app:layout_constraintTop_toTopOf="@+id/btnSignIn" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment