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:org.dronix.android.unisannio.fragment.TabThree.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tabone, container, false);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(getString(R.string.avvisi_giurisprudenza));

    mPullRefreshListView = (PullToRefreshListView) view.findViewById(R.id.pull_refresh_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        @Override//from   w  w  w  . j a v a  2  s .c  o  m
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            mPullRefreshListView.setLastUpdatedLabel(DateUtils.formatDateTime(getActivity(),
                    System.currentTimeMillis(),
                    DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL));

            new NewsRetriever().execute();
        }
    });

    ListView actualListView = mPullRefreshListView.getRefreshableView();

    news = new ArrayList<NewsIng>();
    news.add(new NewsIng(getString(R.string.pull), "", null, null, ""));

    mAdapter = new NewsIngAdapter(getActivity(), news);

    actualListView.setAdapter(mAdapter);

    actualListView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Intent i = new Intent(getActivity(), NewsDetailActivity.class);
            i.putExtra("newsing", news.get(--position));
            startActivity(i);
        }
    });

    return view;
}

From source file:com.dgsd.android.ShiftTracker.Adapter.WeekPagerAdapter.java

protected String getTitleForPosition(int pos) {
    mTime.setJulianDay(getJulianDayForPosition(pos));
    if (mTime.weekDay != mWeekStartDay) {
        while (mTime.weekDay != mWeekStartDay) {
            mTime.monthDay--;/*from w  ww  .ja  va 2s.  c  om*/
            mTime.normalize(true);
        }
    }

    long startMillis = mTime.toMillis(true);
    long endMillis = startMillis + (1000 * 60 * 60 * 24 * 7);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL;
    mStringBuilder.setLength(0);

    return DateUtils.formatDateRange(mContext, mFormatter, startMillis, endMillis, flags, mTime.timezone)
            .toString();
}

From source file:com.midooo.ui.activitys.ImageListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    layoutView = inflater.inflate(R.layout.ac_image_list, null);

    imageUrls = Constants.IMAGES;//from w  ww .  j  a va 2  s. c  o m
    options = Constants.options;

    //listView = (ListView) layoutView.findViewById(android.R.id.list);

    mPullRefreshListView = (PullToRefreshListView) layoutView.findViewById(R.id.pull_refresh_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        FaXingQuanMainActivity fca = (FaXingQuanMainActivity) getActivity();

        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            String label = DateUtils.formatDateTime(fca.getApplicationContext(), System.currentTimeMillis(),
                    DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);

            // Update the LastUpdatedLabel
            refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);

            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    // Add an end-of-list listener
    mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
        @Override
        public void onLastItemVisible() {
            Toast.makeText((FaXingQuanMainActivity) getActivity(), "End of List!", Toast.LENGTH_SHORT).show();
        }
    });

    ListView actualListView = mPullRefreshListView.getRefreshableView();
    // Need to use the Actual ListView when registering for Context Menu
    registerForContextMenu(actualListView);

    /**
     * Add Sound Event Listener
     */
    SoundPullEventListener<ListView> soundListener = new SoundPullEventListener<ListView>(
            (FaXingQuanMainActivity) getActivity());
    soundListener.addSoundEvent(State.PULL_TO_REFRESH, R.raw.pull_event);
    soundListener.addSoundEvent(State.RESET, R.raw.reset_sound);
    soundListener.addSoundEvent(State.REFRESHING, R.raw.refreshing_sound);
    mPullRefreshListView.setOnPullEventListener(soundListener);

    //listView.addHeaderView(new ImagePagerFragment().getView(), null, false);
    mAdapter = new ItemAdapter(inflater);
    actualListView.setAdapter(mAdapter);
    actualListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //startImagePagerActivity(position);
            Log.w("---doop---", "startImagePagerActivity(position)");
        }
    });

    /*      
          listView.setAdapter(new ItemAdapter(inflater));
          listView.setOnItemClickListener(new OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    //startImagePagerActivity(position);
    Log.w("---doop---", "startImagePagerActivity(position)");
             }
          });
                  
    */
    //setListViewHeightBasedOnChildren(listView);

    return layoutView;
}

