Example usage for android.text.format DateUtils HOUR_IN_MILLIS

List of usage examples for android.text.format DateUtils HOUR_IN_MILLIS

Introduction

In this page you can find the example usage for android.text.format DateUtils HOUR_IN_MILLIS.

Prototype

long HOUR_IN_MILLIS

To view the source code for android.text.format DateUtils HOUR_IN_MILLIS.

Click Source Link

Usage

From source file:android.support.v7.app.TwilightManager.java

private void updateState(@NonNull Location location) {
    final TwilightState state = sTwilightState;
    final long now = System.currentTimeMillis();
    final TwilightCalculator calculator = TwilightCalculator.getInstance();

    // calculate yesterday's twilight
    calculator.calculateTwilight(now - DateUtils.DAY_IN_MILLIS, location.getLatitude(),
            location.getLongitude());//from  w  w  w. j a  v  a  2  s  .c  o m
    final long yesterdaySunset = calculator.sunset;

    // calculate today's twilight
    calculator.calculateTwilight(now, location.getLatitude(), location.getLongitude());
    final boolean isNight = (calculator.state == TwilightCalculator.NIGHT);
    final long todaySunrise = calculator.sunrise;
    final long todaySunset = calculator.sunset;

    // calculate tomorrow's twilight
    calculator.calculateTwilight(now + DateUtils.DAY_IN_MILLIS, location.getLatitude(),
            location.getLongitude());
    final long tomorrowSunrise = calculator.sunrise;

    // Set next update
    long nextUpdate = 0;
    if (todaySunrise == -1 || todaySunset == -1) {
        // In the case the day or night never ends the update is scheduled 12 hours later.
        nextUpdate = now + 12 * DateUtils.HOUR_IN_MILLIS;
    } else {
        if (now > todaySunset) {
            nextUpdate += tomorrowSunrise;
        } else if (now > todaySunrise) {
            nextUpdate += todaySunset;
        } else {
            nextUpdate += todaySunrise;
        }
        // add some extra time to be on the safe side.
        nextUpdate += DateUtils.MINUTE_IN_MILLIS;
    }

    // Update the twilight state
    state.isNight = isNight;
    state.yesterdaySunset = yesterdaySunset;
    state.todaySunrise = todaySunrise;
    state.todaySunset = todaySunset;
    state.tomorrowSunrise = tomorrowSunrise;
    state.nextUpdate = nextUpdate;
}

From source file:com.battlelancer.seriesguide.ui.CheckinActivity.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Uri baseUri;/*from  ww  w  .  j  ava 2 s .  c  om*/
    if (mSearchFilter != null) {
        baseUri = Uri.withAppendedPath(Shows.CONTENT_FILTER_URI, Uri.encode(mSearchFilter));
    } else {
        baseUri = Shows.CONTENT_URI;
    }

    // query selects shows with next episodes before this point in time
    // it does not make sense to check into episodes further in the future
    String customTimeInOneHour = String.valueOf(TimeTools.getCurrentTime(this) + DateUtils.HOUR_IN_MILLIS);

    return new CursorLoader(this, baseUri, CheckinQuery.PROJECTION, CheckinQuery.SELECTION,
            new String[] { customTimeInOneHour }, ShowsDistillationSettings.ShowsSortOrder.EPISODE_REVERSE);
}

From source file:com.example.xyzreader.ui.DetailFragment.java

private void bindViews() {
    if (mRootView == null) {
        return;/*from ww w.java 2 s.c  o m*/
    }

    TextView titleView = (TextView) mRootView.findViewById(R.id.article_title);
    TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
    TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (mCursor != null) {

        String title = mCursor.getString(ArticleLoader.Query.TITLE);
        final String shareText = getString(R.string.share_text) + " "
                + mCursor.getString(ArticleLoader.Query.TITLE);

        mRootView.findViewById(R.id.share_fab).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(
                        Intent.createChooser(ShareCompat.IntentBuilder.from(getActivity()).setType("text/plain")
                                .setText(shareText).getIntent(), getString(R.string.action_share)));
            }
        });

        titleView.setText(title);

        bylineView.setText(Html.fromHtml(DateUtils
                .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                        System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
                .toString() + " by <font color='#000000'>" + mCursor.getString(ArticleLoader.Query.AUTHOR)
                + "</font>"));
        bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));

        Picasso.with(getActivity()).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(mPhotoView);
        mPhotoView.setContentDescription(mCursor.getString(ArticleLoader.Query.TITLE));

    } else {
        titleView.setText("N/A");
        bylineView.setText("N/A");
        bodyView.setText("N/A");
    }

}

From source file:piuk.blockchain.android.ui.BlockchainStateFragment.java

