Commit e1a07d1b authored by Tim Geronimo Wagner's avatar Tim Geronimo Wagner

Fix open MainActivity after logout

parent baa3ee4f
Pipeline #246 failed with stages
in 3 minutes and 14 seconds
......@@ -19,7 +19,8 @@
<activity android:name=".features.dashboard.MainActivity"
android:launchMode="singleTop"/>
<activity android:name=".features.login.LoginActivity">
<activity android:name=".features.login.LoginActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
......
......@@ -16,6 +16,7 @@ import de.akamu.tudarmstadt.features.profile.ProfileActivity
import de.akamu.tudarmstadt.model.Avatar
import de.akamu.tudarmstadt.model.User
import de.akamu.tudarmstadt.util.AppUserUtil
import de.akamu.tudarmstadt.util.Constants
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity(), DashboardContract.View {
......@@ -25,10 +26,6 @@ class MainActivity : AppCompatActivity(), DashboardContract.View {
private var user: User? = null
private val DUEL_LIST_FRAGMENT = 1
private val CHALLENGE_FRAGMENT = 2
private val MEMORY_STORE_FRAGMENT = 3
// The current fragment visible in the fragments_frame_dashboard
private var activeFragment = 0
......@@ -49,7 +46,7 @@ class MainActivity : AppCompatActivity(), DashboardContract.View {
}
override fun navigateToProfile() {
startActivity(Intent(this, ProfileActivity::class.java))
startActivityForResult(Intent(this, ProfileActivity::class.java), Constants.MAIN_ACTIVITY_REQ_CODE)
overridePendingTransition(R.anim.fade_in_medium, R.anim.fade_out_medium)
}
......@@ -58,6 +55,12 @@ class MainActivity : AppCompatActivity(), DashboardContract.View {
overridePendingTransition(R.anim.fade_in_medium, R.anim.fade_out_medium)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
Constants.MAIN_ACTIVITY_REQ_CODE -> finishActivity()
}
}
@Suppress("UNUSED_PARAMETER")
fun navigateToSettings(v: View) = navigateToSettings()
......@@ -67,36 +70,36 @@ class MainActivity : AppCompatActivity(), DashboardContract.View {
}
override fun navigateToDuelList() {
if (activeFragment == DUEL_LIST_FRAGMENT) return
if (activeFragment == Constants.DUEL_LIST_FRAGMENT) return
supportFragmentManager.beginTransaction()
.replace(R.id.fragments_frame_dashboard, DuelListFragment.newInstance())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit()
activeFragment = DUEL_LIST_FRAGMENT
activeFragment = Constants.DUEL_LIST_FRAGMENT
}
override fun navigateToChallenge() {
if (activeFragment == CHALLENGE_FRAGMENT) return
if (activeFragment == Constants.CHALLENGE_FRAGMENT) return
supportFragmentManager.beginTransaction()
.replace(R.id.fragments_frame_dashboard, GameModeFragment.newInstance())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit()
activeFragment = CHALLENGE_FRAGMENT
activeFragment = Constants.CHALLENGE_FRAGMENT
}
override fun navigateToMemoryStore() {
if (activeFragment == MEMORY_STORE_FRAGMENT) return
if (activeFragment == Constants.MEMORY_STORE_FRAGMENT) return
supportFragmentManager.beginTransaction()
.replace(R.id.fragments_frame_dashboard, MemoryStoreFragment.newInstance())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit()
activeFragment = MEMORY_STORE_FRAGMENT
activeFragment = Constants.MEMORY_STORE_FRAGMENT
}
......
......@@ -26,7 +26,6 @@ class LoginActivity : AppCompatActivity(), LoginContract.View {
override fun onStart() {
super.onStart()
logo_login.start()
presenter.autoLogin()
}
......@@ -35,6 +34,8 @@ class LoginActivity : AppCompatActivity(), LoginContract.View {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
logo_login.start()
login_button.setOnClickListener {
val username: String = login_username_input.text.toString()
val password: String = login_password_input.text.toString()
......
......@@ -18,6 +18,7 @@ import de.akamu.tudarmstadt.features.title.TitleActivity
import de.akamu.tudarmstadt.model.Avatar
import de.akamu.tudarmstadt.model.User
import de.akamu.tudarmstadt.util.AppUserUtil
import de.akamu.tudarmstadt.util.Constants
import kotlinx.android.synthetic.main.activity_profile.*
class ProfileActivity : AppCompatActivity(), ProfileContract.View, ViewPager.PageTransformer {
......@@ -191,7 +192,8 @@ class ProfileActivity : AppCompatActivity(), ProfileContract.View, ViewPager.Pag
sb.show()
}
override fun finishActivity() {
override fun finishActivities() {
finish()
finishActivity(Constants.MAIN_ACTIVITY_REQ_CODE)
}
}
......@@ -43,9 +43,9 @@ interface ProfileContract {
fun showPointsNeeded(pointsMissing: Int)
/**
* Finish the ProfileActivity
* Finish the ProfileActivity and MainActivity
*/
fun finishActivity()
fun finishActivities()
}
......
......@@ -49,7 +49,7 @@ class ProfilePresenter(private val view: ProfileContract.View) : ProfileContract
override fun logout() {
view.destroyLoginToken()
view.navigateToLogin()
view.finishActivity()
view.finishActivities()
}
}
\ 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 to comment