Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish adding try/catches for firebase logging. #599

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.pennapps.labs.pennmobile.adapters.GsrReservationsAdapter
import com.pennapps.labs.pennmobile.databinding.FragmentGsrReservationsBinding

Expand Down Expand Up @@ -96,22 +96,30 @@ class GsrReservationsFragment : Fragment() {
binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList(reservations))
loadingPanel?.visibility = View.GONE

if (reservations.size > 0) {
binding.gsrNoReservations.visibility = View.GONE
} else {
binding.gsrNoReservations.visibility = View.VISIBLE
try {
if (reservations.size > 0) {
binding.gsrNoReservations.visibility = View.GONE
} else {
binding.gsrNoReservations.visibility = View.VISIBLE
}
// stop refreshing
binding.gsrReservationsRefreshLayout.isRefreshing = false
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
}
// stop refreshing
binding.gsrReservationsRefreshLayout.isRefreshing = false
}
}, { throwable ->
mActivity.runOnUiThread {
Log.e("GsrReservationsFragment", "Error getting reservations", throwable)
binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList())
throwable.printStackTrace()
loadingPanel?.visibility = View.GONE
binding.gsrNoReservations.visibility = View.VISIBLE
binding.gsrReservationsRefreshLayout.isRefreshing = false
try {
binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList())
binding.gsrNoReservations.visibility = View.VISIBLE
binding.gsrReservationsRefreshLayout.isRefreshing = false
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.pennapps.labs.pennmobile.adapters.LaundryRoomAdapter
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.LaundryRoom
Expand Down Expand Up @@ -190,20 +191,27 @@ class LaundryFragment : Fragment() {
roomsData = roomsDataResult
laundryRooms = laundryRoomsResult
mAdapter = LaundryRoomAdapter(mContext, laundryRooms, roomsData, false)
binding.favoriteLaundryList.adapter = mAdapter
try {
binding.favoriteLaundryList.adapter = mAdapter
binding.laundryHelpText.visibility = View.INVISIBLE
binding.laundryMachineRefresh.isRefreshing = false
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
}
no_results?.visibility = View.GONE
loadingPanel?.visibility = View.GONE
binding.laundryHelpText.visibility = View.INVISIBLE
binding.laundryMachineRefresh.isRefreshing = false

}
}
}, {
mActivity.runOnUiThread {
try {
binding.laundryHelpText.visibility = View.GONE
binding.laundryMachineRefresh.isRefreshing = false
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
}
loadingPanel?.visibility = View.GONE
no_results?.visibility = View.VISIBLE
binding.laundryHelpText.visibility = View.GONE
binding.laundryMachineRefresh.isRefreshing = false
Log.e("Laundry", "Error getting laundry data: " + it.stackTrace)
}
})
Expand All @@ -224,8 +232,12 @@ class LaundryFragment : Fragment() {
mActivity.runOnUiThread {
loadingPanel?.visibility = View.GONE
no_results?.visibility = View.VISIBLE
binding.laundryHelpText.visibility = View.GONE
binding.laundryMachineRefresh.isRefreshing = false
try {
binding.laundryHelpText.visibility = View.GONE
binding.laundryMachineRefresh.isRefreshing = false
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
}
}
})
}
Expand Down
Loading