diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt index e10feeb1..bf5be32b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt @@ -2,6 +2,7 @@ package com.pennapps.labs.pennmobile import android.app.DatePickerDialog import android.app.TimePickerDialog +import android.content.SharedPreferences import android.os.Bundle import android.util.Log import androidx.fragment.app.Fragment @@ -64,16 +65,17 @@ class GsrFragment : Fragment() { private var populatedDropDownGSR = false - private var bearerToken = "" private var isWharton = false private var sortByTime = false private lateinit var mActivity: MainActivity + private lateinit var sharedPreferences: SharedPreferences override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStudentLife = MainActivity.studentLifeInstance mActivity = activity as MainActivity + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mActivity) mActivity.closeKeyboard() // set default GSR selection date + time to the current date and time @@ -196,8 +198,7 @@ class GsrFragment : Fragment() { private fun updateStatus() { mActivity.mNetworkManager.getAccessToken { - val sp = PreferenceManager.getDefaultSharedPreferences(activity) - bearerToken = sp.getString(getString(R.string.access_token), "").toString() + 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() @@ -234,8 +235,7 @@ class GsrFragment : Fragment() { val location = mapGSR(gsrLocation) val gid = mapGID(gsrLocation) mActivity.mNetworkManager.getAccessToken { - val sp = PreferenceManager.getDefaultSharedPreferences(activity) - bearerToken = sp.getString(getString(R.string.access_token), "").toString() + val bearerToken = sharedPreferences.getString(getString(R.string.access_token), "").toString() if (location.isEmpty() || bearerToken.isEmpty()) { showNoResults() @@ -276,8 +276,7 @@ class GsrFragment : Fragment() { mActivity.mNetworkManager.getAccessToken { - val sp = PreferenceManager.getDefaultSharedPreferences(activity) - bearerToken = sp.getString(getString(R.string.access_token), "").toString() + val bearerToken = sharedPreferences.getString(getString(R.string.access_token), "").toString() Log.i("GsrFragment", "Bearer Token: $bearerToken") Log.i("GsrFragment", "Wharton Status: $isWharton") diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/DiningHall.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/DiningHall.kt index 6fb86d77..67e3d816 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/DiningHall.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/DiningHall.kt @@ -177,16 +177,15 @@ open class DiningHall : Parcelable { dest.writeString(name) } - companion object { - val CREATOR: Parcelable.Creator = object : Parcelable.Creator { - override fun createFromParcel(`in`: Parcel): Menu? { - return Menu(`in`) - } + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(`in`: Parcel): Menu? { + return Menu(`in`) + } - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } + override fun newArray(size: Int): Array { + return arrayOfNulls(size) } + } }