private void updateView() {
    final boolean showProgress;

    AbstractWalletActivity activity = (AbstractWalletActivity) this.getActivity();

    if (activity == null)
        return;// w  ww  .j  av a2  s  . c o  m

    if (!activity.application.isInP2PFallbackMode()) {
        showProgress = false;
    } else if (download != BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK) {
        showProgress = true;

        if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_STORAGE_PROBLEM) != 0)
            progressView.setText(R.string.blockchain_state_progress_problem_storage);
        else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_NETWORK_PROBLEM) != 0)
            progressView.setText(R.string.blockchain_state_progress_problem_network);
    } else if (bestChainDate != null) {
        final long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime();
        final boolean blockchainUptodate = blockchainLag < Constants.BLOCKCHAIN_UPTODATE_THRESHOLD_MS;

        showProgress = !blockchainUptodate;

        final String downloading = getString(R.string.blockchain_state_progress_downloading);
        final String stalled = getString(R.string.blockchain_state_progress_stalled);

        final String stalledText;
        if (blockchainLag < 2 * DateUtils.DAY_IN_MILLIS) {
            final long hours = blockchainLag / DateUtils.HOUR_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_hours, downloading, hours));
            stalledText = getString(R.string.blockchain_state_progress_hours, stalled, hours);
        } else if (blockchainLag < 2 * DateUtils.WEEK_IN_MILLIS) {
            final long days = blockchainLag / DateUtils.DAY_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_days, downloading, days));
            stalledText = getString(R.string.blockchain_state_progress_days, stalled, days);
        } else if (blockchainLag < 90 * DateUtils.DAY_IN_MILLIS) {
            final long weeks = blockchainLag / DateUtils.WEEK_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_weeks, downloading, weeks));
            stalledText = getString(R.string.blockchain_state_progress_weeks, stalled, weeks);
        } else {
            final long months = blockchainLag / (30 * DateUtils.DAY_IN_MILLIS);
            progressView.setText(getString(R.string.blockchain_state_progress_months, downloading, months));
            stalledText = getString(R.string.blockchain_state_progress_months, stalled, months);
        }

        delayMessageHandler.removeCallbacksAndMessages(null);
        delayMessageHandler.postDelayed(new Runnable() {
            public void run() {
                progressView.setText(stalledText);
            }
        }, Constants.BLOCKCHAIN_DOWNLOAD_THRESHOLD_MS);
    } else {
        showProgress = false;
    }

    progressView.setVisibility(activity.application.isInP2PFallbackMode() ? View.VISIBLE : View.GONE);

    if (activity.application.isInP2PFallbackMode() && !showProgress) {
        progressView.setText(R.string.running_in_p2p_mode);
    }

    getView().setVisibility(activity.application.isInP2PFallbackMode() ? View.VISIBLE : View.GONE);

}

