Example usage for android.text.format DateUtils WEEK_IN_MILLIS

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

Introduction

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

Prototype

long WEEK_IN_MILLIS

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

Click Source Link

Usage

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

private void updateView() {
    if (!isAdded())
        return;// ww  w.  j  av a  2s  . co m

    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.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;/*ww w  .java2s .c o m*/
        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.matthewmitchell.nubits_android_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) {
            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);
    }
}

From source file:de.schildbach.litecoinwallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/*w  w  w.j av a2  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) {
            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 = btcShift == 0 ? Constants.CURRENCY_CODE_BTC : Constants.CURRENCY_CODE_MBTC;

            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setPrecision(btcPrecision, btcShift);
            viewBalanceBtc.setPrefix(prefix);
            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.peercoin_android_wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;//from w  ww.  j  a  v a 2  s.  com

    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) {
            viewBalancePPC.setVisibility(View.VISIBLE);
            viewBalancePPC.setPrecision(config.getPPCPrecision(), config.getPPCShift());
            viewBalancePPC.setPrefix(config.getPPCPrefix());
            viewBalancePPC.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 {
            viewBalancePPC.setVisibility(View.INVISIBLE);
        }

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

From source file:hashengineering.digitalcoin.wallet.ui.WalletBalanceFragment.java

private void updateView() {
    if (!isAdded())
        return;/* ww 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) {
            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setPrecision(Integer.parseInt(
                    prefs.getString(Constants.PREFS_KEY_BTC_PRECISION, Constants.PREFS_DEFAULT_BTC_PRECISION)));
            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:de.schildbach.wallet.goldcoin.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  ww w .j  a  va 2 s  .  c o  m
        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(
            View.VISIBLE /*showDisclaimer || showProgress || showReplaying ? View.VISIBLE : View.GONE*/);
}

From source file:de.schildbach.wallet.elysium.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 a  v a  2 s.  co  m*/
        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:de.schildbach.wallet.ui.WalletBalanceFragment.java

private void updateView() {
    final boolean showProgress;

    if (download != BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK) {
        showProgress = true;//  w  w w .  j a  v a 2 s .  co  m

        if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_STORAGE_PROBLEM) != 0)
            viewProgress.setText(R.string.blockchain_state_progress_problem_storage);
        else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_NETWORK_PROBLEM) != 0)
            viewProgress.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;
            viewProgress.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;
            viewProgress.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;
            viewProgress.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);
            viewProgress.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() {
                viewProgress.setText(stalledText);
            }
        }, Constants.BLOCKCHAIN_DOWNLOAD_THRESHOLD_MS);
    } else {
        showProgress = false;
    }

    if (!showProgress) {
        viewBalance.setVisibility(View.VISIBLE);

        if (!showLocalBalance)
            viewBalanceLocalFrame.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setPrecision(Integer.parseInt(prefs.getString(Constants.PREFS_KEY_BTC_PRECISION,
                    Integer.toString(Constants.BTC_PRECISION))));
            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.vuze.android.remote.fragment.TorrentInfoFragment.java

private void fillTimeline(FragmentActivity a, Map<?, ?> mapTorrent) {
    String s;//from  w  w w .j a  v a  2 s .c o  m
    long addedOn = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_DATE_ADDED, 0);
    s = addedOn <= 0 ? ""
            : DateUtils.getRelativeDateTimeString(getActivity(), addedOn * 1000, DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.WEEK_IN_MILLIS * 2, 0).toString();
    fillRow(a, R.id.torrentInfo_row_addedOn, R.id.torrentInfo_val_addedOn, s);

    long activeOn = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_DATE_ACTIVITY, 0);
    s = activeOn <= 0 ? ""
            : DateUtils.getRelativeDateTimeString(getActivity(), activeOn * 1000, DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.WEEK_IN_MILLIS * 2, 0).toString();
    fillRow(a, R.id.torrentInfo_row_lastActiveOn, R.id.torrentInfo_val_lastActiveOn, s);

    long doneOn = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_DATE_DONE, 0);
    s = doneOn <= 0 ? ""
            : DateUtils.getRelativeDateTimeString(getActivity(), doneOn * 1000, DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.WEEK_IN_MILLIS * 2, 0).toString();
    fillRow(a, R.id.torrentInfo_row_completedOn, R.id.torrentInfo_val_completedOn, s);

    long startedOn = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_DATE_STARTED, 0);
    s = startedOn <= 0 ? ""
            : DateUtils.getRelativeDateTimeString(getActivity(), startedOn * 1000, DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.WEEK_IN_MILLIS * 2, 0).toString();
    fillRow(a, R.id.torrentInfo_row_startedOn, R.id.torrentInfo_val_startedOn, s);

    long secondsDownloading = MapUtils.getMapLong(mapTorrent,
            TransmissionVars.FIELD_TORRENT_SECONDS_DOWNLOADING, 0);
    s = secondsDownloading <= 0 ? "" : DisplayFormatters.prettyFormat(secondsDownloading);
    fillRow(a, R.id.torrentInfo_row_downloadingFor, R.id.torrentInfo_val_downloadingFor, s);

    long secondsUploading = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_SECONDS_SEEDING, 0);
    s = secondsUploading <= 0 ? "" : DisplayFormatters.prettyFormat(secondsUploading);
    fillRow(a, R.id.torrentInfo_row_seedingFor, R.id.torrentInfo_val_seedingFor, s);

    long etaSecs = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_ETA, -1);
    s = etaSecs > 0 && etaSecs * 1000 < DateUtils.WEEK_IN_MILLIS ? DisplayFormatters.prettyFormat(etaSecs) : "";
    fillRow(a, R.id.torrentInfo_row_eta, R.id.torrentInfo_val_eta, s);

}