DateUtils.getRelativeTimeSpanString in v0.9

by Guillaume Perrot » Fri, 22 Aug 2008 18:18:20 GMT


Sponsored Links
 In Android SDK v0.9, the DateUtils class has been removed.
Where is the equivalent to format relative dates ? The function was
"getRelativeTimeSpanString", I hope I don't have to code it myself.
--~--~---------~--~----~------------~-------~--~----~



DateUtils.getRelativeTimeSpanString in v0.9

by Megha Joshi » Tue, 26 Aug 2008 01:50:43 GMT


 2008/8/25 Guillaume Perrot <[EMAIL PROTECTED]>



Yes...DateUtils will be public in the next release...



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Gallery setUnselectedAlpha not resuming transparency (alpha) when unselected after being selected

Hello All,
I have a gallery with the setUnselectedAlpha option enabled. The
gallery is
set to automatically progress through the gallery items, each time one
is
selected it waits 2 seconds before moving to the next. Before it is
selected, it is transparent. When selected it loses it's transparency,
and
then when it become unselected again it does not return to
transparent!

I have seen at times immediately after closing another activity using
the
back button it will work, but it is not consistent or repeatable.
Perhaps
this is a problem only with the emulator?

Below is the source code: (I have also submitted this as a bug on
Google Code, but it doesn't seem Google actually reviews the bugs in
any reasonable timeframe...)

Gallery declaration:

final HomeGalImgAdapter hgia = new HomeGalImgAdapter(ctx);
final Gallery gal = new Gallery(ctx);
gal.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
gal.setAdapter(hgia);
gal.setSpacing(0);
gal.setUnselectedAlpha(0.3f);
gal.setOnItemSelectedListener(new OnItemSelectedListener() {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long
arg3) {
gal.setSelection(arg2);
galType.setText(hgia.getRating(arg2));
galTitle.setText(hgia.getName(arg2));
galAuthor.setText(hgia.getAuthor(arg2));
hgia.pauseBeforeNext(gal);
}

public void onNothingSelected(AdapterView<?> arg0) {

    }
});

And the code for the image adapter:

public class HomeGalImgAdapter extends BaseAdapter {
        private Context myContext;

        private Integer[] myImageIds = {
                        R.drawable.test128_add_to_folder,
                        R.drawable.test128_calendar,
                        R.drawable.test128_chart_pie,
                        R.drawable.test128_clock,
                        R.drawable.test128_comments,
                        R.drawable.test128_info,
                        R.drawable.test128_mail_receive,
                        R.drawable.test128_process,
                        R.drawable.test128_rss,
                        R.drawable.test128_search,
                        R.drawable.test128_users
        };

        /** Simple Constructor saving the 'parent' context. */
        public HomeGalImgAdapter(Context c) { this.myContext = c; }

        /** Returns the amount of images we have defined. */
        public int getCount() { return this.myImageIds.length; }

        /* Use the array-Positions as unique IDs */
        public Object getItem(int position) { return position; }
        public long getItemId(int position) { return position; }

        /** Returns a new ImageView to
         * be displayed, depending on
         * the position passed. */
        public View getView(int position, View convertView, ViewGroup
parent) {
                ImageView i = new ImageView(this.myContext);

                i.setImageResource(this.myImageIds[position]);
                /* Image should be scaled as width/height are set. */
                i.setScaleType(ImageView.ScaleType.FIT_XY);
                /* Set the Width/Height of the ImageView. */
                i.setLayoutParams(new Gallery.LayoutParams(96, 96));
                return i;
        }

        private Gallery gal;
        private GregorianCalendar time1;
        public void pauseBeforeNext(Gallery _gal)
        {
                gal = _gal;

                time1 = new GregorianCalendar();
                final Handler uiThreadCallback = new Handler();
                final Runnable runInUIThread = new Runnable()
                {
                        public void run()
                        {
                                _showInUI();
                        }
                };
                uiThreadCallback.removeCallbacks(runInUIThread);
                new Thread()
                {
                        @Override
                        public void run()
                        {
                                _doInBackgroundPost();
                                uiThreadCallback.post(runInUIThread);
                        }
                }.start();

        }
        private long ElapsedMillis()
        {
                GregorianCalendar gc2 = new GregorianCalendar();
                // the above two dates are one second apart
                Date d1 = time1.getTime();
                Date d2 = gc2.getTime();
                long l1 = d1.getTime();
                long l2 = d2.getTime();
                long difference = l2 - l1;
                return difference;
        }
        private void _showInUI() {
                if (ElapsedMillis() > 2500)
                {
                        if ((gal.getSelectedItemPosition() + 1) ==
gal.getCount())
                                gal.setSelection(0);
                        else

gal.setSelection(gal.getSelectedItemPosition() + 1);
                }
        }

        private void _doInBackgroundPost()
        {
                try {
                        Thread.sleep(2500);
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }
        }
--~--~---------~--~----~------------~-------~--~----~

2. Potential medical applications

Hey everyone,

I am a primary care physician who was a software developer in my
previous career and have been busily coding away on a few apps to be
used by primary care physicians and providers in the clinical and
hospital environment.  Currently, finishing up work on an obstetrical
dating program and medical formulae calculator.

My question for you (if you are willing to share), is what other ideas
or needs have you seen in the clinic or hospital environment that an
Android smart phone could help with?  Obviously, I am not looking to
re-invent the EMR, but useful tasks like basic patient tracking,
rounding lists with "to-do" functionality, routine health care
maintenance schedules, immunization look-up or catch-up calculators,
etc.

Cheers, thanks for the help and so far it has been a blast developing
for Android.
 - Tom

--~--~---------~--~----~------------~-------~--~----~

3. Can't install an APK from the browser.

4. Vote: a device G1 for each ADC entrance

5. INSTALL_NON_MARKET_APPS

6. Other Languages?

7. Fwd: Availability and installation