List of usage examples for android.text.format DateUtils DAY_IN_MILLIS
long DAY_IN_MILLIS
To view the source code for android.text.format DateUtils DAY_IN_MILLIS.
Click Source Link
From source file:tw.idv.gasolin.pycontw2012.ui.ScheduleFragment.java
private void setupDay(LayoutInflater inflater, long startMillis) { Day day = new Day(); // Setup data day.index = mDays.size();/* www.j a va 2 s . co m*/ day.timeStart = startMillis; day.timeEnd = startMillis + DateUtils.DAY_IN_MILLIS; day.blocksUri = CoscupContract.Blocks.buildBlocksBetweenDirUri(day.timeStart, day.timeEnd); // Setup views day.rootView = (ViewGroup) inflater.inflate(R.layout.blocks_content, null); day.scrollView = (ObservableScrollView) day.rootView.findViewById(R.id.blocks_scroll); day.scrollView.setOnScrollListener(this); day.blocksView = (BlocksLayout) day.rootView.findViewById(R.id.blocks); day.nowView = day.rootView.findViewById(R.id.blocks_now); day.blocksView.setDrawingCacheEnabled(true); day.blocksView.setAlwaysDrawnWithCacheEnabled(true); TimeZone.setDefault(UIUtils.CONFERENCE_TIME_ZONE); day.label = DateUtils.formatDateTime(getActivity(), startMillis, TIME_FLAGS); mWorkspace.addView(day.rootView); mDays.add(day); }
From source file:com.google.android.apps.iosched.ui.ScheduleFragment.java
private void setupDay(LayoutInflater inflater, long startMillis) { Day day = new Day(); // Setup data day.index = mDays.size();//from w w w. j a va2 s. c o m day.timeStart = startMillis; day.timeEnd = startMillis + DateUtils.DAY_IN_MILLIS; day.blocksUri = ScheduleContract.Blocks.buildBlocksBetweenDirUri(day.timeStart, day.timeEnd); // Setup views day.rootView = (ViewGroup) inflater.inflate(R.layout.blocks_content, null); day.scrollView = (ObservableScrollView) day.rootView.findViewById(R.id.blocks_scroll); day.scrollView.setOnScrollListener(this); day.blocksView = (BlocksLayout) day.rootView.findViewById(R.id.blocks); day.nowView = day.rootView.findViewById(R.id.blocks_now); day.blocksView.setDrawingCacheEnabled(true); day.blocksView.setAlwaysDrawnWithCacheEnabled(true); TimeZone.setDefault(UIUtils.CONFERENCE_TIME_ZONE); day.label = DateUtils.formatDateTime(getActivity(), startMillis, TIME_FLAGS); mWorkspace.addView(day.rootView); mDays.add(day); }
From source file:org.dalmasso.ietfsched.ui.ScheduleFragment.java
private void setupDay(LayoutInflater inflater, long startMillis) { Day day = new Day(); if (debbug)/* w ww .j a v a 2 s. com*/ Log.d(TAG, "Setup day"); // Setup data day.index = mDays.size(); day.timeStart = startMillis; day.timeEnd = startMillis + DateUtils.DAY_IN_MILLIS; day.blocksUri = ScheduleContract.Blocks.buildBlocksBetweenDirUri(day.timeStart, day.timeEnd); if (debbug) Log.d(TAG, "day block uri " + day.blocksUri); // Setup views day.rootView = (ViewGroup) inflater.inflate(R.layout.blocks_content, null); day.scrollView = (ObservableScrollView) day.rootView.findViewById(R.id.blocks_scroll); day.scrollView.setOnScrollListener(this); day.blocksView = (BlocksLayout) day.rootView.findViewById(R.id.blocks); day.nowView = day.rootView.findViewById(R.id.blocks_now); day.blocksView.setDrawingCacheEnabled(true); day.blocksView.setAlwaysDrawnWithCacheEnabled(true); TimeZone.setDefault(UIUtils.CONFERENCE_TIME_ZONE); day.label = DateUtils.formatDateTime(getActivity(), startMillis, TIME_FLAGS); mWorkspace.addView(day.rootView); mDays.add(day); }
From source file:com.google.android.apps.iosched2.ui.ScheduleFragment.java
private void setupDay(LayoutInflater inflater, long startMillis) { Day day = new Day(); // Setup data day.index = mDays.size();//from w w w . j a v a 2 s . c om day.timeStart = startMillis; day.timeEnd = startMillis + DateUtils.DAY_IN_MILLIS; day.blocksUri = ScheduleContract.Blocks.buildBlocksBetweenDirUri(day.timeStart, day.timeEnd); // Setup views day.rootView = (ViewGroup) inflater.inflate(R.layout.blocks_content, null); day.scrollView = (ObservableScrollView) day.rootView.findViewById(R.id.blocks_scroll); day.scrollView.setOnScrollListener(this); day.blocksView = (BlocksLayout) day.rootView.findViewById(R.id.blocks); day.nowView = day.rootView.findViewById(R.id.blocks_now); day.blocksView.setDrawingCacheEnabled(true); day.blocksView.setAlwaysDrawnWithCacheEnabled(true); TimeZone.setDefault(UIUtils.getConferenceTimeZone()); day.label = DateUtils.formatDateTime(getActivity(), startMillis, TIME_FLAGS); mWorkspace.addView(day.rootView); mDays.add(day); }
From source file:com.markupartist.sthlmtraveling.utils.DateTimeUtil.java
public static CharSequence routeToTimeDisplay(Context context, Route route) { java.text.DateFormat format = android.text.format.DateFormat.getTimeFormat(context); BidiFormatter bidiFormatter = BidiFormatter.getInstance(RtlUtils.isRtl(Locale.getDefault())); Pair<Date, RealTimeState> departsAt = route.departsAt(true); Pair<Date, RealTimeState> arrivesAt = route.arrivesAt(true); String departsAtStr = format.format(departsAt.first); String arrivesAtStr = format.format(arrivesAt.first); CharSequence displayTime;//from w w w.j a v a2s .co m if (!DateUtils.isToday(departsAt.first.getTime())) { displayTime = String.format("%s %s %s", bidiFormatter.unicodeWrap(DateUtils.getRelativeTimeSpanString(departsAt.first.getTime(), System.currentTimeMillis(), DateUtils.DAY_IN_MILLIS).toString()), bidiFormatter.unicodeWrap(departsAtStr), bidiFormatter.unicodeWrap(arrivesAtStr)); } else { displayTime = String.format("%s %s", bidiFormatter.unicodeWrap(departsAtStr), bidiFormatter.unicodeWrap(arrivesAtStr)); } ForegroundColorSpan spanDepartsAt = new ForegroundColorSpan( ContextCompat.getColor(context, ViewHelper.getTextColorByRealtimeState(departsAt.second))); Pattern patternDepartsAt = Pattern.compile(departsAtStr); displayTime = SpanUtils.createSpannable(displayTime, patternDepartsAt, spanDepartsAt); ForegroundColorSpan spanArrivessAt = new ForegroundColorSpan( ContextCompat.getColor(context, ViewHelper.getTextColorByRealtimeState(arrivesAt.second))); Pattern patternArrivesAt = Pattern.compile(arrivesAtStr); displayTime = SpanUtils.createSpannable(displayTime, patternArrivesAt, spanArrivessAt); return displayTime; }
From source file:com.battlelancer.seriesguide.ui.StatsFragment.java
private String getTimeDuration(long duration) { long days = duration / DateUtils.DAY_IN_MILLIS; duration %= DateUtils.DAY_IN_MILLIS; long hours = duration / DateUtils.HOUR_IN_MILLIS; duration %= DateUtils.HOUR_IN_MILLIS; long minutes = duration / DateUtils.MINUTE_IN_MILLIS; StringBuilder result = new StringBuilder(); if (days != 0) { result.append(getResources().getQuantityString(R.plurals.days_plural, (int) days, (int) days)); }//from w w w . j a va 2 s.c o m if (hours != 0) { if (days != 0) { result.append(" "); } result.append(getResources().getQuantityString(R.plurals.hours_plural, (int) hours, (int) hours)); } if (minutes != 0 || (days == 0 && hours == 0)) { if (days != 0 || hours != 0) { result.append(" "); } result.append(getResources().getQuantityString(R.plurals.minutes_plural, (int) minutes, (int) minutes)); } return result.toString(); }
From source file:io.github.hidroh.materialistic.AppUtils.java
public static String getAbbreviatedTimeSpan(long timeMillis) { long span = Math.max(System.currentTimeMillis() - timeMillis, 0); if (span >= DateUtils.YEAR_IN_MILLIS) { return (span / DateUtils.YEAR_IN_MILLIS) + ABBR_YEAR; }//from w w w .jav a 2 s. co m if (span >= DateUtils.WEEK_IN_MILLIS) { return (span / DateUtils.WEEK_IN_MILLIS) + ABBR_WEEK; } if (span >= DateUtils.DAY_IN_MILLIS) { return (span / DateUtils.DAY_IN_MILLIS) + ABBR_DAY; } if (span >= DateUtils.HOUR_IN_MILLIS) { return (span / DateUtils.HOUR_IN_MILLIS) + ABBR_HOUR; } return (span / DateUtils.MINUTE_IN_MILLIS) + ABBR_MINUTE; }
From source file:com.kncwallet.wallet.ui.ReceiveFragment.java
private void updateBalanceView() { if (!isAdded()) return;// w w w .j a va 2 s . c om final boolean showProgress; if (bestChainDate != null) { final long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime(); final boolean blockchainUptodate = blockchainLag < Constants.BLOCKCHAIN_UPTODATE_THRESHOLD_MS; final boolean downloadOk = download == BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK; showProgress = !(blockchainUptodate || !replaying); final String downloading = getString(downloadOk ? R.string.blockchain_state_progress_downloading : R.string.blockchain_state_progress_stalled); if (blockchainLag < 2 * DateUtils.DAY_IN_MILLIS) { final long hours = blockchainLag / DateUtils.HOUR_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_hours, downloading, hours)); } else if (blockchainLag < 2 * DateUtils.WEEK_IN_MILLIS) { final long days = blockchainLag / DateUtils.DAY_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_days, downloading, days)); } else if (blockchainLag < 90 * DateUtils.DAY_IN_MILLIS) { final long weeks = blockchainLag / DateUtils.WEEK_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_weeks, downloading, weeks)); } else { final long months = blockchainLag / (30 * DateUtils.DAY_IN_MILLIS); viewProgress.setText(getString(R.string.blockchain_state_progress_months, downloading, months)); } } else { showProgress = false; } if (!showProgress) { viewBalance.setVisibility(View.VISIBLE); if (balance != null) { final String precision = prefs.getString(Constants.PREFS_KEY_BTC_PRECISION, Constants.PREFS_DEFAULT_BTC_PRECISION); final int btcPrecision = precision.charAt(0) - '0'; final int btcShift = precision.length() == 3 ? precision.charAt(2) - '0' : 0; final String prefix = DenominationUtil.getCurrencyCode(btcShift); viewBalanceBtc.setVisibility(View.VISIBLE); viewBalanceBtc.setPrecision(btcPrecision, btcShift); viewBalanceBtc.setSuffix(prefix); viewBalanceBtc.setAmount(balance); } else { viewBalanceBtc.setVisibility(View.INVISIBLE); } viewProgress.setVisibility(View.GONE); } else { viewProgress.setVisibility(View.VISIBLE); viewBalance.setVisibility(View.INVISIBLE); } if (exchangeRate != null && exchangeRate.rate != null && balance != null) { final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate); viewBalanceLocal.setSuffix(exchangeRate.currencyCode); viewBalanceLocal.setAmount(localValue); viewBalanceLocal.setTextColor(getResources().getColor(R.color.knc_highlight)); } }
From source file:com.kncwallet.wallet.ui.HomeFragment.java
private void updateBalanceView() { if (!isAdded()) return;/*from ww w . ja v a 2 s . co m*/ final boolean showProgress; if (bestChainDate != null) { final long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime(); final boolean blockchainUptodate = blockchainLag < Constants.BLOCKCHAIN_UPTODATE_THRESHOLD_MS; final boolean downloadOk = download == BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK; showProgress = !(blockchainUptodate || !replaying); final String downloading = getString(downloadOk ? R.string.blockchain_state_progress_downloading : R.string.blockchain_state_progress_stalled); if (blockchainLag < 2 * DateUtils.DAY_IN_MILLIS) { final long hours = blockchainLag / DateUtils.HOUR_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_hours, downloading, hours)); } else if (blockchainLag < 2 * DateUtils.WEEK_IN_MILLIS) { final long days = blockchainLag / DateUtils.DAY_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_days, downloading, days)); } else if (blockchainLag < 90 * DateUtils.DAY_IN_MILLIS) { final long weeks = blockchainLag / DateUtils.WEEK_IN_MILLIS; viewProgress.setText(getString(R.string.blockchain_state_progress_weeks, downloading, weeks)); } else { final long months = blockchainLag / (30 * DateUtils.DAY_IN_MILLIS); viewProgress.setText(getString(R.string.blockchain_state_progress_months, downloading, months)); } } else { showProgress = false; } if (!showProgress) { viewBalance.setVisibility(View.VISIBLE); if (balance != null) { final String precision = prefs.getString(Constants.PREFS_KEY_BTC_PRECISION, Constants.PREFS_DEFAULT_BTC_PRECISION); final int btcPrecision = precision.charAt(0) - '0'; final int btcShift = precision.length() == 3 ? precision.charAt(2) - '0' : 0; final String prefix = DenominationUtil.getCurrencyCode(btcShift); if (viewBalanceLocal.getVisibility() != View.VISIBLE) { viewBalanceBtc.setVisibility(View.VISIBLE); } viewBalanceBtc.setPrecision(btcPrecision, btcShift); viewBalanceBtc.setSuffix(prefix); viewBalanceBtc.setAmount(balance); } else { viewBalanceBtc.setVisibility(View.INVISIBLE); } viewProgress.setVisibility(View.GONE); } else { viewProgress.setVisibility(View.VISIBLE); viewBalance.setVisibility(View.INVISIBLE); } if (exchangeRate != null && exchangeRate.rate != null && balance != null) { final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate); viewBalanceLocal.setSuffix(exchangeRate.currencyCode); viewBalanceLocal.setAmount(localValue); viewBalanceLocal.setTextColor(getResources().getColor(R.color.knc_highlight)); } }
From source file:de.aw.awlib.preferences.AWPreferencesAllgemein.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.pkSavePeriodic))) { SwitchPreference pref = (SwitchPreference) findPreference(key); long value = Long.MAX_VALUE; if (pref.isChecked()) { value = System.currentTimeMillis() + DateUtils.DAY_IN_MILLIS * 5; }// ww w . j a va 2 s .co m setRegelmSicherungSummary(pref, sharedPreferences, value); } }