-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #641 from EventFahrplan/schedule-update-alarm
Simplify build flavor configuration by reading event dates from session data.
- Loading branch information
Showing
18 changed files
with
785 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/nerd/tuxmobil/fahrplan/congress/models/ConferenceTimeFrame.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package nerd.tuxmobil.fahrplan.congress.models | ||
|
||
import info.metadude.android.eventfahrplan.commons.temporal.Moment | ||
import nerd.tuxmobil.fahrplan.congress.alarms.AlarmUpdater | ||
import nerd.tuxmobil.fahrplan.congress.schedule.Conference | ||
|
||
/** | ||
* Represents the time frame of a conference which is taken into account by the [AlarmUpdater] | ||
* to calculate if and when alarms should fire. | ||
* | ||
* These classes should not be used for other purposes. | ||
* They are not a replacement for the [Conference] class. | ||
*/ | ||
sealed interface ConferenceTimeFrame { | ||
|
||
data object Unknown : ConferenceTimeFrame | ||
data class Known(val firstDayStartTime: Moment, val lastDayEndTime: Moment) : ConferenceTimeFrame { | ||
|
||
private val timeFrame = firstDayStartTime..lastDayEndTime | ||
|
||
init { | ||
check(isValid) { "Invalid conference time frame: $this" } | ||
} | ||
|
||
val isValid: Boolean | ||
get() = timeFrame.start.isBefore(timeFrame.endInclusive) | ||
|
||
operator fun contains(moment: Moment) = | ||
startsAtOrBefore(moment) && timeFrame.endInclusive.isAfter(moment) | ||
|
||
fun endsAtOrBefore(moment: Moment) = | ||
timeFrame.endInclusive.isSimultaneousWith(moment) || timeFrame.endInclusive.isBefore(moment) | ||
|
||
fun startsAfter(moment: Moment) = | ||
timeFrame.start.isAfter(moment) | ||
|
||
fun startsAtOrBefore(moment: Moment) = | ||
timeFrame.start.isSimultaneousWith(moment) || timeFrame.start.isBefore(moment) | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
other as Known | ||
return timeFrame == other.timeFrame | ||
} | ||
|
||
override fun hashCode() = timeFrame.hashCode() | ||
|
||
override fun toString() = | ||
timeFrame.toString() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.