diff options
author | Scott Jackson <daneren2005@gmail.com> | 2020-09-12 10:55:51 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2020-09-12 10:55:51 -0700 |
commit | f41260fb75c24eb0f28e576903f0220c29cc2738 (patch) | |
tree | 49ce81222528acb43ce47ba7125e06989d3eb6ab /app/src | |
parent | 5cc7156fee13d8318bad59b76edca8b0d844a18c (diff) | |
download | dsub-f41260fb75c24eb0f28e576903f0220c29cc2738.tar.gz dsub-f41260fb75c24eb0f28e576903f0220c29cc2738.tar.bz2 dsub-f41260fb75c24eb0f28e576903f0220c29cc2738.zip |
Fix #1001 playlist timestamps showing UTC time still
Diffstat (limited to 'app/src')
3 files changed, 23 insertions, 12 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java b/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java index 7d480607..d3453e50 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java @@ -49,15 +49,15 @@ public class Playlist implements Serializable { this.id = id; this.name = name; } - public Playlist(String id, String name, String owner, String comment, String songCount, String pub, String created, String changed, Integer duration) { + public Playlist(String id, String name, String owner, String comment, String songCount, String pub, Date created, Date changed, Integer duration) { this.id = id; this.name = name; this.owner = (owner == null) ? "" : owner; this.comment = (comment == null) ? "" : comment; this.songCount = (songCount == null) ? "" : songCount; this.pub = (pub == null) ? null : (pub.equals("true")); - setCreated(created); - setChanged(changed); + this.created = created; + this.changed = changed; this.duration = duration; } diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java index 71a6b65e..7aa0e99e 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java +++ b/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java @@ -19,13 +19,17 @@ package github.daneren2005.dsub.service.parser; import android.content.Context; +import android.util.Log; import github.daneren2005.dsub.domain.Playlist; import github.daneren2005.dsub.util.ProgressListener; +import github.daneren2005.dsub.util.Util; + import org.xmlpull.v1.XmlPullParser; import java.io.Reader; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -53,8 +57,8 @@ public class PlaylistsParser extends AbstractParser { String comment = get("comment"); String songCount = get("songCount"); String pub = get("public"); - String created = get("created"); - String changed = get("changed"); + Date created = Util.parseDate(context, get("created")); + Date changed = Util.parseDate(context, get("changed")); Integer duration = getInteger("duration"); result.add(new Playlist(id, name, owner, comment, songCount, pub, created, changed, duration)); } else if ("error".equals(tag)) { diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index c1581a26..b58a81e4 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -865,12 +865,9 @@ public final class Util { return builder.toString(); } - public static String formatDate(Context context, String dateString) { - return formatDate(context, dateString, true); - } - public static String formatDate(Context context, String dateString, boolean includeTime) { + public static Date parseDate(Context context, String dateString) { if(dateString == null) { - return ""; + return null; } try { @@ -881,11 +878,21 @@ public final class Util { dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } - return formatDate(dateFormat.parse(dateString), includeTime); + return dateFormat.parse(dateString); } catch(ParseException e) { Log.e(TAG, "Failed to parse date string", e); - return dateString; + return null; + } + } + public static String formatDate(Context context, String dateString) { + return formatDate(context, dateString, true); + } + public static String formatDate(Context context, String dateString, boolean includeTime) { + if(dateString == null) { + return ""; } + + return formatDate(parseDate(context, dateString), includeTime); } public static String formatDate(Date date) { return formatDate(date, true); |