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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tabone, container, false);
    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 . ja  v a2s  . 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<News>();
    news.add(new News("", getString(R.string.pull)));

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

    actualListView.setAdapter(mAdapter);
    return view;
}

From source file:ca.rmen.android.poetassistant.wotd.WotdLoader.java

@Override
public ResultListData<WotdEntry> loadInBackground() {
    Log.d(TAG, "loadInBackground()");

    List<WotdEntry> data = new ArrayList<>(100);

    Cursor cursor = mDictionary.getRandomWordCursor();
    if (cursor == null || cursor.getCount() == 0)
        return emptyResult();

    try {/*from   w w  w  .java  2s . c  o  m*/
        Set<String> favorites = mFavorites.getFavorites();
        Calendar calendar = Wotd.getTodayUTC();
        Calendar calendarDisplay = Wotd.getTodayUTC();
        calendarDisplay.setTimeZone(TimeZone.getDefault());
        Settings.Layout layout = Settings.getLayout(mPrefs);
        for (int i = 0; i < 100; i++) {
            Random random = new Random();
            random.setSeed(calendar.getTimeInMillis());
            String date = DateUtils.formatDateTime(getContext(), calendarDisplay.getTimeInMillis(),
                    DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
            int position = random.nextInt(cursor.getCount());
            if (cursor.moveToPosition(position)) {
                String word = cursor.getString(0);
                @ColorRes
                int color = (i % 2 == 0) ? R.color.row_background_color_even : R.color.row_background_color_odd;
                data.add(new WotdEntry(word, date, ContextCompat.getColor(getContext(), color),
                        favorites.contains(word), layout == Settings.Layout.EFFICIENT));
            }
            calendar.add(Calendar.DAY_OF_YEAR, -1);
            calendarDisplay.add(Calendar.DAY_OF_YEAR, -1);

        }

    } finally {
        cursor.close();
    }
    return new ResultListData<>(getContext().getString(R.string.wotd_list_header), false, data);
}

From source file:org.dronix.android.unisannio.fragment.AvvisiIngFragment.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_ingengeria));

    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. ja va 2  s .  c  om
        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: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/* w  w  w  .  ja va2s . 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  www . j  av a2 s.  c  o m
            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.dgsd.android.ShiftTracker.Adapter.WeekAdapter.java

@Override
protected void bindHeaderView(View view, Context context, Cursor cursor) {
    HeaderViewHolder holder = (HeaderViewHolder) view.getTag();

    final int jd = cursor.getInt(cursor.getColumnIndex(DbField.JULIAN_DAY.name));
    String title = mJdToTitleArray.get(jd, null);
    if (TextUtils.isEmpty(title)) {

        mTime.setJulianDay(jd);//w  ww . j  av  a 2s  .c  o m
        title = DateUtils.formatDateTime(getContext(), mTime.toMillis(true), DateUtils.FORMAT_SHOW_DATE
                | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_NO_YEAR);

        mJdToTitleArray.put(jd, title);
    }

    //Highlight the current day with a bold title
    if (jd == mCurrentJulianDay)
        holder.title.setTypeface(null, Typeface.BOLD);
    else
        holder.title.setTypeface(null, Typeface.NORMAL);

    holder.title.setText(title);
}

From source file:edu.mit.mobile.android.locast.ver2.events.EventDetail.java

private void loadFromCursor(Cursor c) {
    if (c.moveToFirst()) {
        ((TextView) findViewById(R.id.title)).setText(c.getString(c.getColumnIndex(Event._TITLE)));
        ((TextView) findViewById(R.id.description)).setText(c.getString(c.getColumnIndex(Event._DESCRIPTION)));
        ((TextView) findViewById(R.id.author)).setText(c.getString(c.getColumnIndex(Event._AUTHOR)));
        final long start = c.getLong(c.getColumnIndex(Event._START_DATE)),
                end = c.getLong(c.getColumnIndex(Event._END_DATE));

        ((TextView) findViewById(R.id.author)).setText(DateUtils.formatDateRange(this, start, end,
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR
                        | DateUtils.FORMAT_SHOW_WEEKDAY));

        setPointerFromCursor(c);/* w ww  .j a va2s .  c  o  m*/

        mEventOverlay.swapCursor(c);
    } else {
        Toast.makeText(this, R.string.error_loading_event, Toast.LENGTH_LONG).show();
        Log.e(TAG, "cursor has no content");
        finish();
    }
}

From source file:com.tum.atse.Utils.java

/**
 * Returns a user-friendly localized date.
 *
 * @param context/*from  w w  w. j  a va 2s. c  om*/
 * @param dateTime
 * @return
 */
public static String getFormattedDate(Context context, DateTime dateTime) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(dateTime.getValue());
    return DateUtils.formatDateTime(context, cal.getTimeInMillis(),
            DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH);
}

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;//  w w w.ja v a  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.adam.aslfms.util.Util.java

/**
 * Converts time from a long to a string in a format set by the user in the
 * phone's settings./*from   w w  w.j  ava2  s. co  m*/
 *
 * @param ctx  context to get access to the conversion methods
 * @param secs time since 1970, UTC, in seconds
 * @return the time since 1970, UTC, as a string (e.g. 2009-10-23 12:25)
 */
public static String timeFromUTCSecs(Context ctx, long secs) {
    return DateUtils.formatDateTime(ctx, secs * 1000,
            DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE);
}