gaizhi / apps-for-android

Automatically exported from code.google.com/p/apps-for-android
Apache License 2.0
0 stars 0 forks source link

[GlobalTime] Deprecation warnings in AndroidGlobalTime #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Compiling AndroidGlobalTime using -Xlint:unchecked with Beta 0.9 SDK
generates warnings for City.java and Clock.java

1. Here's an update for the getCitiesByOffset method, using Comparator<City>:

    public static City[] getCitiesByOffset() {
        City[] ocities = cities.values().toArray(new City[0]);
        Arrays.sort(ocities, new Comparator<City>() {
                public int compare(City c1, City c2) {
                    long now = System.currentTimeMillis();
                    TimeZone tz1 = c1.getTimeZone();
                    TimeZone tz2 = c2.getTimeZone();
                    int off1 = tz1.getOffset(now);
                    int off2 = tz2.getOffset(now);
                    if (off1 == off2) {
                        float dlat = c2.getLatitude() - c1.getLatitude();
                        if (dlat < 0.0f) return -1;
                        if (dlat > 0.0f) return 1;
                        return 0;
                    }
                    return off1 - off2;
                }
            });
        return ocities;
    }

Note the use of the following one-line idiom that replaces several lines in
the original:

        City[] ocities = cities.values().toArray(new City[0]);

This can also be used in getCitiesByName:

    public static City[] getCitiesByName() {
        City[] ocities = cities.values().toArray(new City[0]);
        Arrays.sort(ocities);
        return ocities;
    }

2. The unchecked warning in Clock.java concerns the use of
android.pim.DateUtils.timeString, which is deprecated.

However, I can neither find android.pim in the package index nor find
DateUtils in the class index(!), so I'm at a loss at how to silence this
warning.

Original issue reported on code.google.com by joe.bowb...@gmail.com on 28 Aug 2008 at 10:09

GoogleCodeExporter commented 9 years ago
Hi joe!  Instead of posting the method, can you run the command 'svn diff -u' 
on your
local modified copy of the repository, and attach that instead?  That will be 
easier
to merge.

Original comment by morri...@gmail.com on 3 Sep 2008 at 3:11

GoogleCodeExporter commented 9 years ago
Diff attached.

Original comment by joe.bowb...@gmail.com on 8 Sep 2008 at 5:15

Attachments:

GoogleCodeExporter commented 9 years ago
Update: Clock.java won't compile in 1.0 SDK because android.pim package (former 
home
of DateUtils) is no longer included.

Original comment by joe.bowb...@gmail.com on 23 Sep 2008 at 7:23

GoogleCodeExporter commented 9 years ago

Original comment by morri...@gmail.com on 13 Nov 2008 at 10:11

GoogleCodeExporter commented 9 years ago

Original comment by morri...@gmail.com on 13 Nov 2008 at 10:17

GoogleCodeExporter commented 9 years ago
LGTM, patch submitted as r140.  Thanks, joe.bowbeer!

The Clock.java issue is recorded elsewhere, so I am resolving this issue.

Original comment by morri...@gmail.com on 13 Nov 2008 at 4:04