From source file:com.bushstar.htmlcoin_android_wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/*  w  w w.  j  a va 2  s  .c o  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 (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceHTML5.setVisibility(View.VISIBLE);
            viewBalanceHTML5.setPrecision(config.getHTML5Precision(), config.getHTML5Shift());
            viewBalanceHTML5.setPrefix(config.getHTML5Prefix());
            viewBalanceHTML5.setAmount(balance);

            if (showLocalBalance) {
                viewBalanceLocalFrame.setVisibility(View.INVISIBLE);
            }
        } else {
            viewBalanceHTML5.setVisibility(View.INVISIBLE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}

From source file:cc.mintcoin.wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/*from   w w w. j  a va  2 s. c o  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 (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setPrecision(config.getBtcPrecision(), config.getBtcShift());
            viewBalanceBtc.setPrefix(config.getBtcPrefix());
            viewBalanceBtc.setAmount(balance);

            if (showLocalBalance) {
                if (exchangeRate != null) {
                    final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate);
                    viewBalanceLocalFrame.setVisibility(View.VISIBLE);
                    viewBalanceLocal.setPrefix(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
                    viewBalanceLocal.setAmount(localValue);
                    viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
                } else {
                    viewBalanceLocalFrame.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            viewBalanceBtc.setVisibility(View.INVISIBLE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}

From source file:com.feathercoin.wallet.feathercoin.ui.BlockchainStateFragment.java

private void updateView() {
    final boolean disclaimer = prefs.getBoolean(Constants.PREFS_KEY_DISCLAIMER, true);

    final boolean showDisclaimer;
    final boolean showProgress;

    if (download != BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK) {
        showDisclaimer = false;//from   w  w  w.  j  av  a 2  s  . c om
        showProgress = true;

        if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_STORAGE_PROBLEM) != 0)
            progressView.setText(R.string.blockchain_state_progress_problem_storage);
        else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_POWER_PROBLEM) != 0)
            progressView.setText(R.string.blockchain_state_progress_problem_power);
        else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_NETWORK_PROBLEM) != 0)
            progressView.setText(R.string.blockchain_state_progress_problem_network);
    } else if (bestChainDate != null) {
        final long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime();
        final boolean blockchainUptodate = blockchainLag < Constants.BLOCKCHAIN_UPTODATE_THRESHOLD_MS;

        showProgress = !blockchainUptodate;
        showDisclaimer = blockchainUptodate && disclaimer;

        final String downloading = getString(R.string.blockchain_state_progress_downloading);
        final String stalled = getString(R.string.blockchain_state_progress_stalled);

        final String stalledText;
        if (blockchainLag < 2 * DateUtils.DAY_IN_MILLIS) {
            final long hours = blockchainLag / DateUtils.HOUR_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_hours, downloading, hours));
            stalledText = getString(R.string.blockchain_state_progress_hours, stalled, hours);
        } else if (blockchainLag < 2 * DateUtils.WEEK_IN_MILLIS) {
            final long days = blockchainLag / DateUtils.DAY_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_days, downloading, days));
            stalledText = getString(R.string.blockchain_state_progress_days, stalled, days);
        } else if (blockchainLag < 90 * DateUtils.DAY_IN_MILLIS) {
            final long weeks = blockchainLag / DateUtils.WEEK_IN_MILLIS;
            progressView.setText(getString(R.string.blockchain_state_progress_weeks, downloading, weeks));
            stalledText = getString(R.string.blockchain_state_progress_weeks, stalled, weeks);
        } else {
            final long months = blockchainLag / (30 * DateUtils.DAY_IN_MILLIS);
            progressView.setText(getString(R.string.blockchain_state_progress_months, downloading, months));
            stalledText = getString(R.string.blockchain_state_progress_months, stalled, months);
        }

        delayMessageHandler.removeCallbacksAndMessages(null);
        delayMessageHandler.postDelayed(new Runnable() {
            public void run() {
                progressView.setText(stalledText);
            }
        }, Constants.BLOCKCHAIN_DOWNLOAD_THRESHOLD_MS);
    } else {
        showDisclaimer = disclaimer;
        showProgress = false;
    }

    final boolean showReplaying = replaying;

    disclaimerView.setVisibility(showDisclaimer ? View.VISIBLE : View.GONE);
    progressView.setVisibility(showProgress ? View.VISIBLE : View.GONE);
    replayingView.setVisibility(showReplaying ? View.VISIBLE : View.GONE);

    getView().setVisibility(showDisclaimer || showProgress || showReplaying ? View.VISIBLE : View.GONE);
}

From source file:com.rimbit.android_wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;// w  w  w  . j a  v  a  2 s  .  c  o 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 (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceRBT.setVisibility(View.VISIBLE);
            viewBalanceRBT.setPrecision(config.getRBTPrecision(), config.getRBTShift());
            viewBalanceRBT.setPrefix(config.getRBTPrefix());
            viewBalanceRBT.setAmount(balance);

            if (showLocalBalance) {
                if (exchangeRate != null) {
                    final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate);
                    viewBalanceLocalFrame.setVisibility(View.VISIBLE);
                    viewBalanceLocal.setPrefix(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
                    viewBalanceLocal.setAmount(localValue);
                    viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
                } else {
                    viewBalanceLocalFrame.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            viewBalanceRBT.setVisibility(View.INVISIBLE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}

From source file:com.hamradiocoin.wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/*from ww w.  j a v a2 s .  c om*/

    final boolean showProgress;

    if (bestChainDate != null) {
        final long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime();
        final boolean blockchainUptodate = blockchainLag < 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 (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setPrecision(config.getBtcPrecision(), config.getBtcShift());
            viewBalanceBtc.setPrefix(config.getBtcPrefix());
            viewBalanceBtc.setAmount(balance);

            if (showLocalBalance) {
                if (exchangeRate != null) {
                    final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate);
                    viewBalanceLocalFrame.setVisibility(View.VISIBLE);
                    viewBalanceLocal.setPrefix(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
                    viewBalanceLocal.setAmount(localValue);
                    viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
                } else {
                    viewBalanceLocalFrame.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            viewBalanceBtc.setVisibility(View.INVISIBLE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}

From source file:com.matthewmitchell.nubits_android_wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/*from  w w  w. j  av a2 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 (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceNBT.setVisibility(View.VISIBLE);
            viewBalanceNBT.setPrecision(config.getNBTPrecision(), config.getNBTShift());
            viewBalanceNBT.setPrefix(config.getNBTPrefix());
            viewBalanceNBT.setAmount(balance);

            if (showLocalBalance) {
                if (exchangeRate != null) {
                    final BigInteger localValue = WalletUtils.localValue(balance, exchangeRate.rate);
                    viewBalanceLocalFrame.setVisibility(View.VISIBLE);
                    viewBalanceLocal.setPrefix(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
                    viewBalanceLocal.setAmount(localValue);
                    viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
                } else {
                    viewBalanceLocalFrame.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            viewBalanceNBT.setVisibility(View.INVISIBLE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}