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;
}
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();
}
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);
}
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;
}
}
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);
}
});
}
}
}
Aggregations