aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp/src/main/java')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt2
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt2
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt1
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt12
4 files changed, 14 insertions, 3 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt
index a8efbf2..9331dcc 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt
@@ -15,7 +15,7 @@ class TrackerApp: Application() {
super.onCreate()
val appModule = module {
- single { "https://etbsa.net/api/" }
+ single { "https://etbsa.net/api" }
single { SessionApi(get()) }
viewModel { LoginViewModel(get(), get()) }
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt
index 3aec7b8..3fbab80 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt
@@ -1,8 +1,6 @@
package mx.trackermap.TrackerMap.android.session
import android.os.Bundle
-import android.os.PersistableBundle
-import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import mx.trackermap.TrackerMap.android.R
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
index 5039a7c..82d11d1 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
@@ -32,6 +32,7 @@ class LoginFragment : Fragment() {
setupEvents()
setupObservers()
+ loginViewModel.restoreSession()
}
override fun onDestroyView() {
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt
index 9df78aa..82c5bf9 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt
@@ -29,6 +29,18 @@ class LoginViewModel(
private val loginResultEmitter = EventEmitter<LoginResult>()
val loginResult: EventSource<LoginResult> = loginResultEmitter
+ fun restoreSession() {
+ viewModelScope.launch {
+ try {
+ val user = sessionApi.sessionGet()
+ Log.d("LoginViewModel", user.toString())
+ loginResultEmitter.emit(LoginResult.Success)
+ } catch (e: Exception) {
+ Log.d("LoginViewModel", "No session")
+ }
+ }
+ }
+
fun login() {
val email = email.value!!.toString().trim()
val password = password.value!!.toString().trim()