Example usage for android.text.format DateUtils FORMAT_ABBREV_ALL

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

Introduction

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

Prototype

int FORMAT_ABBREV_ALL

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

Click Source Link

Usage

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.j  a  v a 2 s.  c  o  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:im.neon.adapters.VectorMessagesAdapter.java

/**
 * Converts a difference of days to a string.
 * @param date the date to display//from   ww  w  .  j a  v  a 2  s .co  m
 * @param nbrDays the number of days between the reference days
 * @return the date text
 */
private String dateDiff(Date date, long nbrDays) {
    if (nbrDays == 0) {
        return mContext.getResources().getString(R.string.today);
    } else if (nbrDays == 1) {
        return mContext.getResources().getString(R.string.yesterday);
    } else if (nbrDays < 7) {
        return (new SimpleDateFormat("EEEE", AdapterUtils.getLocale(mContext))).format(date);
    } else {
        int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_ALL
                | DateUtils.FORMAT_SHOW_WEEKDAY;

        Formatter f = new Formatter(new StringBuilder(50), AdapterUtils.getLocale(mContext));
        return DateUtils.formatDateRange(mContext, f, date.getTime(), date.getTime(), flags).toString();
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static String formatTimeStampString(final Context context, final long timestamp) {
    if (context == null)
        return null;
    final Time then = new Time();
    then.set(timestamp);//from w  ww.  ja v  a  2s. com
    final Time now = new Time();
    now.setToNow();

    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL
            | DateUtils.FORMAT_CAP_AMPM;

    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }

    return DateUtils.formatDateTime(context, timestamp, format_flags);
}

From source file:cx.ring.service.LocalService.java

public void updateTextNotifications() {
    Log.d(TAG, "updateTextNotifications()");

    for (Conversation c : conversations.values()) {
        TreeMap<Long, TextMessage> texts = c.getUnreadTextMessages();
        if (texts.isEmpty() || texts.lastEntry().getValue().isNotified()) {
            continue;
        } else/*from  w ww  .  j  a va 2  s  .com*/
            notificationManager.cancel(c.notificationId);

        CallContact contact = c.getContact();
        if (c.notificationBuilder == null) {
            c.notificationBuilder = new NotificationCompat.Builder(getApplicationContext());
            c.notificationBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE)
                    .setPriority(NotificationCompat.PRIORITY_HIGH).setDefaults(NotificationCompat.DEFAULT_ALL)
                    .setSmallIcon(R.drawable.ic_launcher).setContentTitle(contact.getDisplayName());
        }
        NotificationCompat.Builder noti = c.notificationBuilder;
        Intent c_intent = new Intent(Intent.ACTION_VIEW).setClass(this, ConversationActivity.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        Intent d_intent = new Intent(ACTION_CONV_READ).setClass(this, LocalService.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        noti.setContentIntent(PendingIntent.getActivity(this, new Random().nextInt(), c_intent, 0))
                .setDeleteIntent(PendingIntent.getService(this, new Random().nextInt(), d_intent, 0));

        if (contact.getPhoto() != null) {
            Resources res = getResources();
            int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height);
            int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width);
            noti.setLargeIcon(Bitmap.createScaledBitmap(contact.getPhoto(), width, height, false));
        }
        if (texts.size() == 1) {
            TextMessage txt = texts.firstEntry().getValue();
            txt.setNotified(true);
            noti.setContentText(txt.getMessage());
            noti.setStyle(null);
            noti.setWhen(txt.getTimestamp());
        } else {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            for (TextMessage s : texts.values()) {
                inboxStyle.addLine(Html.fromHtml("<b>"
                        + DateUtils.formatDateTime(this, s.getTimestamp(),
                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_ALL)
                        + "</b> " + s.getMessage()));
                s.setNotified(true);
            }
            noti.setContentText(texts.lastEntry().getValue().getMessage());
            noti.setStyle(inboxStyle);
            noti.setWhen(texts.lastEntry().getValue().getTimestamp());
        }
        notificationManager.notify(c.notificationId, noti.build());
    }
}

From source file:de.vanita5.twittnuker.util.Utils.java

@SuppressWarnings("deprecation")
public static String formatTimeStampString(final Context context, final long timestamp) {
    if (context == null)
        return null;
    final Time then = new Time();
    then.set(timestamp);//from   www  .  ja  va2  s . c  om
    final Time now = new Time();
    now.setToNow();

    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL
            | DateUtils.FORMAT_CAP_AMPM;

    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }

    return DateUtils.formatDateTime(context, timestamp, format_flags);
}

