aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/cgCacheVisitComparator.java
blob: 19a4b52229e0f65b71e8b9a04d5425fbd65d9249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package cgeo.geocaching;

import java.util.Comparator;
import android.util.Log;

public class cgCacheVisitComparator implements Comparator<cgCache> {

	public int compare(cgCache cache1, cgCache cache2) {
		try {
			if (cache1.visitedDate == null || cache1.visitedDate <= 0 || cache2.visitedDate == null || cache2.visitedDate <= 0) {
				return 0;
			}

			if (cache1.visitedDate > cache2.visitedDate) {
				return -1;
			} else if (cache1.visitedDate < cache2.visitedDate) {
				return 1;
			} else {
				return 0;
			}
		} catch (Exception e) {
			Log.e(cgSettings.tag, "cgCacheVisitComparator.compare: " + e.toString());
		}

		return 0;
	}
}