Skip to content

Commit

Permalink
Version Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
baronhsieh2005 committed Sep 9, 2024
1 parent 8469628 commit b0b1ab9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.pennapps.labs.pennmobile

import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
Expand Down Expand Up @@ -242,27 +243,29 @@ class GsrFragment : Fragment() {

private fun updateStatus() {
mActivity.mNetworkManager.getAccessToken {
val bearerToken =
sharedPreferences.getString(getString(R.string.access_token), "").toString()
checkIfFragmentAttached {
val bearerToken =
sharedPreferences.getString(getString(R.string.access_token), "").toString()

if (bearerToken.isEmpty()) {
Toast.makeText(activity, "You are not logged in!", Toast.LENGTH_LONG).show()
} else {
try {
mStudentLife
.isWharton(
"Bearer $bearerToken",
)?.subscribe(
{ status ->
isWharton = status.isWharton
},
{
Log.e("GsrFragment", "Error getting Wharton status", it)
isWharton = false
},
)
} catch (e: Exception) {
e.printStackTrace()
if (bearerToken.isEmpty()) {
Toast.makeText(activity, "You are not logged in!", Toast.LENGTH_LONG).show()
} else {
try {
mStudentLife
.isWharton(
"Bearer $bearerToken",
)?.subscribe(
{ status ->
isWharton = status.isWharton
},
{
Log.e("GsrFragment", "Error getting Wharton status", it)
isWharton = false
},
)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
Expand Down Expand Up @@ -681,4 +684,9 @@ class GsrFragment : Fragment() {
mGSRS.add(newGSRObject)
}
}
fun checkIfFragmentAttached(operation: Context.() -> Unit) {
if (isAdded && context != null) {
operation(requireContext())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ class MenuFragment : Fragment() {
super.onCreate(savedInstanceState)
mDiningHall = arguments?.getParcelable("DiningHall")
mActivity = activity as MainActivity
mActivity.toolbar.visibility = View.VISIBLE
setHasOptionsMenu(true)
mActivity.hideBottomBar()
}

override fun onCreateView(
Expand All @@ -105,6 +103,8 @@ class MenuFragment : Fragment() {
pager.adapter = pageAdapter
v.setBackgroundColor(Color.WHITE)
mActivity.addTabs(pageAdapter as TabAdapter, pager, true)
mActivity.toolbar.visibility = View.VISIBLE
mActivity.hideBottomBar()
return v
}

Expand Down

0 comments on commit b0b1ab9

Please sign in to comment.