Commit f3574940 by Paktalin

Isolated logOut and startActivity functions

parent 757b3b59
......@@ -7,10 +7,7 @@ import android.os.Bundle
import android.util.Log
import com.paktalin.vocabularynotebook.*
import com.paktalin.vocabularynotebook.utils.fieldsNotEmpty
import com.paktalin.vocabularynotebook.utils.shortToast
import com.paktalin.vocabularynotebook.utils.signUp
import com.paktalin.vocabularynotebook.utils.userLoggedIn
import com.paktalin.vocabularynotebook.utils.*
import kotlinx.android.synthetic.main.activity_log_in.*
class LogInActivity : AppCompatActivity() {
......@@ -53,8 +50,7 @@ class LogInActivity : AppCompatActivity() {
fun startUserActivity() {
Log.d(TAG, "Logged in successfully")
val userActivityIntent = Intent(this@LogInActivity, MainActivity::class.java)
startActivity(userActivityIntent)
startActivity(this@LogInActivity, MainActivity::class.java)
}
private fun addProgressBar() {
......
package com.paktalin.vocabularynotebook.ui.activities
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import com.google.firebase.auth.FirebaseAuth
import kotlinx.android.synthetic.main.activity_main.*
import android.view.WindowManager
......@@ -20,6 +18,7 @@ import com.paktalin.vocabularynotebook.ui.fragments.VocabularyFragment
import com.paktalin.vocabularynotebook.utils.addFragment
import com.paktalin.vocabularynotebook.utils.extractVocabularyData
import com.paktalin.vocabularynotebook.utils.shortToast
import com.paktalin.vocabularynotebook.utils.startActivity
class MainActivity : AppCompatActivity() {
......@@ -48,10 +47,8 @@ class MainActivity : AppCompatActivity() {
}
private fun logOut() {
Log.i(TAG, "User logged out")
FirebaseAuth.getInstance()!!.signOut()
val intentLogInActivity = Intent(this@MainActivity, LogInActivity::class.java)
startActivity(intentLogInActivity)
logOut()
startActivity(this@MainActivity, LogInActivity::class.java)
}
private fun setUpNavigationView() {
......
package com.paktalin.vocabularynotebook.utils
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
......@@ -48,3 +49,7 @@ fun enableScrolling(mainActivity: MainActivity) {
fun shortToast(context: Context, text: String) {
Toast.makeText(context, text, Toast.LENGTH_SHORT).show()
}
fun startActivity(context: Context, cls: Class<*>) {
context.startActivity(Intent(context, cls))
}
\ No newline at end of file
......@@ -3,12 +3,7 @@ package com.paktalin.vocabularynotebook.utils
import android.util.Log
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import com.paktalin.vocabularynotebook.ui.activities.LogInActivity
import com.paktalin.vocabularynotebook.firestoreitems.UserPojo
import com.paktalin.vocabularynotebook.firestoreitems.Vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import java.util.*
private const val TAG = "VN/UserManager"
private var mAuth: FirebaseAuth? = FirebaseAuth.getInstance()
......@@ -49,3 +44,8 @@ fun signUp(activity: LogInActivity, email: String, password: String) {
fun userLoggedIn(): Boolean {
return mAuth!!.currentUser != null
}
fun logOut() {
mAuth!!.signOut()
Log.i(TAG, "User logged out")
}
\ 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