diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-03-19 17:35:29 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-03-19 17:35:29 -0700 |
commit | d9f31a4c3e1d8f7a46607b9882b188d10b613403 (patch) | |
tree | bc1f74be31018084b8ab59f37bf1a6c1c6c61a55 /src/github | |
parent | 1e4c579f55d3d56529a3863f9bde0bfe470011be (diff) | |
download | dsub-d9f31a4c3e1d8f7a46607b9882b188d10b613403.tar.gz dsub-d9f31a4c3e1d8f7a46607b9882b188d10b613403.tar.bz2 dsub-d9f31a4c3e1d8f7a46607b9882b188d10b613403.zip |
Use the same date format across the board, improve to more standard format
Diffstat (limited to 'src/github')
6 files changed, 22 insertions, 7 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 8bc27c84..707d9090 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -566,7 +566,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { if(remoteState != null && remoteState.changed != null) {
Date localChange = downloadService.getLastStateChanged();
if(localChange == null || localChange.before(remoteState.changed)) {
- playerQueue = remoteState;
+ playerQueue = remoteState;ma
}
}
} catch (Exception e) {
@@ -585,7 +585,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { }.execute();
}
private void promptRestoreFromRemoteQueue(final PlayerQueue remoteState) {
- Util.confirmDialog(this, R.string.download_restore_play_queue, new SimpleDateFormat("MMM dd hh:mm").format(remoteState.changed), new DialogInterface.OnClickListener() {
+ Util.confirmDialog(this, R.string.download_restore_play_queue, Util.formatDate(remoteState.changed), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index c26429ce..85895dd2 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -127,7 +127,6 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En private void displayBookmarkInfo(final MusicDirectory.Entry entry) { Bookmark bookmark = entry.getBookmark(); - Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String comment = bookmark.getComment(); if(comment == null) { comment = ""; @@ -135,7 +134,7 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En String msg = context.getResources().getString(R.string.bookmark_details, entry.getTitle(), Util.formatDuration(bookmark.getPosition() / 1000), - formatter.format(bookmark.getCreated()), formatter.format(bookmark.getChanged()), comment); + Util.formatDate(bookmark.getCreated()), Util.formatDate(bookmark.getChanged()), comment); Util.info(context, R.string.bookmark_details_title, msg, false); } diff --git a/src/github/daneren2005/dsub/fragments/SelectShareFragment.java b/src/github/daneren2005/dsub/fragments/SelectShareFragment.java index 5fc50594..692df7d0 100644 --- a/src/github/daneren2005/dsub/fragments/SelectShareFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectShareFragment.java @@ -104,7 +104,7 @@ public class SelectShareFragment extends SelectListFragment<Share> { private void displayShareInfo(final Share share) {
String message = context.getResources().getString(R.string.share_info,
share.getUsername(), (share.getDescription() != null) ? share.getDescription() : "", share.getUrl(),
- share.getCreated(), share.getLastVisited(), share.getExpires(), share.getVisitCount());
+ Util.formatDate(share.getCreated()), Util.formatDate(share.getLastVisited()), Util.formatDate(share.getExpires()), share.getVisitCount());
Util.info(context, share.getName(), message);
}
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java index a1878cad..c34ce678 100644 --- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java @@ -55,7 +55,6 @@ public class PodcastSyncAdapter extends SubsonicSyncAdapter { @Override
public void onExecuteSync(Context context, int instance) {
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
ArrayList<SyncSet> podcastList = SyncUtil.getSyncedPodcasts(context, instance);
try {
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 412289fc..d23d7300 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -68,7 +68,9 @@ import java.lang.reflect.Method; import java.security.MessageDigest; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.Locale; /** @@ -86,6 +88,9 @@ public final class Util { private static DecimalFormat MEGA_BYTE_LOCALIZED_FORMAT = null; private static DecimalFormat KILO_BYTE_LOCALIZED_FORMAT = null; private static DecimalFormat BYTE_LOCALIZED_FORMAT = null; + private static SimpleDateFormat DATE_FORMAT_SHORT = new SimpleDateFormat("MMM d h:mm a"); + private static SimpleDateFormat DATE_FORMAT_LONG = new SimpleDateFormat("MMM d, yyyy h:mm a"); + private static int CURRENT_YEAR = new Date().getYear(); public static final String EVENT_META_CHANGED = "github.daneren2005.dsub.EVENT_META_CHANGED"; public static final String EVENT_PLAYSTATE_CHANGED = "github.daneren2005.dsub.EVENT_PLAYSTATE_CHANGED"; @@ -777,6 +782,18 @@ public final class Util { return builder.toString(); } + public static String formatDate(Date date) { + if(date == null) { + return "Never"; + } else { + if(date.getYear() != CURRENT_YEAR) { + return DATE_FORMAT_LONG.format(date); + } else { + return DATE_FORMAT_SHORT.format(date); + } + } + } + public static boolean equals(Object object1, Object object2) { if (object1 == object2) { return true; diff --git a/src/github/daneren2005/dsub/view/ShareView.java b/src/github/daneren2005/dsub/view/ShareView.java index 32a83880..2b2fbee4 100644 --- a/src/github/daneren2005/dsub/view/ShareView.java +++ b/src/github/daneren2005/dsub/view/ShareView.java @@ -57,7 +57,7 @@ public class ShareView extends UpdateView { Share share = (Share) obj;
titleView.setText(share.getName());
if(share.getExpires() != null) {
- descriptionView.setText(context.getResources().getString(R.string.share_expires, new SimpleDateFormat("E MMM d yyyy", Locale.ENGLISH).format(share.getExpires())));
+ descriptionView.setText(context.getResources().getString(R.string.share_expires, new SimpleDateFormat("E MMM d, yyyy", Locale.ENGLISH).format(share.getExpires())));
} else {
descriptionView.setText(context.getResources().getString(R.string.share_expires_never));
}
|