Archived
Made further documentation and safety changes. Scraper classes (StudIPParser.kt, StwParser.kt) still need to be checked for safety.
This commit is contained in:
@@ -6,6 +6,13 @@ import android.app.TimePickerDialog
|
||||
import android.os.Bundle
|
||||
import android.widget.TimePicker
|
||||
|
||||
/**
|
||||
* Dialogue used for letting the user pick a timestamp.
|
||||
*
|
||||
* @param timestamp timestamp that is to be edited
|
||||
* @param listener listener for when the user finishes setting a time
|
||||
* @param isEventStart whether the timestamp to be edited is the start of the event
|
||||
*/
|
||||
class TimePickerFragment(
|
||||
private val timestamp: String,
|
||||
private val listener: OnTimeSetListener,
|
||||
@@ -14,14 +21,36 @@ class TimePickerFragment(
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val timestampSplit = timestamp.split(":")
|
||||
return TimePickerDialog(activity, this, timestampSplit[0].toInt(), timestampSplit[1].toInt(), true)
|
||||
return TimePickerDialog(
|
||||
activity,
|
||||
this,
|
||||
timestampSplit[0].toInt(),
|
||||
timestampSplit[1].toInt(),
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom implementation of TimePickerDialog#OnTimeSetListener that includes a boolean to find
|
||||
* out whether the start or the end timestamp has been edited.
|
||||
*/
|
||||
interface OnTimeSetListener {
|
||||
|
||||
/**
|
||||
* Timestamp has been edited by the user.
|
||||
*
|
||||
* @param hours hour of the timestamp
|
||||
* @param minutes minute of the timestamp
|
||||
* @param isEventStart whether the timestamp to be edited is the start of the event
|
||||
*/
|
||||
fun onTimeSet(hours: Int, minutes: Int, isEventStart: Boolean)
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the implementation of TimePickerDialog#OnTimeSetListener.
|
||||
*/
|
||||
override fun onTimeSet(picker: TimePicker?, hours: Int, minutes: Int) {
|
||||
// Use custom implementation of OnTimeSetListener
|
||||
listener.onTimeSet(hours, minutes, isEventStart)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user