1
package freeguide.common.lib.fgspecific.data;
3
public class TVProgrammeOverlapIsEqualComparator implements java.util.Comparator
7
* Compare two programmes by their datetimes.
9
* @param prog1 A TVProgramme
10
* @param prog2 another TVProgramme
12
* @return -1 if prog1 comes first,
13
* 1 if prog2 comes first, and
16
public int compare( Object prog1, Object prog2 )
18
TVProgramme p1 = (TVProgramme)( prog1 );
19
TVProgramme p2 = (TVProgramme)( prog2 );
21
// If the end times have not been downloaded, we
22
// must compare purely by start time.
23
// If both end times are valid, we delare them equal if
24
// They overlap at all, so we don't get overlapping
25
// programmes showing.
26
if( p1.getEnd() == 0 || p2.getEnd() == 0 )
28
if( p1.getStart() < p2.getStart() )
32
else if( p1.getStart() > p2.getStart() )
38
// If the start times are the same, they definitely overlap!
42
else if( p1.getEnd() <= p2.getStart() )
46
else if( p2.getEnd() <= p1.getStart() )