Merge pull request #70 from hugomg/relative-times

Use human-readable relative times in LoadGameActivity.
This commit is contained in:
Christopher Beckmann 2020-11-22 18:47:46 +01:00 committed by GitHub
commit 21c2f567ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -260,12 +261,11 @@ public class LoadGameActivity extends BaseActivity implements IDeleteDialogFragm
h = (hours< 10)? "0"+String.valueOf(hours):String.valueOf(hours);
playedTime.setText(h + ":" + m + ":" + s);
Date lastTimePlayedDate = gic.getLastTimePlayed();
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getDefault());
lastTimePlayed.setText(format.format(lastTimePlayedDate));
long now = System.currentTimeMillis();
long lastTimePlayedTimestamp = gic.getLastTimePlayed().getTime();
CharSequence humanReadableRelativeTime = DateUtils.getRelativeTimeSpanString(
lastTimePlayedTimestamp, now, DateUtils.MINUTE_IN_MILLIS);
lastTimePlayed.setText(humanReadableRelativeTime);
return convertView;
}