From ec1ff077022eec893c844dce0a7cba7a6cea1420 Mon Sep 17 00:00:00 2001 From: Hanno Zulla Date: Wed, 17 Apr 2013 10:40:39 +0200 Subject: [PATCH] without a_moment_ago there is no need for a Converter method anymore --- .../antennapod/adapter/DefaultFeedItemlistAdapter.java | 6 ++++-- src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java | 7 ++++--- src/de/danoeh/antennapod/adapter/FeedlistAdapter.java | 7 ++++--- .../antennapod/adapter/InternalFeedItemlistAdapter.java | 6 ++++-- .../antennapod/adapter/MiroGuideItemlistAdapter.java | 6 +++--- src/de/danoeh/antennapod/util/Converter.java | 9 --------- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java index 5a77d9a07..2b49795c3 100644 --- a/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/DefaultFeedItemlistAdapter.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.adapter; 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; @@ -72,8 +73,9 @@ public class DefaultFeedItemlistAdapter extends BaseAdapter { holder.title.setText(item.getTitle()); holder.published.setText(convertView.getResources().getString( R.string.published_prefix) - + Converter.getRelativeTimeSpanString(context, - item.getPubDate().getTime())); + + DateUtils.getRelativeTimeSpanString( + item.getPubDate().getTime(), + System.currentTimeMillis(), 0, 0)); 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 e80009a44..f97210cf3 100644 --- a/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.adapter; import android.content.Context; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -12,7 +13,6 @@ 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. */ @@ -58,8 +58,9 @@ public class DownloadLogAdapter extends BaseAdapter { } else { holder.title.setText(R.string.download_log_title_unknown); } - holder.date.setText(Converter.getRelativeTimeSpanString(context, - status.getCompletionDate().getTime())); + holder.date.setText(DateUtils.getRelativeTimeSpanString( + status.getCompletionDate().getTime(), + System.currentTimeMillis(), 0, 0)); 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 a4557e123..df87a83c6 100644 --- a/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/FeedlistAdapter.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.adapter; import android.content.Context; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -12,7 +13,6 @@ 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,8 +82,9 @@ public class FeedlistAdapter extends BaseAdapter { if (numOfItems > 0) { holder.lastUpdate.setText(convertView.getResources().getString( R.string.most_recent_prefix) - + Converter.getRelativeTimeSpanString(context, - feed.getItemAtIndex(true, 0).getPubDate().getTime())); + + DateUtils.getRelativeTimeSpanString( + feed.getItemAtIndex(true, 0).getPubDate().getTime(), + System.currentTimeMillis(), 0, 0)); } } holder.numberOfEpisodes.setText(numOfItems diff --git a/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java index 69d41bce5..e5c12f018 100644 --- a/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/InternalFeedItemlistAdapter.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.adapter; 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; @@ -119,8 +120,9 @@ public class InternalFeedItemlistAdapter extends DefaultFeedItemlistAdapter { holder.published.setText(convertView.getResources().getString( R.string.published_prefix) - + Converter.getRelativeTimeSpanString(getContext(), - item.getPubDate().getTime())); + + DateUtils.getRelativeTimeSpanString( + item.getPubDate().getTime(), + System.currentTimeMillis(), 0, 0)); 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 c4ca56d6a..f12345f84 100644 --- a/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/MiroGuideItemlistAdapter.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.adapter; 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; @@ -10,7 +11,6 @@ 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 { @@ -41,8 +41,8 @@ public class MiroGuideItemlistAdapter extends ArrayAdapter { holder.title.setText(item.getName()); if (item.getDate() != null) { - holder.date.setText(Converter.getRelativeTimeSpanString(getContext(), - item.getDate().getTime())); + holder.date.setText(DateUtils.getRelativeTimeSpanString( + item.getDate().getTime(), System.currentTimeMillis(), 0, 0)); 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 3f0419a4f..6ef47af31 100644 --- a/src/de/danoeh/antennapod/util/Converter.java +++ b/src/de/danoeh/antennapod/util/Converter.java @@ -1,9 +1,6 @@ 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 { @@ -82,10 +79,4 @@ public final class Converter { return String.format("%02d:%02d", h, m); } - /** Converts milliseconds to a relative time span */ - public static String getRelativeTimeSpanString(Context context, long millis) { - long now = System.currentTimeMillis(); - return DateUtils.getRelativeTimeSpanString( - millis, now, 0, 0).toString(); - } }