From source file:de.vanita5.twittnuker.util.Utils.java

@SuppressWarnings("deprecation")
public static String formatToLongTimeString(final Context context, final long timestamp) {
    if (context == null)
        return null;
    final Time then = new Time();
    then.set(timestamp);/* ww  w.  ja  v a 2  s.c  o m*/
    final Time now = new Time();
    now.setToNow();

    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL
            | DateUtils.FORMAT_CAP_AMPM;

    format_flags |= DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME;

    return DateUtils.formatDateTime(context, timestamp, format_flags);
}

From source file:org.mariotaku.harmony.MusicPlaybackService.java

private void startSleepTimer(long milliseconds, boolean gentle) {

    Calendar now = Calendar.getInstance();
    mCurrentTimestamp = now.getTimeInMillis();
    mStopTimestamp = mCurrentTimestamp + milliseconds;

    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL
            | DateUtils.FORMAT_CAP_AMPM;

    format_flags |= DateUtils.FORMAT_SHOW_TIME;
    String time = DateUtils.formatDateTime(this, mStopTimestamp, format_flags);

    CharSequence contentTitle = getString(R.string.sleep_timer_enabled);
    CharSequence contentText = getString(R.string.notification_sleep_timer, time);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
    Notification notification = new Notification(R.drawable.ic_stat_playback, null, 0);
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    notification.icon = R.drawable.ic_stat_sleeptimer;
    notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);

    mGentleSleepTimer = gentle;// ww  w .  j  a va  2  s  .co  m
    mNotificationManager.notify(ID_NOTIFICATION_SLEEPTIMER, notification);
    mSleepTimerHandler.sendEmptyMessageDelayed(START_SLEEP_TIMER, milliseconds);
    final int nmin = (int) milliseconds / 60 / 1000;
    Toast.makeText(this, getResources().getQuantityString(R.plurals.NNNminutes_notif, nmin, nmin),
            Toast.LENGTH_SHORT).show();
}

From source file:cn.suishen.email.activity.MessageViewFragmentBase.java

/**
 * @return the given date/time in a human readable form.  The returned string always have
 *     month and day (and year if {@code withYear} is set), so is usually long.
 *     Use {@link DateUtils#getRelativeTimeSpanString} instead to save the screen real estate.
 *//*  ww w .  ja  v a  2  s  .c o  m*/
private String formatDate(long millis, boolean withYear) {
    StringBuilder sb = new StringBuilder();
    Formatter formatter = new Formatter(sb);
    DateUtils.formatDateRange(mContext, formatter, millis, millis,
            DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME
                    | (withYear ? DateUtils.FORMAT_SHOW_YEAR : DateUtils.FORMAT_NO_YEAR));
    return sb.toString();
}

From source file:org.yammp.MusicPlaybackService.java

private void startSleepTimer(long milliseconds, boolean gentle) {

    Calendar now = Calendar.getInstance();
    mCurrentTimestamp = now.getTimeInMillis();
    mStopTimestamp = mCurrentTimestamp + milliseconds;

    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL
            | DateUtils.FORMAT_CAP_AMPM;

    format_flags |= DateUtils.FORMAT_SHOW_TIME;
    String time = DateUtils.formatDateTime(this, mStopTimestamp, format_flags);

    CharSequence contentTitle = getString(R.string.sleep_timer_enabled);
    CharSequence contentText = getString(R.string.notification_sleep_timer, time);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setOngoing(true);/*from  w  w  w .j a  va2s. c om*/
    builder.setSmallIcon(R.drawable.ic_stat_sleeptimer);
    builder.setContentIntent(contentIntent);
    builder.setContentTitle(contentTitle);
    builder.setContentText(contentText);

    mGentleSleepTimer = gentle;
    mNotificationManager.notify(ID_NOTIFICATION_SLEEPTIMER, builder.getNotification());
    mSleepTimerHandler.sendEmptyMessageDelayed(START_SLEEP_TIMER, milliseconds);
    Toast.makeText(this, getResources().getQuantityString(R.plurals.NNNminutes_notif,
            Integer.valueOf((int) milliseconds / 60 / 1000), Integer.valueOf((int) milliseconds / 60 / 1000)),
            Toast.LENGTH_SHORT).show();
}