Skip to content

Commit

Permalink
Route to dashboard if session is active
Browse files Browse the repository at this point in the history
Add button for clearing session
  • Loading branch information
HenryKenya committed Apr 15, 2020
1 parent b46f422 commit 64e2428
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ class DashboardActivity : AppCompatActivity() {
val token = SessionManagerUtil.getUserToken(this)
textToken.text = token
textSessionStatus.text = sessionStatus.toString()

button2.setOnClickListener { endSession() }
}

private fun endSession() {
SessionManagerUtil.endUserSession(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import ke.co.skylinedesign.session_manager.SessionManagerUtil
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val currentTime = Calendar.getInstance().time

val sessionIsActive = SessionManagerUtil.isSessionActive(currentTime, this)

if (sessionIsActive) startActivity(Intent(this, DashboardActivity::class.java))

button.setOnClickListener {
SessionManagerUtil.startUserSession(this, 60)
Expand Down

0 comments on commit 64e2428

Please sign in to comment.