Made further documentation and safety changes. Scraper classes (StudIPParser.kt, StwParser.kt) still need to be checked for safety.

This commit is contained in:
denizk0461
2023-04-27 20:27:42 +02:00
parent 9d6489f83b
commit ccd77a5daf
57 changed files with 349 additions and 213 deletions
@@ -19,7 +19,9 @@ open class AppSheet(@LayoutRes private val layoutId: Int) : BottomSheetDialogFra
// Internal context object
private lateinit var _context: Context
// Get non-null context. Only valid after onAttach()
/**
* Get non-null context. Only valid after onAttach().
*/
override fun getContext(): Context = _context
override fun onAttach(context: Context) {
@@ -27,7 +29,6 @@ open class AppSheet(@LayoutRes private val layoutId: Int) : BottomSheetDialogFra
_context = context
}
// Inflate the given layout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
LayoutInflater.from(context).inflate(layoutId, container, false)
}
@@ -6,14 +6,15 @@ import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity
import androidx.transition.TransitionManager
import com.denizk0461.studip.R
import com.denizk0461.studip.data.getTimestampAcademicQuarterEnd
import com.denizk0461.studip.data.getTimestampAcademicQuarterStart
import com.denizk0461.studip.data.parseToMinutes
import com.denizk0461.studip.data.showToast
import com.denizk0461.studip.data.timeslotsAcademicQuarter
import com.denizk0461.studip.data.timeslotsAcademicQuarterEnd
import com.denizk0461.studip.data.timeslotsAcademicQuarterStart
import com.denizk0461.studip.data.viewBinding
import com.denizk0461.studip.databinding.SheetScheduleUpdateBinding
import com.denizk0461.studip.dialog.TimePickerFragment
import com.denizk0461.studip.exception.AcademicQuarterNotApplicableException
import com.denizk0461.studip.model.StudIPEvent
/**
@@ -60,10 +61,8 @@ class ScheduleUpdateSheet(
binding.buttonAcademicQuarter.setOnClickListener {
try {
// Retrieve new timestamps with the academic quarter applied, or throw a tantrum
val newStart = timeslotsAcademicQuarterStart[timeslotStart]
?: throw NullPointerException()
val newEnd = timeslotsAcademicQuarterEnd[timeslotEnd]
?: throw NullPointerException()
val newStart = getTimestampAcademicQuarterStart(timeslotStart)
val newEnd = getTimestampAcademicQuarterEnd(timeslotEnd)
// Set the buttons to the new timesatmps
timeslotStart = newStart
@@ -79,7 +78,7 @@ class ScheduleUpdateSheet(
binding.buttonAcademicQuarter.visibility = View.GONE
// Catch if a timeslot couldn't be found in the list, and tell the user
} catch (e: NullPointerException) {
} catch (e: AcademicQuarterNotApplicableException) {
showToast(context, getString(R.string.sheet_schedule_update_hint_quarter_error))
}
}
@@ -2,7 +2,6 @@ package com.denizk0461.studip.sheet
import android.os.Bundle
import android.view.View
import androidx.annotation.StringRes
import com.denizk0461.studip.R
import com.denizk0461.studip.data.viewBinding
import com.denizk0461.studip.databinding.SheetTextBinding