summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod
diff options
context:
space:
mode:
authorHanno Zulla <hanno.zulla@epublica.de>2013-04-16 14:24:20 +0200
committerHanno Zulla <hanno.zulla@epublica.de>2013-04-16 14:24:20 +0200
commitb5f47898655985cf25fc92cf384b7901a1cc05e6 (patch)
treedd10605e7add241c45915e2057464e305c1935e4 /src/de/danoeh/antennapod
parent09191d734e2eb7cfcd338057266ec150063287b6 (diff)
downloadAntennaPod-b5f47898655985cf25fc92cf384b7901a1cc05e6.zip
changed dates in lists to relative timespans (e.g. "3 days ago")
Diffstat (limited to 'src/de/danoeh/antennapod')
-rw-r--r--src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java9
-rw-r--r--src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java9
-rw-r--r--src/de/danoeh/antennapod/adapter/FeedlistAdapter.java9
-rw-r--r--src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java8
-rw-r--r--src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java8
-rw-r--r--src/de/danoeh/antennapod/util/Converter.java15
6 files changed, 28 insertions, 30 deletions
diff --git a/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java
index b603bb54f..5a77d9a07 100644
--- a/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java
@@ -1,10 +1,7 @@
package de.danoeh.antennapod.adapter;
-import java.text.DateFormat;
-
import android.content.Context;
import android.content.res.TypedArray;
-import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -75,10 +72,8 @@ public class DefaultFeedItemlistAdapter extends BaseAdapter {
holder.title.setText(item.getTitle());
holder.published.setText(convertView.getResources().getString(
R.string.published_prefix)
- + DateUtils.formatSameDayTime(item.getPubDate().getTime(),
- System.currentTimeMillis(), DateFormat.MEDIUM,
- DateFormat.SHORT));
-
+ + Converter.getRelativeTimeSpanString(context,
+ item.getPubDate().getTime()));
if (item.getMedia() == null) {
holder.type.setVisibility(View.GONE);
holder.lenSize.setVisibility(View.GONE);
diff --git a/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
index c0ccdc7fe..e80009a44 100644
--- a/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
@@ -1,9 +1,6 @@
package de.danoeh.antennapod.adapter;
-import java.text.DateFormat;
-
import android.content.Context;
-import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,6 +12,7 @@ import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedImage;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.feed.FeedMedia;
+import de.danoeh.antennapod.util.Converter;
import de.danoeh.antennapod.util.DownloadError;
/** Displays a list of DownloadStatus entries. */
@@ -60,9 +58,8 @@ public class DownloadLogAdapter extends BaseAdapter {
} else {
holder.title.setText(R.string.download_log_title_unknown);
}
- holder.date.setText(DateUtils.formatSameDayTime(status
- .getCompletionDate().getTime(), System.currentTimeMillis(),
- DateFormat.SHORT, DateFormat.SHORT));
+ holder.date.setText(Converter.getRelativeTimeSpanString(context,
+ status.getCompletionDate().getTime()));
if (status.isSuccessful()) {
holder.successful.setTextColor(convertView.getResources().getColor(
R.color.download_success_green));
diff --git a/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java b/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java
index d7ea0c160..49573ba7d 100644
--- a/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java
@@ -1,9 +1,6 @@
package de.danoeh.antennapod.adapter;
-import java.text.DateFormat;
-
import android.content.Context;
-import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,6 +12,7 @@ import de.danoeh.antennapod.asynctask.ImageLoader;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.storage.DownloadRequester;
+import de.danoeh.antennapod.util.Converter;
import de.danoeh.antennapod.util.ThemeUtils;
public class FeedlistAdapter extends BaseAdapter {
@@ -82,9 +80,8 @@ public class FeedlistAdapter extends BaseAdapter {
} else {
holder.lastUpdate.setText(convertView.getResources().getString(
R.string.last_update_prefix)
- + DateUtils.formatSameDayTime(feed.getLastUpdate()
- .getTime(), System.currentTimeMillis(),
- DateFormat.MEDIUM, DateFormat.SHORT));
+ + Converter.getRelativeTimeSpanString(context,
+ feed.getLastUpdate().getTime()));
}
holder.numberOfEpisodes.setText(feed.getNumOfItems(true)
+ convertView.getResources()
diff --git a/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java
index 7b898385e..69d41bce5 100644
--- a/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java
@@ -1,10 +1,7 @@
package de.danoeh.antennapod.adapter;
-import java.text.DateFormat;
-
import android.content.Context;
import android.content.res.TypedArray;
-import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -122,9 +119,8 @@ public class InternalFeedItemlistAdapter extends DefaultFeedItemlistAdapter {
holder.published.setText(convertView.getResources().getString(
R.string.published_prefix)
- + DateUtils.formatSameDayTime(item.getPubDate().getTime(),
- System.currentTimeMillis(), DateFormat.MEDIUM,
- DateFormat.SHORT));
+ + Converter.getRelativeTimeSpanString(getContext(),
+ item.getPubDate().getTime()));
FeedMedia media = item.getMedia();
if (media == null) {
diff --git a/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java
index 4cee0a64a..c4ca56d6a 100644
--- a/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java
@@ -1,10 +1,8 @@
package de.danoeh.antennapod.adapter;
-import java.text.DateFormat;
import java.util.List;
import android.content.Context;
-import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -12,6 +10,7 @@ import android.widget.ArrayAdapter;
import android.widget.TextView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.miroguide.model.MiroGuideItem;
+import de.danoeh.antennapod.util.Converter;
public class MiroGuideItemlistAdapter extends ArrayAdapter<MiroGuideItem> {
@@ -42,9 +41,8 @@ public class MiroGuideItemlistAdapter extends ArrayAdapter<MiroGuideItem> {
holder.title.setText(item.getName());
if (item.getDate() != null) {
- holder.date.setText(DateUtils.formatSameDayTime(item.getDate()
- .getTime(), System.currentTimeMillis(), DateFormat.SHORT,
- DateFormat.SHORT));
+ holder.date.setText(Converter.getRelativeTimeSpanString(getContext(),
+ item.getDate().getTime()));
holder.date.setVisibility(View.VISIBLE);
} else {
holder.date.setVisibility(View.GONE);
diff --git a/src/de/danoeh/antennapod/util/Converter.java b/src/de/danoeh/antennapod/util/Converter.java
index f02e8ea69..7ca291919 100644
--- a/src/de/danoeh/antennapod/util/Converter.java
+++ b/src/de/danoeh/antennapod/util/Converter.java
@@ -1,6 +1,9 @@
package de.danoeh.antennapod.util;
+import android.content.Context;
+import android.text.format.DateUtils;
import android.util.Log;
+import de.danoeh.antennapod.R;
/** Provides methods for converting various units. */
public final class Converter {
@@ -78,4 +81,16 @@ public final class Converter {
return String.format("%02d:%02d", h, m);
}
+
+ /** Converts milliseconds to a relative time span,
+ * will return "a moment ago" if it's less than a minute ago */
+ public static String getRelativeTimeSpanString(Context context, long millis) {
+ long now = System.currentTimeMillis();
+ if (now - millis <= 60 * 1000) {
+ return context.getString(R.string.a_moment_ago);
+ } else {
+ return DateUtils.getRelativeTimeSpanString(
+ millis, now, 0, 0).toString();
+ }
+ }
}