Example usage for android.text.format DateUtils FORMAT_SHOW_DATE

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

Introduction

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

Prototype

int FORMAT_SHOW_DATE

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

Click Source Link

Usage

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

private void populateShow() {
    if (mShowCursor == null) {
        return;//w  w  w.ja v a 2s.c  om
    }

    // title
    mShowTitle = mShowCursor.getString(ShowQuery.TITLE);
    mShowPoster = mShowCursor.getString(ShowQuery.POSTER);

    // status
    if (mShowCursor.getInt(ShowQuery.STATUS) == 1) {
        mTextViewStatus.setTextColor(getResources().getColor(
                Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.textColorSgGreen)));
        mTextViewStatus.setText(getString(R.string.show_isalive));
    } else {
        mTextViewStatus.setTextColor(Color.GRAY);
        mTextViewStatus.setText(getString(R.string.show_isnotalive));
    }

    // release time
    String releaseDay = mShowCursor.getString(ShowQuery.RELEASE_DAY);
    long releaseTime = mShowCursor.getLong(ShowQuery.RELEASE_TIME_MS);
    String releaseCountry = mShowCursor.getString(ShowQuery.RELEASE_COUNTRY);
    if (!TextUtils.isEmpty(releaseDay)) {
        String[] values = TimeTools.formatToShowReleaseTimeAndDay(getActivity(), releaseTime, releaseCountry,
                releaseDay);
        mTextViewReleaseTime.setText(values[1] + " " + values[0]);
    } else {
        mTextViewReleaseTime.setText(null);
    }

    // runtime
    mTextViewRuntime.setText(getString(R.string.runtime_minutes, mShowCursor.getInt(ShowQuery.RUNTIME)));

    // network
    mTextViewNetwork.setText(mShowCursor.getString(ShowQuery.NETWORK));

    // favorite button
    final boolean isFavorite = mShowCursor.getInt(ShowQuery.IS_FAVORITE) == 1;
    mButtonFavorite.setEnabled(true);
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mButtonFavorite, 0,
            Utils.resolveAttributeToResourceId(getActivity().getTheme(),
                    isFavorite ? R.attr.drawableStar : R.attr.drawableStar0),
            0, 0);
    mButtonFavorite.setText(isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    CheatSheet.setup(mButtonFavorite, isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    mButtonFavorite.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable until action is complete
            v.setEnabled(false);
            ShowTools.get(v.getContext()).storeIsFavorite(getShowTvdbId(), !isFavorite);
        }
    });

    // overview
    mTextViewOverview.setText(mShowCursor.getString(ShowQuery.OVERVIEW));

    // country for release time calculation
    // show "unknown" if country is not supported
    mTextViewReleaseCountry.setText(
            TimeTools.isUnsupportedCountry(releaseCountry) ? getString(R.string.unknown) : releaseCountry);

    // original release
    String firstRelease = mShowCursor.getString(ShowQuery.FIRST_RELEASE);
    Utils.setValueOrPlaceholder(mTextViewFirstRelease,
            TimeTools.getShowReleaseYear(firstRelease, releaseTime, releaseCountry));

    // content rating
    Utils.setValueOrPlaceholder(mTextViewContentRating, mShowCursor.getString(ShowQuery.CONTENT_RATING));
    // genres
    Utils.setValueOrPlaceholder(mTextViewGenres,
            Utils.splitAndKitTVDBStrings(mShowCursor.getString(ShowQuery.GENRES)));

    // TVDb rating
    String tvdbRating = mShowCursor.getString(ShowQuery.TVDB_RATING);
    if (!TextUtils.isEmpty(tvdbRating)) {
        mTextViewTvdbRating.setText(tvdbRating);
    }

    // last edit
    long lastEditRaw = mShowCursor.getLong(ShowQuery.LAST_EDIT_MS);
    if (lastEditRaw > 0) {
        mTextViewLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditRaw * 1000,
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME));
    } else {
        mTextViewLastEdit.setText(R.string.unknown);
    }

    // IMDb button
    String imdbId = mShowCursor.getString(ShowQuery.IMDBID);
    ServiceUtils.setUpImdbButton(imdbId, mButtonImdb, TAG, getActivity());

    // TVDb button
    ServiceUtils.setUpTvdbButton(getShowTvdbId(), mButtonTvdb, TAG);

    // trakt button
    ServiceUtils.setUpTraktButton(getShowTvdbId(), mButtonTrakt, TAG);

    // web search button
    ServiceUtils.setUpWebSearchButton(mShowTitle, mButtonWebSearch, TAG);

    // shout button
    mButtonComments.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), TraktShoutsActivity.class);
            i.putExtras(TraktShoutsActivity.createInitBundleShow(mShowTitle, getShowTvdbId()));
            ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
            fireTrackerEvent("Shouts");
        }
    });

    // poster, full screen poster button
    final View posterContainer = getView().findViewById(R.id.containerShowPoster);
    final ImageView posterView = (ImageView) posterContainer.findViewById(R.id.imageViewShowPoster);
    Utils.loadPoster(getActivity(), posterView, mShowPoster);
    posterContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class);
            fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH,
                    TheTVDB.buildScreenshotUrl(mShowPoster));
            ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
        }
    });

    // background
    ImageView background = (ImageView) getView().findViewById(R.id.imageViewShowPosterBackground);
    Utils.loadPosterBackground(getActivity(), background, mShowPoster);

    onLoadTraktRatings(true);
}

