changed dates in lists to relative timespans (e.g. "3 days ago")
This commit is contained in:
parent
09191d734e
commit
b5f4789865
|
@ -21,6 +21,7 @@
|
|||
<!--Playback history-->
|
||||
<string name="clear_history_label">Chronik löschen</string>
|
||||
<!--Other-->
|
||||
<string name="a_moment_ago">Vor Kurzem</string>
|
||||
<string name="confirm_label">Bestätigen</string>
|
||||
<string name="cancel_label">Abbrechen</string>
|
||||
<string name="author_label">Autor</string>
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<string name="processing_label">Processing</string>
|
||||
<string name="loading_label">Loading...</string>
|
||||
<string name="image_of_prefix">Image of:\u0020</string>
|
||||
<string name="a_moment_ago">a moment ago</string>
|
||||
|
||||
<!-- 'Add Feed' Activity labels -->
|
||||
<string name="feedurl_label">Feed URL</string>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue