fixed time display
This commit is contained in:
parent
172e85ee42
commit
b61f77f32e
|
@ -23,9 +23,12 @@ import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.mariotaku.twidere.Constants;
|
import org.mariotaku.twidere.Constants;
|
||||||
|
import org.mariotaku.twidere.R;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
@ -76,18 +79,23 @@ public class ShortTimeView extends AppCompatTextView implements Constants {
|
||||||
|
|
||||||
private void invalidateTime() {
|
private void invalidateTime() {
|
||||||
if (mShowAbsoluteTime) {
|
if (mShowAbsoluteTime) {
|
||||||
setText(formatSameDayTime(getContext(), mTime));
|
setTextIfChanged(formatSameDayTime(getContext(), mTime));
|
||||||
} else {
|
} else {
|
||||||
final long current = System.currentTimeMillis();
|
final long current = System.currentTimeMillis();
|
||||||
if (Math.abs(current - mTime) > 60 * 1000) {
|
if (Math.abs(current - mTime) > 60 * 1000) {
|
||||||
// setText(getRelativeTimeSpanString(mTime, System.currentTimeMillis(),
|
setTextIfChanged(DateUtils.getRelativeTimeSpanString(mTime, System.currentTimeMillis(),
|
||||||
// DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL));
|
DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL));
|
||||||
} else {
|
} 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 static class TickerRunnable implements Runnable {
|
||||||
|
|
||||||
private final WeakReference<ShortTimeView> mViewRef;
|
private final WeakReference<ShortTimeView> mViewRef;
|
||||||
|
|
Loading…
Reference in New Issue