Skip to content

Commit

Permalink
Only call profileViewModel if attendee
Browse files Browse the repository at this point in the history
  • Loading branch information
leahlud committed Feb 24, 2024
1 parent a3c6c73 commit 8c4c619
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ class ProfileFragment : Fragment() {

override fun onPause() {
super.onPause()
profileViewModel.stopTimer()
if (isAttendee()) {
profileViewModel.stopTimer()
}
}

override fun onResume() {
super.onResume()
profileViewModel.startTimer()
if (isAttendee()) {
profileViewModel.startTimer()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -185,4 +189,10 @@ class ProfileFragment : Fragment() {
val prefString = context.getString(R.string.authorization_pref_file_key)
return context.getSharedPreferences(prefString, Context.MODE_PRIVATE).getString("provider", "") ?: "" == "google"
}

private fun isAttendee(): Boolean {
val context = requireActivity().applicationContext
val prefString = context.getString(R.string.authorization_pref_file_key)
return context.getSharedPreferences(prefString, Context.MODE_PRIVATE).getString("provider", "") ?: "" == "github"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ProfileViewModel : ViewModel() {
timerObj = Timer()
val timerTaskObj: TimerTask = object : TimerTask() {
override fun run() {
Log.d("QR FETCH", "...")
qr = qrRepository.fetch()
}
}
Expand Down

0 comments on commit 8c4c619

Please sign in to comment.