-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Locus Data API to version 9. Started in implementation of sen…
…ding Field notes and better checking of logged user.
- Loading branch information
Showing
18 changed files
with
306 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package geocaching.api.data; | ||
|
||
import geocaching.api.data.type.LogType; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.TimeZone; | ||
|
||
public class FieldNote { | ||
public static final SimpleDateFormat DATE_FORMAT; | ||
|
||
static { | ||
DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); | ||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); | ||
} | ||
|
||
protected String cacheCode; | ||
protected LogType logType; | ||
protected Date dateLogged; | ||
protected String note; | ||
|
||
public FieldNote(String cacheCode, Date dateLogged, LogType logType, String note) { | ||
this.cacheCode = cacheCode; | ||
this.dateLogged = dateLogged; | ||
this.logType = logType; | ||
this.note = note; | ||
} | ||
|
||
public String getCacheCode() { | ||
return cacheCode; | ||
} | ||
|
||
public Date getDateLogged() { | ||
return dateLogged; | ||
} | ||
|
||
public LogType getLogType() { | ||
return logType; | ||
} | ||
|
||
public String getNote() { | ||
return note; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s,%s,%s,\"%s\"", cacheCode, DATE_FORMAT.format(dateLogged), logType.getFriendlyName(), safeNote(note)); | ||
} | ||
|
||
public static FieldNote parseLine(String line) { | ||
String[] items = line.split(",", 4); | ||
|
||
String note = items[3]; | ||
if (note.length() >= 2 && note.startsWith("\"") && note.endsWith("\"")) | ||
note = note.substring(1, note.length() - 1); | ||
|
||
try { | ||
return new FieldNote(items[0], DATE_FORMAT.parse(items[1]), LogType.parseLogType(items[2]), note); | ||
} catch (ParseException e) { | ||
return null; | ||
} | ||
} | ||
|
||
protected static String safeNote(String note) { | ||
return note.replace('"', '\'').replaceAll("[\r\n\t]+", ""); | ||
} | ||
} |
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,5 @@ | ||
package geocaching.api.data; | ||
|
||
public class ImageData { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package geocaching.api.data; | ||
|
||
import geocaching.api.data.type.MemberType; | ||
|
||
public class User { | ||
protected String avatarUrl; | ||
protected int findCount; | ||
protected int hideCount; | ||
protected float[] homeCoordinates; | ||
protected long id; | ||
protected boolean admin; | ||
protected MemberType memberType; | ||
protected String publicGuid; | ||
protected String userName; | ||
|
||
public User(String avatarUrl, int findCount, int hideCount, float[] homeCoordinates, long id, boolean admin, MemberType memberType, String publicGuid, | ||
String userName) { | ||
this.avatarUrl = avatarUrl; | ||
this.findCount = findCount; | ||
this.hideCount = hideCount; | ||
this.homeCoordinates = homeCoordinates; | ||
this.id = id; | ||
this.admin = admin; | ||
this.memberType = memberType; | ||
this.publicGuid = publicGuid; | ||
this.userName = userName; | ||
} | ||
|
||
public String getAvatarUrl() { | ||
return avatarUrl; | ||
} | ||
|
||
public int getFindCount() { | ||
return findCount; | ||
} | ||
|
||
public int getHideCount() { | ||
return hideCount; | ||
} | ||
|
||
public float[] getHomeCoordinates() { | ||
return homeCoordinates; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public boolean isAdmin() { | ||
return admin; | ||
} | ||
|
||
public MemberType getMemberType() { | ||
return memberType; | ||
} | ||
|
||
public String getPublicGuid() { | ||
return publicGuid; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
} |
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,25 @@ | ||
package geocaching.api.data; | ||
|
||
|
||
public class UserProfile { | ||
//protected List<FavoritePoint> favoritePoints; | ||
//protected GeocacheFindStats findStats; | ||
//protected PublicProfile publicProfile; | ||
//protected List<Souvenir> souvenirs; | ||
//protected GlobalStats globalStats; | ||
//protected TrackableStats trackableStats; | ||
protected User user; | ||
|
||
public UserProfile(/*List<FavoritePoint> favoritePoints, GeocacheFindStats findStats, PublicProfile publicProfile, List<Souvenir> souvenirs, | ||
GlobalStats globalStats, TrackableStats trackableStats,*/ User user) { | ||
/* this.favoritePoints = favoritePoints; | ||
this.findStats = findStats; | ||
this.publicProfile = publicProfile; | ||
this.souvenirs = souvenirs; | ||
this.globalStats = globalStats; | ||
this.trackableStats = trackableStats;*/ | ||
this.user = user; | ||
} | ||
|
||
|
||
} |
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,33 @@ | ||
package geocaching.api.data.type; | ||
|
||
public enum MemberType { | ||
Guest("Guest", 0), | ||
Basic("Basic", 1), | ||
Charter("Charter", 2), | ||
Premium("Premium", 3); | ||
|
||
protected String friendlyName; | ||
protected int groundSpeakId; | ||
|
||
private MemberType(String friendlyName, int groundSpeakId) { | ||
this.friendlyName = friendlyName; | ||
this.groundSpeakId = groundSpeakId; | ||
} | ||
|
||
public String getFriendlyName() { | ||
return friendlyName; | ||
} | ||
|
||
public int getGroundSpeakId() { | ||
return groundSpeakId; | ||
} | ||
|
||
public static MemberType parseMemeberTypeByGroundSpeakId(int groundSpeakId) { | ||
for (MemberType memberType : values()) { | ||
if (memberType.groundSpeakId == groundSpeakId) | ||
return memberType; | ||
} | ||
|
||
return Guest; | ||
} | ||
} |
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.