From source file:com.socialdisasters.other.MessageAdapter.java

public static String formatTimeStampString(Context context, long when, boolean fullFormat) {
    Time then = new Time();
    then.set(when);//from   w w w  .  j a v  a 2s.  co m
    Time now = new Time();
    now.setToNow();

    // Basic settings for formatDateTime() we want for all cases.
    int format_flags = DateUtils.FORMAT_ABBREV_ALL;

    // If the message is from a different year, show the date and year.
    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        // If it is from a different day than today, show only the date.
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        // Otherwise, if the message is from today, show the time.
        format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }

    // If the caller has asked for full details, make sure to show the date
    // and time no matter what we've determined above (but still make showing
    // the year only happen if it is a different year from today).
    if (fullFormat) {
        format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
    }

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

From source file:com.example.xyzreader.ui.articlelist.ArticleListAdapter.java

@Override
public void onBindViewHolder(final ViewHolder viewHolder, Cursor cursor) {

    // set up the animation per the xml files
    int position = cursor.getPosition();
    Animation animation = AnimationUtils.loadAnimation(mContext,
            (position > mLastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
    viewHolder.itemView.startAnimation(animation);
    mLastPosition = position;/*from  w w  w.  j  a  v  a2  s.c  o  m*/

    //show the thumb image (with progress spinner) or the "not found" image
    viewHolder.mArticleListImageProgressBar.setVisibility(View.VISIBLE);
    Picasso.with(mContext).load(cursor.getString(ArticleLoader.Query.THUMB_URL))
            .into(viewHolder.mArticleListImageView, new Callback() {
                @Override
                public void onSuccess() {
                    viewHolder.mArticleListImageProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onError() {
                    viewHolder.mArticleListImageView.setImageResource(R.mipmap.ic_launcher);
                }
            });

    // show the title and byline
    viewHolder.mArticleListItemTitle.setText(cursor.getString(ArticleLoader.Query.TITLE));
    String byLine = DateUtils
            .getRelativeTimeSpanString(cursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by " + cursor.getString(ArticleLoader.Query.AUTHOR);
    viewHolder.mArticleListItemByLine.setText(byLine);
}

From source file:com.example.xyzreader.ui.DetailFragment.java

private void bindViews() {
    if (mRootView == null) {
        return;/*from  w ww .j  a v  a  2s  .co  m*/
    }

    TextView titleView = (TextView) mRootView.findViewById(R.id.article_title);
    TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
    TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (mCursor != null) {

        String title = mCursor.getString(ArticleLoader.Query.TITLE);
        final String shareText = getString(R.string.share_text) + " "
                + mCursor.getString(ArticleLoader.Query.TITLE);

        mRootView.findViewById(R.id.share_fab).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(
                        Intent.createChooser(ShareCompat.IntentBuilder.from(getActivity()).setType("text/plain")
                                .setText(shareText).getIntent(), getString(R.string.action_share)));
            }
        });

        titleView.setText(title);

        bylineView.setText(Html.fromHtml(DateUtils
                .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                        System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
                .toString() + " by <font color='#000000'>" + mCursor.getString(ArticleLoader.Query.AUTHOR)
                + "</font>"));
        bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));

        Picasso.with(getActivity()).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(mPhotoView);
        mPhotoView.setContentDescription(mCursor.getString(ArticleLoader.Query.TITLE));

    } else {
        titleView.setText("N/A");
        bylineView.setText("N/A");
        bodyView.setText("N/A");
    }

}

From source file:com.jpventura.xyzreader.ui.ArticleDetailFragment.java