From source file:com.android.datetimepicker.date.DatePickerDialog.java

private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        mDayOfWeekView//from   w w  w  . ja v a 2s. com
                .setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault())
                        .toUpperCase(Locale.getDefault()));
    }

    mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())
            .toUpperCase(Locale.getDefault()));
    mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}

From source file:hide.com.android.datetimepicker.date.DatePickerDialog.java

@SuppressLint("DefaultLocale")
private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setText(Utils.getLongDayOfWeekName(mCalendar).toUpperCase());
    }// w ww .j ava  2s . c  o m

    mSelectedMonthTextView.setText(Utils.getShortMonthName(mCalendar).toUpperCase());
    mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}

From source file:com.redinput.datetimepickercompat.date.DatePickerDialog.java

private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setText(/*w  w  w .j  av  a  2 s. c  o m*/
                new DateFormatSymbols(Locale.getDefault()).getWeekdays()[mCalendar.get(Calendar.DAY_OF_WEEK)]
                        .toUpperCase(Locale.getDefault()));
    }

    mSelectedMonthTextView
            .setText(new DateFormatSymbols(Locale.getDefault()).getMonths()[mCalendar.get(Calendar.MONTH)]
                    .toUpperCase(Locale.getDefault()));
    mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}

From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java

private static String formatMonthDayYear(Calendar calendar) {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR;
    return formatDateTime(calendar, flags);
}

From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java

private static String formatMonthAndDay(Calendar calendar) {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_NO_YEAR;
    return formatDateTime(calendar, flags);
}

From source file:mirko.android.datetimepicker.date.DatePickerDialog.java

private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        mDayOfWeekView/*from   w  w  w . java  2s.c o  m*/
                .setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault())
                        .toUpperCase(Locale.getDefault()));
    }

    if (mSelectedMonthTextView == null) {
        Log.i(TAG, "mSelectedMonthTextView is null updateDisplay");
    }

    mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())
            .toUpperCase(Locale.getDefault()));
    mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}

From source file:org.holoeverywhere.widget.datetimepicker.date.SimpleMonthView.java

private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);//ww w  . j  a va2 s  .  c  o  m
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        long millis = mCalendar.getTimeInMillis();
        return DateUtils
                .formatDateRange(getContext(), mFormatter, millis, millis, flags, Time.getCurrentTimezone())
                .toString();
    } else {
        if (mMonthAndYearFormatter == null) {
            mMonthAndYearFormatter = new SimpleDateFormat("MMMM yyyy", Locale.getDefault());
            mMonthAndYearFormatter.setTimeZone(TimeZone.getDefault());
        }
        return mMonthAndYearFormatter.format(mCalendar.getTime());
    }
}

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());
                }/* www. j av  a  2  s.c  o  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:app.android.datetimepicker.date.SimpleMonthView.java

private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);//from   w ww. ja va 2 s . c  o  m
    long millis = mCalendar.getTimeInMillis();
    return DateUtils.formatDateRange(getContext(), mFormatter, millis, millis, flags, Time.getCurrentTimezone())
            .toString();
}