Skip to content

Commit

Permalink
Get rid of some of the warnings we have. Cleaning code is mildly ther…
Browse files Browse the repository at this point in the history
…apeutic :).
  • Loading branch information
meiron03 committed Dec 15, 2023
1 parent 16672cc commit e5c585e
Show file tree
Hide file tree
Showing 33 changed files with 66 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.pennapps.labs.pennmobile

import android.content.Context
import android.graphics.Color
import android.net.ConnectivityManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -113,13 +111,6 @@ class DiningInfoFragment : Fragment() {
return vertical
}

private val isNetworkAvailable: Boolean
get() {
val connectivityManager = mActivity.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
return activeNetworkInfo != null && activeNetworkInfo.isConnected
}

override fun onDestroyView() {
setHasOptionsMenu(false)
super.onDestroyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DiningInsightsFragment : Fragment() {
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View {
_binding = FragmentDiningInsightsBinding.inflate(inflater, container, false)
val view = binding.root

Expand Down Expand Up @@ -101,9 +101,6 @@ class DiningInsightsFragment : Fragment() {
}
}

override fun onResume() {
super.onResume()
}

private fun refresh() {
val accessToken = networkManager.getAccessToken()
Expand All @@ -127,7 +124,7 @@ class DiningInsightsFragment : Fragment() {
private fun getInsights(accessToken: String?) {
if (!isOnline(context)) {
binding.internetConnectionDiningInsights.setBackgroundColor(resources.getColor(R.color.darkRedBackground))
binding.internetConnectionMessageDiningInsights.setText("Not Connected to Internet")
binding.internetConnectionMessageDiningInsights.text = "Not Connected to Internet"
binding.internetConnectionDiningInsights.visibility = View.VISIBLE
binding.diningInsightsRefresh.isRefreshing = false
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.pennapps.labs.pennmobile.adapters.DiningSettingsAdapter
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.DiningHall
import com.pennapps.labs.pennmobile.classes.DiningRequest
Expand Down Expand Up @@ -37,7 +36,7 @@ class DiningSettingsFragment : Fragment() {
mActivity.hideBottomBar()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentDiningPreferencesBinding.inflate(inflater, container, false)
val v = binding.root
binding.diningHallRv.layoutManager = LinearLayoutManager(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FitnessHolderFragment: Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
super.onCreateView(inflater, container, savedInstanceState)
_binding = FragmentFitnessHolderBinding.inflate(inflater, container, false)
return binding.root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pennapps.labs.pennmobile

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pennapps.labs.pennmobile

import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
Expand All @@ -12,11 +11,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.*
import android.widget.AdapterView.OnItemSelectedListener
import androidx.annotation.RequiresApi
import androidx.preference.PreferenceManager
import com.google.firebase.analytics.FirebaseAnalytics
import com.pennapps.labs.pennmobile.adapters.GsrBuildingAdapter
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.GSRContainer
import com.pennapps.labs.pennmobile.classes.GSRRoom
Expand Down Expand Up @@ -99,7 +96,6 @@ class GsrFragment : Fragment() {
_binding = null
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
selectDateButton = binding.gsrSelectDate
selectTimeButton = binding.gsrSelectTime
Expand Down Expand Up @@ -144,7 +140,7 @@ class GsrFragment : Fragment() {

// Launch Time Picker Dialog
val timePickerDialog = TimePickerDialog(activity,
TimePickerDialog.OnTimeSetListener { _, hourOfDay, minute ->
{ _, hourOfDay, minute ->

// Update hour + minute
selectedDateTime = DateTime(selectedDateTime.year, selectedDateTime.monthOfYear, selectedDateTime.dayOfMonth, hourOfDay, minute)
Expand All @@ -165,7 +161,7 @@ class GsrFragment : Fragment() {
val mDay = c.get(Calendar.DAY_OF_MONTH)

val datePickerDialog = DatePickerDialog(mActivity,
DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
{ _, year, monthOfYear, dayOfMonth ->
//account for index starting at 0
val entryMonth = monthOfYear + 1

Expand Down Expand Up @@ -207,9 +203,9 @@ class GsrFragment : Fragment() {
private fun updateStatus() {
mActivity.mNetworkManager.getAccessToken {
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
bearerToken = sp.getString(getString(R.string.access_token), "").toString();
bearerToken = sp.getString(getString(R.string.access_token), "").toString()

if (bearerToken.isNullOrEmpty()) {
if (bearerToken.isEmpty()) {
Toast.makeText(activity, "You are not logged in!", Toast.LENGTH_LONG).show()
} else {
mStudentLife.isWharton(
Expand Down Expand Up @@ -240,14 +236,14 @@ class GsrFragment : Fragment() {
populateDropDownGSR()
}
}
var gsrLocation = gsrLocationDropDown.selectedItem.toString()
val gsrLocation = gsrLocationDropDown.selectedItem.toString()
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();
bearerToken = sp.getString(getString(R.string.access_token), "").toString()

if (location.isNullOrEmpty() || bearerToken.isNullOrEmpty()) {
if (location.isEmpty() || bearerToken.isEmpty()) {
showNoResults()
} else {
// display loading screen if user did not use swipe refresh
Expand Down Expand Up @@ -287,9 +283,9 @@ class GsrFragment : Fragment() {

mActivity.mNetworkManager.getAccessToken {
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
bearerToken = sp.getString(getString(R.string.access_token), "").toString();
bearerToken = sp.getString(getString(R.string.access_token), "").toString()

Log.i("GsrFragment", "Bearer Token: $bearerToken");
Log.i("GsrFragment", "Bearer Token: $bearerToken")
Log.i("GsrFragment", "Wharton Status: $isWharton")

mStudentLife.gsrRoom(
Expand Down Expand Up @@ -331,7 +327,7 @@ class GsrFragment : Fragment() {
}

binding.gsrRoomsList.adapter = (context?.let {
GsrBuildingAdapter(it, mGSRS, location.toString(), (durationDropDown.selectedItemPosition + 1) * 30, sortByTime)
GsrBuildingAdapter(it, mGSRS, location, (durationDropDown.selectedItemPosition + 1) * 30, sortByTime)

})

Expand Down Expand Up @@ -426,9 +422,9 @@ class GsrFragment : Fragment() {
// go through all the rooms
while (i < numLocations) {
val locationName = locations[i]?.name ?: ""
if (locationName.isNullOrEmpty()) {
if (locationName.isEmpty()) {
Log.w("Empty location name",
locations[i].id ?: locations[i].gid.toString());
locations[i].id ?: locations[i].gid.toString())
}
gsrHashMap[locationName] = locations[i].id
gsrGIDHashMap[locationName] = locations[i].gid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import android.view.View
import android.view.ViewGroup
import com.google.firebase.analytics.FirebaseAnalytics
import com.pennapps.labs.pennmobile.adapters.GsrReservationsAdapter
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.databinding.FragmentGsrReservationsBinding

import kotlinx.android.synthetic.main.loading_panel.loadingPanel
Expand Down Expand Up @@ -43,7 +42,7 @@ class GsrReservationsFragment : Fragment() {
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View {
_binding = FragmentGsrReservationsBinding.inflate(inflater, container, false)
val view = binding.root

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GsrTabbedFragment : Fragment() {
private val binding get() = _binding!!

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View {
// Inflate the layout for this fragment
_binding = FragmentGsrTabsBinding.inflate(inflater, container, false)
val view = binding.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HomeFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
_binding = FragmentHomeBinding.inflate(inflater, container, false)
val view = binding.root

Expand Down Expand Up @@ -203,9 +203,9 @@ class HomeFragment : Fragment() {
venues.add(1442)
venues.add(636)
} else {
list?.forEach({
list?.forEach {
it.id?.let { it1 -> venues.add(it1) }
})
}

}
diningCellInfo.venues = venues
Expand Down Expand Up @@ -272,7 +272,6 @@ class HomeFragment : Fragment() {

studentLife.getLaundryPref(bearerToken).subscribe({ preferences ->
mActivity.runOnUiThread {
val venues = mutableListOf<Int>()
val laundryCell = HomeCell()
laundryCell.type = "laundry"
val laundryCellInfo = HomeCellInfo()
Expand Down Expand Up @@ -418,7 +417,7 @@ class HomeFragment : Fragment() {
this.setTitle(getString(R.string.home))
mActivity.toolbar.visibility = View.GONE
val initials = sharedPreferences.getString(getString(R.string.initials), null)
if (initials != null && initials.isNotEmpty()) {
if (!initials.isNullOrEmpty()) {
binding.initials.text = initials
} else {
binding.profileBackground.setImageDrawable(
Expand Down Expand Up @@ -452,20 +451,4 @@ class HomeFragment : Fragment() {
//TODO: Account Settings
}
}

/**
* Show a SnackBar message right below the app bar
*/
@Suppress("DEPRECATION")
private fun displaySnack(view: View, text: String) {
(view as ViewGroup).showSneakerToast(message = text, doOnRetry = { }, sneakerColor = R.color.sneakerBlurColorOverlay)
}

enum class Cells {
POLLS, NEWS, DINING, CALENDAR, LAUNDRY, POSTS
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.webkit.CookieManager
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.GSRBookingResult
import com.pennapps.labs.pennmobile.databinding.FragmentHuntsmanGsrloginBinding
Expand Down Expand Up @@ -52,7 +51,7 @@ class HuntsmanGSRLogin : Fragment() {
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View {
// Inflate the layout for this fragment
_binding = FragmentHuntsmanGsrloginBinding.inflate(inflater, container, false)
return binding.root
Expand Down Expand Up @@ -100,7 +99,7 @@ class HuntsmanGSRLogin : Fragment() {
editor.apply()
if (startTime.substring(9,13) == "2330") {
val newDay = endTime[7] + 1
var newEndTime = endTime.substring(0,7) + newDay + endTime.substring(8,endTime.length)
val newEndTime = endTime.substring(0,7) + newDay + endTime.substring(8,endTime.length)
endTime = newEndTime
}
bookHuntsmanGSR(bearerToken, sessionid)
Expand Down Expand Up @@ -168,20 +167,4 @@ class HuntsmanGSRLogin : Fragment() {
)
}
}

companion object {

fun newInstance(gsrID: String, gsrLocationCode: String, startTime: String, endTime: String, gid: Int, roomName: String): HuntsmanGSRLogin {
val fragment = HuntsmanGSRLogin()
val args = Bundle()
args.putString("gsrID", gsrID)
args.putString("gsrLocationCode", gsrLocationCode)
args.putString("startTime", startTime)
args.putString("endTime", endTime)
args.putInt("gid", gid)
args.putString("roomName", roomName)
fragment.arguments = args
return fragment
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ class LaundryFragment : Fragment() {
if (laundryRoomsResult.size == count) {

// sort laundry rooms data by hall name
roomsDataResult.sortWith(Comparator { usage1, usage2 -> usage2.id - usage1.id })
roomsDataResult.sortWith { usage1, usage2 -> usage2.id - usage1.id }

// sort laundry rooms by name
laundryRoomsResult.sortWith(Comparator { room1, room2 -> room2.id - room1.id })
laundryRoomsResult.sortWith { room1, room2 -> room2.id - room1.id }

// update UI
mActivity.runOnUiThread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LaundrySettingsFragment : Fragment() {
FirebaseAnalytics.getInstance(mContext).logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentLaundrySettingsBinding.inflate(inflater, container, false)
val view = binding.root

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LoginFragment : Fragment() {
mActivity.closeKeyboard()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentLoginBinding.inflate(inflater, container, false)
val v = binding.root

Expand Down
Loading

0 comments on commit e5c585e

Please sign in to comment.