Search in sources :

Example 61 with Time

use of android.text.format.Time in project Etar-Calendar by Etar-Group.

the class Utils method getDisplayedTimezone.

/**
     * Returns the timezone to display in the event info, if the local timezone is different
     * from the event timezone.  Otherwise returns null.
     */
public static String getDisplayedTimezone(long startMillis, String localTimezone, String eventTimezone) {
    String tzDisplay = null;
    if (!TextUtils.equals(localTimezone, eventTimezone)) {
        // Figure out if this is in DST
        TimeZone tz = TimeZone.getTimeZone(localTimezone);
        if (tz == null || tz.getID().equals("GMT")) {
            tzDisplay = localTimezone;
        } else {
            Time startTime = new Time(localTimezone);
            startTime.set(startMillis);
            tzDisplay = tz.getDisplayName(startTime.isDst != 0, TimeZone.SHORT);
        }
    }
    return tzDisplay;
}
Also used : TimeZone(java.util.TimeZone) Time(android.text.format.Time) SpannableString(android.text.SpannableString)

Example 62 with Time

use of android.text.format.Time in project Etar-Calendar by Etar-Group.

the class Utils method getWeekNumberFromTime.

/**
     * Given a context and a time in millis since unix epoch figures out the
     * correct week of the year for that time.
     *
     * @param millisSinceEpoch
     * @return
     */
public static int getWeekNumberFromTime(long millisSinceEpoch, Context context) {
    Time weekTime = new Time(getTimeZone(context, null));
    weekTime.set(millisSinceEpoch);
    weekTime.normalize(true);
    int firstDayOfWeek = getFirstDayOfWeek(context);
    // week
    if (weekTime.weekDay == Time.SUNDAY && (firstDayOfWeek == Time.SUNDAY || firstDayOfWeek == Time.SATURDAY)) {
        weekTime.monthDay++;
        weekTime.normalize(true);
    } else if (weekTime.weekDay == Time.SATURDAY && firstDayOfWeek == Time.SATURDAY) {
        weekTime.monthDay += 2;
        weekTime.normalize(true);
    }
    return weekTime.getWeekNumber();
}
Also used : Time(android.text.format.Time)

Example 63 with Time

use of android.text.format.Time in project Etar-Calendar by Etar-Group.

the class OtherPreferences method formatTime.

/**
     * @param hourOfDay the hour of the day (0-24)
     * @param minute
     * @return human-readable string formatted based on 24-hour mode.
     */
private String formatTime(int hourOfDay, int minute) {
    Time time = new Time();
    time.hour = hourOfDay;
    time.minute = minute;
    String format = mIs24HourMode ? format24Hour : format12Hour;
    return time.format(format);
}
Also used : Time(android.text.format.Time)

Example 64 with Time

use of android.text.format.Time in project Etar-Calendar by Etar-Group.

the class SearchActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Time t = null;
    final int itemId = item.getItemId();
    if (itemId == R.id.action_today) {
        t = new Time();
        t.setToNow();
        mController.sendEvent(this, EventType.GO_TO, t, null, -1, ViewType.CURRENT);
        return true;
    } else if (itemId == R.id.action_search) {
        return false;
    } else if (itemId == R.id.action_settings) {
        mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
        return true;
    } else if (itemId == android.R.id.home) {
        Utils.returnToCalendarHome(this);
        return true;
    } else {
        return false;
    }
}
Also used : Time(android.text.format.Time)

Example 65 with Time

use of android.text.format.Time in project Etar-Calendar by Etar-Group.

the class AgendaFragment method onScroll.

// Gets the time of the first visible view. If it is a new time, send a message to update
// the time on the ActionBar
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    int julianDay = mAgendaListView.getJulianDayFromPosition(firstVisibleItem - mAgendaListView.getHeaderViewsCount());
    // On error - leave the old view
    if (julianDay == 0) {
        return;
    }
    // If the day changed, update the ActionBar
    if (mJulianDayOnTop != julianDay) {
        mJulianDayOnTop = julianDay;
        Time t = new Time(mTimeZone);
        t.setJulianDay(mJulianDayOnTop);
        mController.setTime(t.toMillis(true));
        // so instead post a runnable that will run when the layout is done
        if (!mIsTabletConfig) {
            view.post(new Runnable() {

                @Override
                public void run() {
                    Time t = new Time(mTimeZone);
                    t.setJulianDay(mJulianDayOnTop);
                    mController.sendEvent(this, EventType.UPDATE_TITLE, t, t, null, -1, ViewType.CURRENT, 0, null, null);
                }
            });
        }
    }
}
Also used : Time(android.text.format.Time)

Aggregations

Time (android.text.format.Time)395 SmallTest (android.test.suitebuilder.annotation.SmallTest)97 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)23 Date (java.util.Date)21 NetworkPolicy (android.net.NetworkPolicy)16 TrustedTime (android.util.TrustedTime)16 TextView (android.widget.TextView)15 Bundle (android.os.Bundle)13 TimeFormatException (android.util.TimeFormatException)13 Suppress (android.test.suitebuilder.annotation.Suppress)12 View (android.view.View)12 Paint (android.graphics.Paint)11 IOException (java.io.IOException)11 Matcher (java.util.regex.Matcher)9 IntentFilter (android.content.IntentFilter)7 File (java.io.File)7 DateFormat (java.text.DateFormat)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ContentValues (android.content.ContentValues)6