use of android.text.format.Time in project datetimepicker by flavienlaurent.
the class SimpleMonthView method setMonthParams.
public void setMonthParams(HashMap<String, Integer> params) {
if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
throw new InvalidParameterException("You must specify month and year for this view");
}
setTag(params);
if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
if (mRowHeight < MIN_HEIGHT) {
mRowHeight = MIN_HEIGHT;
}
}
if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
}
mMonth = params.get(VIEW_PARAMS_MONTH);
mYear = params.get(VIEW_PARAMS_YEAR);
final Time today = new Time(Time.getCurrentTimezone());
today.setToNow();
mHasToday = false;
mToday = -1;
mCalendar.set(Calendar.MONTH, mMonth);
mCalendar.set(Calendar.YEAR, mYear);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
} else {
mWeekStart = mCalendar.getFirstDayOfWeek();
}
mNumCells = Utils.getDaysInMonth(mMonth, mYear);
for (int i = 0; i < mNumCells; i++) {
final int day = i + 1;
if (sameDay(day, today)) {
mHasToday = true;
mToday = day;
}
}
mNumRows = calculateNumRows();
}
use of android.text.format.Time in project datetimepicker by flavienlaurent.
the class RadialPickerLayout method dispatchPopulateAccessibilityEvent.
/**
* Announce the currently-selected time when launched.
*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current time will be spoken.
event.getText().clear();
Time time = new Time();
time.hour = getHours();
time.minute = getMinutes();
long millis = time.normalize(true);
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24HourMode) {
flags |= DateUtils.FORMAT_24HOUR;
}
String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
event.getText().add(timeString);
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}
use of android.text.format.Time in project XobotOS by xamarin.
the class DateTimeView method setTime.
@android.view.RemotableViewMethod
public void setTime(long time) {
Time t = new Time();
t.set(time);
t.second = 0;
mTimeMillis = t.toMillis(false);
mTime = new Date(t.year - 1900, t.month, t.monthDay, t.hour, t.minute, 0);
update();
}
use of android.text.format.Time in project platform_frameworks_base by android.
the class AnalogClock method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!mAttached) {
mAttached = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
// OK, this is gross but needed. This class is supported by the
// remote views machanism and as a part of that the remote views
// can be inflated by a context for another user without the app
// having interact users permission - just for loading resources.
// For exmaple, when adding widgets from a user profile to the
// home screen. Therefore, we register the receiver as the current
// user not the one the context is for.
getContext().registerReceiverAsUser(mIntentReceiver, android.os.Process.myUserHandle(), filter, null, getHandler());
}
// NOTE: It's safe to do these after registering the receiver since the receiver always runs
// in the main thread, therefore the receiver can't run before this method returns.
// The time zone may have changed while the receiver wasn't registered, so update the Time
mCalendar = new Time();
// Make sure we update to the current time
onTimeChanged();
}
use of android.text.format.Time in project platform_frameworks_base by android.
the class SurfaceTextureRenderer method dumpGlTiming.
/**
* Save a measurement dump to disk, in
* {@code /sdcard/CameraLegacy/durations_<time>_<width1>x<height1>_...txt}
*/
private void dumpGlTiming() {
if (mPerfMeasurer == null)
return;
File legacyStorageDir = new File(Environment.getExternalStorageDirectory(), "CameraLegacy");
if (!legacyStorageDir.exists()) {
if (!legacyStorageDir.mkdirs()) {
Log.e(TAG, "Failed to create directory for data dump");
return;
}
}
StringBuilder path = new StringBuilder(legacyStorageDir.getPath());
path.append(File.separator);
path.append("durations_");
Time now = new Time();
now.setToNow();
path.append(now.format2445());
path.append("_S");
for (EGLSurfaceHolder surface : mSurfaces) {
path.append(String.format("_%d_%d", surface.width, surface.height));
}
path.append("_C");
for (EGLSurfaceHolder surface : mConversionSurfaces) {
path.append(String.format("_%d_%d", surface.width, surface.height));
}
path.append(".txt");
mPerfMeasurer.dumpPerformanceData(path.toString());
}
Aggregations