List of usage examples for android.text.format DateUtils WEEK_IN_MILLIS
long WEEK_IN_MILLIS
To view the source code for android.text.format DateUtils WEEK_IN_MILLIS.
Click Source Link
From source file:com.appsimobile.appsii.iab.Purchase.java
Purchase(String sku, String itemType, int purchaseState) { mItemType = itemType;//ww w . j av a2 s .c o m mOrderId = UUID.randomUUID().toString(); mPackageName = BuildConfig.APPLICATION_ID; mSku = sku; mPurchaseTime = System.currentTimeMillis() - DateUtils.WEEK_IN_MILLIS; mPurchaseState = purchaseState; mDeveloperPayload = null; mToken = null; mSignature = null; }
From source file:com.ferjuarez.androidthingsdemo.PhotoEntryAdapter.java
@Override protected void populateViewHolder(DoorbellEntryViewHolder viewHolder, PhotoEntry model, int position) { // Display the timestamp if (model != null && model.getTimestamp() != null) { CharSequence prettyTime = DateUtils.getRelativeDateTimeString(mApplicationContext, model.getTimestamp(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); viewHolder.time.setText(prettyTime); // Display the image if (model.getThumbnail() != null) { // Decode image data encoded by the Cloud Vision library byte[] imageBytes = Base64.decode(model.getThumbnail(), Base64.NO_WRAP | Base64.URL_SAFE); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); if (bitmap != null) { viewHolder.image.setImageBitmap(bitmap); } else { Drawable placeholder = ContextCompat.getDrawable(mApplicationContext, R.mipmap.ic_launcher); viewHolder.image.setImageDrawable(placeholder); }// w ww . j a v a 2 s . c o m } } // Display the metadata /*if (model.getAnnotations() != null) { ArrayList<String> keywords = new ArrayList<>(model.getAnnotations().keySet()); int limit = Math.min(keywords.size(), 3); viewHolder.metadata.setText(TextUtils.join("\n", keywords.subList(0, limit))); } else { viewHolder.metadata.setText("no annotations yet"); }*/ }
From source file:com.example.androidthings.doorbell.DoorbellEntryAdapter.java
@Override protected void populateViewHolder(DoorbellEntryViewHolder viewHolder, DoorbellEntry model, int position) { // Display the timestamp CharSequence prettyTime = DateUtils.getRelativeDateTimeString(mApplicationContext, model.getTimestamp(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); viewHolder.time.setText(prettyTime); // Display the image if (model.getImage() != null) { // Decode image data encoded by the Cloud Vision library byte[] imageBytes = Base64.decode(model.getImage(), Base64.NO_WRAP | Base64.URL_SAFE); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); if (bitmap != null) { viewHolder.image.setImageBitmap(bitmap); } else {/* ww w . j ava 2s. c o m*/ Drawable placeholder = ContextCompat.getDrawable(mApplicationContext, R.drawable.ic_image); viewHolder.image.setImageDrawable(placeholder); } } // Display the metadata if (model.getAnnotations() != null) { ArrayList<String> keywords = new ArrayList<>(model.getAnnotations().keySet()); int limit = Math.min(keywords.size(), 3); viewHolder.metadata.setText(TextUtils.join("\n", keywords.subList(0, limit))); } else { viewHolder.metadata.setText("no annotations yet"); } }
From source file:org.exobel.routerkeygen.ui.NetworksListActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override//from w w w. ja v a 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_networks_list); networkListFragment = ((NetworksListFragment) getFragmentManager() .findFragmentById(R.id.frag_networks_list)); if (findViewById(R.id.keygen_fragment) != null) { mTwoPane = true; networkListFragment.setActivateOnItemClick(true); } wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiState = wifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED || wifi.getWifiState() == WifiManager.WIFI_STATE_ENABLING; scanFinished = new WifiScanReceiver(wifi, networkListFragment, this); stateChanged = new WifiStateReceiver(wifi, networkListFragment); final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); welcomeScreenShown = mPrefs.getBoolean(Preferences.VERSION, false); final long timePassed = System.currentTimeMillis() - mPrefs.getLong(LAST_DIALOG_TIME, 0); if (!welcomeScreenShown || (timePassed > DateUtils.WEEK_IN_MILLIS)) { final SharedPreferences.Editor editor = mPrefs.edit(); editor.putBoolean(Preferences.VERSION, true); editor.putLong(LAST_DIALOG_TIME, System.currentTimeMillis()); editor.apply(); // Checking for updates every week if (BuildConfig.APPLICATION_ID.equals("org.exobel.routerkeygen")) { startService(new Intent(getApplicationContext(), UpdateCheckerService.class)); } // } mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { scan(); } }); mSwipeRefreshLayout.setColorSchemeResources(R.color.accent); }
From source file:com.chalmers.feedlr.adapter.FeedAdapter.java
@Override public void bindView(View v, Context context, Cursor c) { super.bindView(v, context, c); // Holds the views, so that a recycled view does not have to find its // XML view//from ww w .j av a 2s .c om ViewHolder viewHolder = (ViewHolder) v.getTag(); // Remove the recycled profile picture viewHolder.profilePicture.setVisibility(View.INVISIBLE); // Get user id int colNumUserId = c.getColumnIndex(DatabaseHelper.ITEM_COLUMN_USER_ID); Cursor cursor = db.getUser(c.getInt(colNumUserId) + ""); cursor.moveToFirst(); // Set source image int colNumSource = cursor.getColumnIndex(DatabaseHelper.USER_COLUMN_SOURCE); if (cursor.getString(colNumSource).equals("facebook")) { viewHolder.source.setBackgroundResource(R.drawable.source_facebook); } else { viewHolder.source.setBackgroundResource(R.drawable.source_twitter); } // Display profile picture int colNumURL = cursor.getColumnIndex(DatabaseHelper.USER_COLUMN_IMGURL); String imgURL = cursor.getString(colNumURL); viewHolder.profilePicture.setTag(numberOfViews++); new DownloadImageTask(viewHolder.profilePicture).execute(imgURL); // Display username int colNumUsername = cursor.getColumnIndex(DatabaseHelper.USER_COLUMN_USERNAME); if (cursor.getString(colNumUsername).length() > 18) { viewHolder.author.setTextSize(16); } viewHolder.author.setText(cursor.getString(colNumUsername)); // Display timestamp int colNumTimestamp = c.getColumnIndex(DatabaseHelper.ITEM_COLUMN_TIMESTAMP); Date timestampDate = new Date(c.getLong(colNumTimestamp)); String parsedTimestamp = DateUtils.getRelativeDateTimeString(context, timestampDate.getTime(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0).toString(); viewHolder.timestamp.setText(stripTimestamp(parsedTimestamp)); }
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. jav a 2s.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;//from www . ja 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:com.owncloud.android.utils.DisplayUtils.java
/** * calculates the relative time string based on the given modificaion timestamp. * * @param context the app's context//from w w w . j a v a 2 s .c om * @param modificationTimestamp the UNIX timestamp of the file modification time. * @return a relative time string */ public static CharSequence getRelativeTimestamp(Context context, long modificationTimestamp) { return getRelativeDateTimeString(context, modificationTimestamp, DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); }
From source file:cc.mintcoin.wallet.ui.WalletBalanceFragment.java
private void updateView() { if (!isAdded()) return;/*from w w w. j ava 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 (!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.rimbit.android_wallet.ui.WalletBalanceFragment.java
private void updateView() { if (!isAdded()) return;//from ww w.j a v a2 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) { 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); } }