List of usage examples for android.text.format DateUtils FORMAT_SHOW_TIME
int FORMAT_SHOW_TIME
To view the source code for android.text.format DateUtils FORMAT_SHOW_TIME.
Click Source Link
From source file:com.adguard.android.contentblocker.MainActivity.java
private void refreshStatistics() { PreferencesService preferencesService = ServiceLocator.getInstance(this).getPreferencesService(); final FilterService filterService = ServiceLocator.getInstance(this).getFilterService(); Date now = preferencesService.getLastUpdateCheck(); // Last update time if (now == null) { List<FilterList> filters = filterService.getFilters(); for (FilterList filter : filters) { if (now == null) { now = filter.getTimeUpdated(); LOG.info("Using first time of {}", filter.getName()); } else { if (filter.getTimeUpdated().after(now)) { now = filter.getTimeUpdated(); LOG.info("Using time of {}", filter.getName()); }/*from ww w.ja v a 2s. co m*/ } } if (now == null) { now = new Date(); } } String dateTime = DateUtils.formatDateTime(this, now.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_TIME); ((TextView) findViewById(R.id.updateTimeTextView)).setText(dateTime); // Enabled filters count int filterListCount = filterService.getEnabledFilterListCount(); ((TextView) findViewById(R.id.filtersCountTextView)).setText(String.format("%d", filterListCount)); // Filter rules count int filterRuleCount = filterService.getFilterRuleCount(); ((TextView) findViewById(R.id.rulesCountTextView)).setText(String.format("%d", filterRuleCount)); if (filterRuleCount == 0) { new ApplyAndRefreshTask(filterService, this).execute(); } }
From source file:io.mpos.ui.shared.view.SummaryFragment.java
private void showTransactionDateTime() { //Set the date and time if (mTransactionDataHolder.getCreatedTimestamp() == 0) { mDateTimeView.setVisibility(View.GONE); } else {/*ww w. j a v a 2 s . co m*/ mDateTimeView.setText(DateUtils.formatDateTime(this.getActivity().getApplicationContext(), mTransactionDataHolder.getCreatedTimestamp(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR)); } }
From source file:com.battlelancer.seriesguide.ui.EpisodeDetailsFragment.java
private void populateEpisodeData(Cursor cursor) { if (cursor == null || !cursor.moveToFirst()) { // no data to display if (mEpisodeContainer != null) { mEpisodeContainer.setVisibility(View.GONE); }//from w w w .j av a 2 s .c o m return; } mShowTvdbId = cursor.getInt(DetailsQuery.REF_SHOW_ID); mSeasonNumber = cursor.getInt(DetailsQuery.SEASON); mEpisodeNumber = cursor.getInt(DetailsQuery.NUMBER); mShowRunTime = cursor.getInt(DetailsQuery.SHOW_RUNTIME); mEpisodeReleaseTime = cursor.getLong(DetailsQuery.FIRST_RELEASE_MS); // title and description mEpisodeTitle = cursor.getString(DetailsQuery.TITLE); mTitle.setText(mEpisodeTitle); mDescription.setText(cursor.getString(DetailsQuery.OVERVIEW)); // show title mShowTitle = cursor.getString(DetailsQuery.SHOW_TITLE); // release time and day SpannableStringBuilder timeAndNumbersText = new SpannableStringBuilder(); if (mEpisodeReleaseTime != -1) { Date actualRelease = TimeTools.getEpisodeReleaseTime(getActivity(), mEpisodeReleaseTime); mReleaseDay.setText(TimeTools.formatToDate(getActivity(), actualRelease)); // "in 15 mins (Fri)" timeAndNumbersText.append(getString(R.string.release_date_and_day, TimeTools.formatToRelativeLocalReleaseTime(getActivity(), actualRelease), TimeTools.formatToLocalReleaseDay(actualRelease)).toUpperCase(Locale.getDefault())); timeAndNumbersText.append(" "); } else { mReleaseDay.setText(R.string.unknown); } // absolute number (e.g. relevant for Anime): "ABSOLUTE 142" int numberStartIndex = timeAndNumbersText.length(); int absoluteNumber = cursor.getInt(DetailsQuery.ABSOLUTE_NUMBER); if (absoluteNumber > 0) { timeAndNumbersText.append(getString(R.string.episode_number_absolute)).append(" ") .append(String.valueOf(absoluteNumber)); // de-emphasize number timeAndNumbersText.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_Caption_Dim), numberStartIndex, timeAndNumbersText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } mReleaseTime.setText(timeAndNumbersText); // guest stars Utils.setLabelValueOrHide(mLabelGuestStars, mGuestStars, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.GUESTSTARS))); // DVD episode number Utils.setLabelValueOrHide(mLabelDvd, mDvd, cursor.getDouble(DetailsQuery.DVDNUMBER)); // directors Utils.setValueOrPlaceholder(mDirectors, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.DIRECTORS))); // writers Utils.setValueOrPlaceholder(mWriters, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.WRITERS))); // last TVDb edit date long lastEditSeconds = cursor.getLong(DetailsQuery.LASTEDIT); if (lastEditSeconds > 0) { mLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditSeconds * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME)); } else { mLastEdit.setText(R.string.unknown); } // ratings mRatingsContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { rateOnTrakt(); } }); mRatingsContainer.setFocusable(true); CheatSheet.setup(mRatingsContainer, R.string.action_rate); // TVDb rating String tvdbRating = cursor.getString(DetailsQuery.RATING); if (!TextUtils.isEmpty(tvdbRating)) { mTvdbRating.setText(tvdbRating); } // trakt ratings loadTraktRatings(true); // episode image final String imagePath = cursor.getString(DetailsQuery.IMAGE); mImageContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class); fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH, imagePath); ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); } }); loadImage(imagePath); // check in button final int episodeTvdbId = cursor.getInt(DetailsQuery._ID); mCheckinButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // display a check-in dialog CheckInDialogFragment f = CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId); f.show(getFragmentManager(), "checkin-dialog"); fireTrackerEvent("Check-In"); } }); CheatSheet.setup(mCheckinButton); // watched button mEpisodeFlag = cursor.getInt(DetailsQuery.WATCHED); boolean isWatched = EpisodeTools.isWatched(mEpisodeFlag); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchedButton, 0, isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch), 0, 0); mWatchedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleWatched(); fireTrackerEvent("Toggle watched"); } }); mWatchedButton.setEnabled(true); mWatchedButton.setText(isWatched ? R.string.action_unwatched : R.string.action_watched); CheatSheet.setup(mWatchedButton, isWatched ? R.string.action_unwatched : R.string.action_watched); // collected button mCollected = cursor.getInt(DetailsQuery.COLLECTED) == 1; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mCollectedButton, 0, mCollected ? R.drawable.ic_collected : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect), 0, 0); mCollectedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleCollected(); fireTrackerEvent("Toggle collected"); } }); mCollectedButton.setEnabled(true); mCollectedButton.setText(mCollected ? R.string.action_collection_remove : R.string.action_collection_add); CheatSheet.setup(mCollectedButton, mCollected ? R.string.action_collection_remove : R.string.action_collection_add); // skip button boolean isSkipped = EpisodeTools.isSkipped(mEpisodeFlag); if (isWatched) { // if watched do not allow skipping mSkipButton.setVisibility(View.INVISIBLE); } else { mSkipButton.setVisibility(View.VISIBLE); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mSkipButton, 0, isSkipped ? R.drawable.ic_skipped : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableSkip), 0, 0); mSkipButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleSkipped(); fireTrackerEvent("Toggle skipped"); } }); mSkipButton.setText(isSkipped ? R.string.action_dont_skip : R.string.action_skip); CheatSheet.setup(mSkipButton, isSkipped ? R.string.action_dont_skip : R.string.action_skip); } mSkipButton.setEnabled(true); // service buttons ServiceUtils.setUpTraktButton(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mTraktButton, TAG); // IMDb String imdbId = cursor.getString(DetailsQuery.IMDBID); if (TextUtils.isEmpty(imdbId)) { // fall back to show IMDb id imdbId = cursor.getString(DetailsQuery.SHOW_IMDBID); } ServiceUtils.setUpImdbButton(imdbId, mImdbButton, TAG, getActivity()); // TVDb final int seasonTvdbId = cursor.getInt(DetailsQuery.REF_SEASON_ID); ServiceUtils.setUpTvdbButton(mShowTvdbId, seasonTvdbId, getEpisodeTvdbId(), mTvdbButton, TAG); // trakt comments mCommentsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), TraktShoutsActivity.class); intent.putExtras(TraktShoutsActivity.createInitBundleEpisode(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mEpisodeTitle)); ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); fireTrackerEvent("Comments"); } }); mEpisodeContainer.setVisibility(View.VISIBLE); }
From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) super.onPopulateAccessibilityEvent(event); int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourView) { flags |= DateUtils.FORMAT_24HOUR; } else {/*from w w w . j a va2 s . c o m*/ flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDateUtterance = DateUtils.formatDateTime(getContext(), mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); }
From source file:com.abc.driver.MainActivity.java
public void initHorders() { for (int i = 0; i < 3; i++) { mHorderTypes[i] = new HorderType(i); }/*from w w w . jav a2 s .co m*/ mPartyMore = (ViewGroup) LayoutInflater.from(MainActivity.this).inflate(R.layout.more_list, null); mPartyMore.setVisibility(View.GONE); mMoreTv = (TextView) mPartyMore.getChildAt(0); // mHorderLv.addFooterView(mPartyMore); mHorderLv.setOnItemClickListener(mHorderDetailListener); mHorderLv.setAdapter(mHorderTypes[mCurrRadioIdx].nHorderAdapter); // Set a listener to be invoked when the list should be refreshed. mHorderLv.setOnRefreshListener(new OnRefreshListener2<ListView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { isForceRefresh = true; String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);// // mHorderTypes[mCurrRadioIdx] = new HorderType(mCurrRadioIdx); mHorderDownLoadTask = new HorderDownLoadTask(); mHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION); } @Override public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { isForceRefresh = true; // mHorderTypes[mCurrRadioIdx] = new HorderType(mCurrRadioIdx); String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);// mHorderDownLoadTask = new HorderDownLoadTask(); mHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION); } }); }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public void onTimeSelected(long millis) { if (getActivity() == null) return;/*w w w. ja v a2s . c o m*/ TextView tv = null; if (mLastTimeSelected == LastTimeSelected.START) tv = mStartTime; else if (mLastTimeSelected == LastTimeSelected.END) tv = mEndTime; else return; //O no! This should never happen! tv.setTag(millis); int flags = DateUtils.FORMAT_SHOW_TIME; if (DateFormat.is24HourFormat(getActivity())) flags |= DateUtils.FORMAT_24HOUR; else flags |= DateUtils.FORMAT_12HOUR; tv.setError(null); tv.setText(DateUtils.formatDateRange(getActivity(), millis, millis, flags)); }
From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourView) { flags |= DateUtils.FORMAT_24HOUR; } else {/*from w w w .ja v a 2s . c o m*/ flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDate = DateUtils.formatDateTime(mContext, mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDate); }
From source file:com.appeaser.sublimepickerlibrary.timepicker.SublimeTimePicker.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); int flags = DateUtils.FORMAT_SHOW_TIME; // The deprecation status does not show up in the documentation and // source code does not outline the alternative. // Leaving this as is for now. if (mIs24HourView) { //noinspection deprecation flags |= DateUtils.FORMAT_24HOUR; } else {/* w w w . j av a 2 s .c o m*/ //noinspection deprecation flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDate = DateUtils.formatDateTime(mContext, mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDate); }
From source file:com.google.samples.apps.iosched.util.UIUtils.java
/** * @param startTime The start time of a session in millis. * @param context The context to be used for getting the display timezone. * @return Formats a given startTime to the specific short time. example: 12:00 AM *//*from w w w.j ava2 s. c o m*/ public static String formatTime(long startTime, Context context) { StringBuilder sb = new StringBuilder(); DateUtils.formatDateRange(context, new Formatter(sb), startTime, startTime, DateUtils.FORMAT_SHOW_TIME, SettingsUtils.getDisplayTimeZone(context).getID()); return sb.toString(); }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.app_lst_view, container, false); ((Button) rootView.findViewById(R.id.btn_export)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doExport();/*from ww w. ja v a2s . c o m*/ } }); ((Button) rootView.findViewById(R.id.btn_sel_all)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toggleAllSelection(true); } }); ((Button) rootView.findViewById(R.id.btn_desel_all)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toggleAllSelection(false); } }); ListView lstApps = (ListView) rootView.findViewById(android.R.id.list); lstApps.setFastScrollEnabled(true); registerForContextMenu(lstApps); ArrayAdapter<AppInfoHolder> adapter = new ArrayAdapter<AppInfoHolder>(getActivity(), R.layout.app_item) { public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent) { View view; TextView txt_name, txt_size, txt_ver, txt_time; ImageView img_type; CheckBox ckb_app; Activity ctx = getActivity(); if (convertView == null) { view = ctx.getLayoutInflater().inflate(R.layout.app_item, parent, false); } else { view = convertView; } if (position >= getCount()) { return view; } AppInfoHolder itm = getItem(position); txt_name = (TextView) view.findViewById(R.id.app_name); if (itm.label != null) { txt_name.setText(itm.label); } else { txt_name.setText(itm.appInfo.packageName); } if (Util.getBooleanOption(ctx, PSTORE_APPMANAGER, PREF_KEY_SHOW_BACKUP_STATE)) { switch (itm.backupState) { case 1: txt_name.setTextColor(Color.YELLOW); break; case 2: txt_name.setTextColor(0xff00bb00); break; case 3: txt_name.setTextColor(0xffF183BD); break; default: txt_name.setTextColor(Color.WHITE); break; } } else { txt_name.setTextColor(Color.WHITE); } txt_ver = (TextView) view.findViewById(R.id.app_version); txt_ver.setText(itm.version); txt_size = (TextView) view.findViewById(R.id.app_size); if (Util.getBooleanOption(ctx, PSTORE_APPMANAGER, PREF_KEY_SHOW_SIZE)) { txt_size.setVisibility(View.VISIBLE); if (itm.size != null) { txt_size.setText(itm.size); } else { txt_size.setText(R.string.computing); } } else { txt_size.setVisibility(View.GONE); } txt_time = (TextView) view.findViewById(R.id.app_time); if (Util.getBooleanOption(ctx, PSTORE_APPMANAGER, PREF_KEY_SHOW_DATE)) { txt_time.setVisibility(View.VISIBLE); if (itm.appInfo.sourceDir != null) { File f = new File(itm.appInfo.sourceDir); txt_time.setText(DateUtils.formatDateTime(ctx, f.lastModified(), DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME)); } else { txt_time.setText(R.string.unknown); } } else { txt_time.setVisibility(View.GONE); } img_type = (ImageView) view.findViewById(R.id.img_app_icon); if (Util.getBooleanOption(ctx, PSTORE_APPMANAGER, PREF_KEY_SHOW_ICON)) { img_type.setVisibility(View.VISIBLE); if (itm.icon != null) { img_type.setImageDrawable(itm.icon); } else { try { img_type.setImageDrawable(ctx.getPackageManager().getDefaultActivityIcon()); } catch (Exception fe) { img_type.setImageDrawable(null); Log.e(ApplicationManager.class.getName(), fe.getLocalizedMessage()); } } } else { img_type.setVisibility(View.GONE); } ckb_app = (CheckBox) view.findViewById(R.id.ckb_app); ckb_app.setTag(position); ckb_app.setChecked(itm.checked); ckb_app.setOnCheckedChangeListener(checkListener); View imgLock = view.findViewById(R.id.img_lock); imgLock.setVisibility(itm.isPrivate ? View.VISIBLE : View.GONE); return view; } }; setListAdapter(adapter); return rootView; }