private void bindViews() {
    if (mRootView == null) {
        return;//w  w  w .j ava  2s .  com
    }

    mTitleView = (TextView) mRootView.findViewById(R.id.article_title);
    mSubitleView = (TextView) mRootView.findViewById(R.id.article_byline);
    mSubitleView.setMovementMethod(new LinkMovementMethod());
    mBodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (null == mCursor) {
        mRootView.setVisibility(View.GONE);
        mTitleView.setText("N/A");
        mSubitleView.setText("N/A");
        mBodyView.setText("N/A");
        return;
    }

    mRootView.setAlpha(0);
    mRootView.setVisibility(View.VISIBLE);
    mRootView.animate().alpha(1);
    mTitleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
    mSubitleView.setText(Html.fromHtml(DateUtils
            .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by <font color='#ffffff'>" + mCursor.getString(ArticleLoader.Query.AUTHOR)
            + "</font>"));
    mBodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));

    Picasso.with(getActivity()).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(mPhotoView, this);
}

From source file:com.example.xyzreader.ui.articledetail.ArticleDetailFragment.java

private void bindViews() {
    if (mRootView == null || mCursor == null) {
        return;//from   ww w. ja va2  s. c  o  m
    }
    final ImageView detailImageView = (ImageView) mRootView.findViewById(R.id.detail_image);
    final TextView articleTitle = (TextView) mRootView.findViewById(R.id.article_detail_title);
    final TextView articleByLine = (TextView) mRootView.findViewById(R.id.article_detail_byline);
    final TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long itemId = mCursor.getLong(ArticleLoader.Query._ID);
        String imageTransitionName = mContext.getString(R.string.image_transition_name) + itemId;
        detailImageView.setTransitionName(imageTransitionName);
        //            Log.d(LOG_TAG, "detail image transition name = '" + imageTransitionName + "'");
    }

    Picasso.with(mContext).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(detailImageView,
            new Callback() {
                @Override
                public void onSuccess() {
                    //                        Log.d(LOG_TAG, "successful image load");
                    mPalette = generatePalette(detailImageView);
                    if (getUserVisibleHint() && isResumed()) {
                        setAppBarColor();
                    }
                }

                @Override
                public void onError() {
                    //                        Log.d(LOG_TAG, "image load FAIL");
                }
            });

    articleTitle.setText(mCursor.getString(ArticleLoader.Query.TITLE));

    String byLine = DateUtils
            .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by " + mCursor.getString(ArticleLoader.Query.AUTHOR);
    articleByLine.setText(byLine);

    // Light up the embedded links in the body of the article
    bodyView.setMovementMethod(LinkMovementMethod.getInstance());

    //        bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
    bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
}

From source file:com.abc.driver.MainActivity.java

public void initFHorders() {
    mFHorderLv = (PullToRefreshListView) findViewById(R.id.huoyun_lv);
    mFHorderLv.setMode(Mode.BOTH);//from  ww  w.j av a 2  s  .  com

    mFHorderMore = (ViewGroup) LayoutInflater.from(MainActivity.this).inflate(R.layout.more_list, null);
    mFHorderMore.setVisibility(View.GONE);

    mFHolderMoreTv = (TextView) mFHorderMore.getChildAt(0);

    // mFHorderLv.addFooterView(mFHorderMore);
    mFHorderLv.setOnItemClickListener(mFHorderDetailListener);
    mFHorderLv.setAdapter(mFHorderTypes.nHorderAdapter);
    // Set a listener to be invoked when the list should be refreshed.

    mFHorderLv.setOnRefreshListener(new OnRefreshListener2<ListView>() {

        @Override
        public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            isForceRefreshFH = 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);
            mFHorderDownLoadTask = new FHorderDownLoadTask();
            mFHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION);
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
            isForceRefreshFH = 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);// 

            mFHorderDownLoadTask = new FHorderDownLoadTask();
            mFHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION);
        }

    });

}

From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java

@Override
public void onDateSelected(int typeCode, int julianDay) {
    if (getActivity() == null)
        return;//from ww  w.java2s. c  o  m

    final long millis = TimeUtils.getStartMillisForJulianDay(julianDay);
    String formatted = DateUtils.formatDateRange(getActivity(), millis, millis,
            DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_DATE);

    if (typeCode == TYPE_CODE_START) {
        mStartDate.setTag(julianDay);
        mStartDate.setText(formatted);
    } else {
        mEndDate.setTag(julianDay);
        mEndDate.setText(formatted);
    }
}