fixed time display

This commit is contained in:
Mariotaku Lee 2017-01-19 01:55:01 +08:00
parent 172e85ee42
commit b61f77f32e
1 changed files with 12 additions and 4 deletions

View File

@ -23,9 +23,12 @@ import android.content.Context;
import android.os.Handler;
import android.os.SystemClock;
import android.support.v7.widget.AppCompatTextView;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import java.lang.ref.WeakReference;
@ -76,18 +79,23 @@ public class ShortTimeView extends AppCompatTextView implements Constants {
private void invalidateTime() {
if (mShowAbsoluteTime) {
setText(formatSameDayTime(getContext(), mTime));
setTextIfChanged(formatSameDayTime(getContext(), mTime));
} else {
final long current = System.currentTimeMillis();
if (Math.abs(current - mTime) > 60 * 1000) {
// setText(getRelativeTimeSpanString(mTime, System.currentTimeMillis(),
// DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL));
setTextIfChanged(DateUtils.getRelativeTimeSpanString(mTime, System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL));
} else {
// setText(R.string.just_now);
setTextIfChanged(getContext().getString(R.string.just_now));
}
}
}
private void setTextIfChanged(CharSequence text) {
if (TextUtils.equals(text, getText())) return;
setText(text);
}
private static class TickerRunnable implements Runnable {
private final WeakReference<ShortTimeView> mViewRef;