List of usage examples for android.text.format Time Time
public Time()
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
private String validateTime() { Long startMillis = (Long) mStartTime.getTag(); Long endMillis = (Long) mEndTime.getTag(); Integer startDay = (Integer) mStartDate.getTag(); Integer endDay = (Integer) mEndDate.getTag(); if (startMillis == null) { String error = "Please select a start time"; mStartTime.setError(error);//from www.ja v a2 s. com return error; } if (endMillis == null) { String error = "Please select an end time"; mEndTime.setError(error); return error; } if (startDay == null) { String error = "Please select a start day"; mStartDate.setError(error); return error; } if (endDay == null) { String error = "Please select an end day"; mEndDate.setError(error); return error; } if (endDay < startDay) { String error = "End date must be after start date"; mEndDate.setError(error); return error; } Time start = new Time(); Time end = new Time(); start.set(startMillis); end.set(endMillis); if (startDay.equals(endDay) && (start.hour > end.hour || (start.hour == end.hour && start.minute > end.minute))) { String error = "End time is before start time"; mEndTime.setError(error); return error; } return null; }
From source file:com.android.calendar.AllInOneActivity.java
public void setupFloatingActionButton() { mFab.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .j a va 2 s. c o m*/ public void onClick(View v) { //Create new Event Time t = new Time(); t.set(mController.getTime()); if (t.minute > 30) { t.hour++; t.minute = 0; } else if (t.minute > 0 && t.minute < 30) { t.minute = 30; } mController.sendEventRelatedEvent(this, EventType.CREATE_EVENT, -1, t.toMillis(true), 0, 0, 0, -1); } }); }
From source file:com.android.calendar.alerts.AlertService.java
/** * Processes the query results and bucketizes the alerts. * * @param highPriorityEvents This will contain future events, and concurrent events * that started recently (less than the interval DEPRIORITIZE_GRACE_PERIOD_MS). * @param mediumPriorityEvents This will contain concurrent events that started * more than DEPRIORITIZE_GRACE_PERIOD_MS ago. * @param lowPriorityEvents Will contain events that have ended. * @return Returns the number of new alerts to fire. If this is 0, it implies * a quiet update./* ww w . ja va 2 s .c o m*/ */ static int processQuery(final Cursor alertCursor, final Context context, final long currentTime, ArrayList<NotificationInfo> highPriorityEvents, ArrayList<NotificationInfo> mediumPriorityEvents, ArrayList<NotificationInfo> lowPriorityEvents) { // Experimental reminder setting to only remind for events that have // been responded to with "yes" or "maybe". String skipRemindersPref = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_REMINDERS_RESPONDED, ""); // Skip no-response events if the "Skip Reminders" preference has the second option, // "If declined or not responded", is selected. // Note that by default, the first option will be selected, so this will be false. boolean remindRespondedOnly = skipRemindersPref .equals(context.getResources().getStringArray(R.array.preferences_skip_reminders_values)[1]); // Experimental reminder setting to silence reminders when they are // during the pre-defined quiet hours. boolean useQuietHours = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_QUIET_HOURS, false); // Note that the start time may be either before or after the end time, // depending on whether quiet hours cross through midnight. int quietHoursStartHour = OtherPreferences.QUIET_HOURS_DEFAULT_START_HOUR; int quietHoursStartMinute = OtherPreferences.QUIET_HOURS_DEFAULT_START_MINUTE; int quietHoursEndHour = OtherPreferences.QUIET_HOURS_DEFAULT_END_HOUR; int quietHoursEndMinute = OtherPreferences.QUIET_HOURS_DEFAULT_END_MINUTE; if (useQuietHours) { quietHoursStartHour = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_QUIET_HOURS_START_HOUR, OtherPreferences.QUIET_HOURS_DEFAULT_START_HOUR); quietHoursStartMinute = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_QUIET_HOURS_START_MINUTE, OtherPreferences.QUIET_HOURS_DEFAULT_START_MINUTE); quietHoursEndHour = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_QUIET_HOURS_END_HOUR, OtherPreferences.QUIET_HOURS_DEFAULT_END_HOUR); quietHoursEndMinute = Utils.getSharedPreference(context, OtherPreferences.KEY_OTHER_QUIET_HOURS_END_MINUTE, OtherPreferences.QUIET_HOURS_DEFAULT_END_MINUTE); } Time time = new Time(); ContentResolver cr = context.getContentResolver(); HashMap<Long, NotificationInfo> eventIds = new HashMap<Long, NotificationInfo>(); int numFired = 0; try { while (alertCursor.moveToNext()) { final long alertId = alertCursor.getLong(ALERT_INDEX_ID); final long eventId = alertCursor.getLong(ALERT_INDEX_EVENT_ID); final int minutes = alertCursor.getInt(ALERT_INDEX_MINUTES); final String eventName = alertCursor.getString(ALERT_INDEX_TITLE); final String description = alertCursor.getString(ALERT_INDEX_DESCRIPTION); final String location = alertCursor.getString(ALERT_INDEX_EVENT_LOCATION); final int status = alertCursor.getInt(ALERT_INDEX_SELF_ATTENDEE_STATUS); final boolean declined = status == Attendees.ATTENDEE_STATUS_DECLINED; final boolean responded = status != Attendees.ATTENDEE_STATUS_NONE && status != Attendees.ATTENDEE_STATUS_INVITED; final long beginTime = alertCursor.getLong(ALERT_INDEX_BEGIN); final long endTime = alertCursor.getLong(ALERT_INDEX_END); final Uri alertUri = ContentUris.withAppendedId(CalendarAlerts.CONTENT_URI, alertId); final long alarmTime = alertCursor.getLong(ALERT_INDEX_ALARM_TIME); boolean forceQuiet = false; if (useQuietHours) { // Quiet hours have been set. time.set(alarmTime); // Check whether the alarm will fire after the quiet hours // start time and/or before the quiet hours end time. boolean alarmAfterQuietHoursStart = (time.hour > quietHoursStartHour || (time.hour == quietHoursStartHour && time.minute >= quietHoursStartMinute)); boolean alarmBeforeQuietHoursEnd = (time.hour < quietHoursEndHour || (time.hour == quietHoursEndHour && time.minute <= quietHoursEndMinute)); // Check if quiet hours crosses through midnight, iff: // start hour is after end hour, or // start hour is equal to end hour, and start minute is // after end minute. // i.e. 22:30 - 06:45; 12:45 - 12:00 // 01:05 - 10:30; 05:00 - 05:30 boolean quietHoursCrossesMidnight = quietHoursStartHour > quietHoursEndHour || (quietHoursStartHour == quietHoursEndHour && quietHoursStartMinute > quietHoursEndMinute); if (quietHoursCrossesMidnight) { // Quiet hours crosses midnight. Alarm should be quiet // if it's after start time OR before end time. if (alarmAfterQuietHoursStart || alarmBeforeQuietHoursEnd) { forceQuiet = true; } } else { // Quiet hours doesn't cross midnight. Alarm should be // quiet if it's after start time AND before end time. if (alarmAfterQuietHoursStart && alarmBeforeQuietHoursEnd) { forceQuiet = true; } } } int state = alertCursor.getInt(ALERT_INDEX_STATE); final boolean allDay = alertCursor.getInt(ALERT_INDEX_ALL_DAY) != 0; // Use app local storage to keep track of fired alerts to fix problem of multiple // installed calendar apps potentially causing missed alarms. boolean newAlertOverride = false; if (AlertUtils.BYPASS_DB && ((currentTime - alarmTime) / MINUTE_MS < 1)) { // To avoid re-firing alerts, only fire if alarmTime is very recent. Otherwise // we can get refires for non-dismissed alerts after app installation, or if the // SharedPrefs was cleared too early. This means alerts that were timed while // the phone was off may show up silently in the notification bar. boolean alreadyFired = AlertUtils.hasAlertFiredInSharedPrefs(context, eventId, beginTime, alarmTime); if (!alreadyFired) { newAlertOverride = true; } } if (DEBUG) { StringBuilder msgBuilder = new StringBuilder(); msgBuilder.append("alertCursor result: alarmTime:").append(alarmTime).append(" alertId:") .append(alertId).append(" eventId:").append(eventId).append(" state: ").append(state) .append(" minutes:").append(minutes).append(" declined:").append(declined) .append(" responded:").append(responded).append(" beginTime:").append(beginTime) .append(" endTime:").append(endTime).append(" allDay:").append(allDay) .append(" alarmTime:").append(alarmTime).append(" forceQuiet:").append(forceQuiet); if (AlertUtils.BYPASS_DB) { msgBuilder.append(" newAlertOverride: " + newAlertOverride); } Log.d(TAG, msgBuilder.toString()); } ContentValues values = new ContentValues(); int newState = -1; boolean newAlert = false; // Uncomment for the behavior of clearing out alerts after the // events ended. b/1880369 // // if (endTime < currentTime) { // newState = CalendarAlerts.DISMISSED; // } else // Remove declined events boolean sendAlert = !declined; // Check for experimental reminder settings. if (remindRespondedOnly) { // If the experimental setting is turned on, then only send // the alert if you've responded to the event. sendAlert = sendAlert && responded; } if (sendAlert) { if (state == CalendarAlerts.STATE_SCHEDULED || newAlertOverride) { newState = CalendarAlerts.STATE_FIRED; numFired++; // If quiet hours are forcing the alarm to be silent, // keep newAlert as false so it will not make noise. if (!forceQuiet) { newAlert = true; } // Record the received time in the CalendarAlerts table. // This is useful for finding bugs that cause alarms to be // missed or delayed. values.put(CalendarAlerts.RECEIVED_TIME, currentTime); } } else { newState = CalendarAlerts.STATE_DISMISSED; } // Update row if state changed if (newState != -1) { values.put(CalendarAlerts.STATE, newState); state = newState; if (AlertUtils.BYPASS_DB) { AlertUtils.setAlertFiredInSharedPrefs(context, eventId, beginTime, alarmTime); } } if (state == CalendarAlerts.STATE_FIRED) { // Record the time posting to notification manager. // This is used for debugging missed alarms. values.put(CalendarAlerts.NOTIFY_TIME, currentTime); } // Write row to if anything changed if (values.size() > 0) cr.update(alertUri, values, null, null); if (state != CalendarAlerts.STATE_FIRED) { continue; } // TODO: Prefer accepted events in case of ties. NotificationInfo newInfo = new NotificationInfo(eventName, location, description, beginTime, endTime, eventId, allDay, newAlert); // Adjust for all day events to ensure the right bucket. Don't use the 1/4 event // duration grace period for these. long beginTimeAdjustedForAllDay = beginTime; String tz = null; if (allDay) { tz = TimeZone.getDefault().getID(); beginTimeAdjustedForAllDay = Utils.convertAlldayUtcToLocal(null, beginTime, tz); } // Handle multiple alerts for the same event ID. if (eventIds.containsKey(eventId)) { NotificationInfo oldInfo = eventIds.get(eventId); long oldBeginTimeAdjustedForAllDay = oldInfo.startMillis; if (allDay) { oldBeginTimeAdjustedForAllDay = Utils.convertAlldayUtcToLocal(null, oldInfo.startMillis, tz); } // Determine whether to replace the previous reminder with this one. // Query results are sorted so this one will always have a lower start time. long oldStartInterval = oldBeginTimeAdjustedForAllDay - currentTime; long newStartInterval = beginTimeAdjustedForAllDay - currentTime; boolean dropOld; if (newStartInterval < 0 && oldStartInterval > 0) { // Use this reminder if this event started recently dropOld = Math.abs(newStartInterval) < MIN_DEPRIORITIZE_GRACE_PERIOD_MS; } else { // ... or if this one has a closer start time. dropOld = Math.abs(newStartInterval) < Math.abs(oldStartInterval); } if (dropOld) { // This is a recurring event that has a more relevant start time, // drop other reminder in favor of this one. // // It will only be present in 1 of these buckets; just remove from // multiple buckets since this occurrence is rare enough that the // inefficiency of multiple removals shouldn't be a big deal to // justify a more complicated data structure. Expired events don't // have individual notifications so we don't need to clean that up. highPriorityEvents.remove(oldInfo); mediumPriorityEvents.remove(oldInfo); if (DEBUG) { Log.d(TAG, "Dropping alert for recurring event ID:" + oldInfo.eventId + ", startTime:" + oldInfo.startMillis + " in favor of startTime:" + newInfo.startMillis); } } else { // Skip duplicate reminders for the same event instance. continue; } } // TODO: Prioritize by "primary" calendar eventIds.put(eventId, newInfo); long highPriorityCutoff = currentTime - getGracePeriodMs(beginTime, endTime, allDay); if (beginTimeAdjustedForAllDay > highPriorityCutoff) { // High priority = future events or events that just started highPriorityEvents.add(newInfo); } else if (allDay && tz != null && DateUtils.isToday(beginTimeAdjustedForAllDay)) { // Medium priority = in progress all day events mediumPriorityEvents.add(newInfo); } else { lowPriorityEvents.add(newInfo); } } // TODO(cwren) add beginTime/startTime GlobalDismissManager.processEventIds(context, eventIds.keySet()); } finally { if (alertCursor != null) { alertCursor.close(); } } return numFired; }
From source file:de.ribeiro.android.gso.dataclasses.Pager.java
/** * Erstellt eine Stundeplan Seite des ViewPagers, inkl Header und Footer * <p/>/*from w w w. ja v a 2 s . c o m*/ * Hier wird die Wochenansicht generiert * * @param weekData * @param ctxt * @return * @author Tobias Janssen */ private View createWeekPage(WeekData weekData) { // in die Page kommen alle Elemente dieser Ansicht View page = inflater.inflate(R.layout.weeklayout, null); TableLayout tl = (TableLayout) page.findViewById(R.id.weekTimetable); LinearLayoutBordered ll = new LinearLayoutBordered(context); // Tagesberschrift erstellen: TableRow tr = new TableRow(context); for (int x = Calendar.SUNDAY; x < Calendar.SATURDAY; x++) { // einen neuen Rahmen fr das Tabellenfeld vorbereiten ll = new LinearLayoutBordered(context); ll.setBorderRight(true); ll.setBorderBottom(true); ll.setBorderTop(true); ll.setBorderSize(1); ll.setBackgroundColor(Color.WHITE); View textview = inflater.inflate(R.layout.textview, null); TextView tv = (TextView) textview.findViewById(R.id.textview); // berschriftentextgre einstellen tv.setTextSize(textSize); if (x == Calendar.SUNDAY) { tv.setText(timeslots[0]); tv.setTextColor(Color.parseColor("#3A599A")); } else { tv.setText(ResolveWeekDay(x)); } ll.addView(tv); tr.addView(ll); } tl.addView(tr); // den Stundenplan zusammensetzten // fr jeden tag List<Lesson> stunden = GetSchulstunden(); for (int y = 0; y < stunden.size(); y++) { tr = new TableRow(context); for (int x = Calendar.SUNDAY; x <= Calendar.FRIDAY; x++) { if (x == Calendar.SUNDAY) { addColumn(timeslots[y + 1], "#3A599A", tr); } else { // alle events dieses Tages durchgehen ob die zu dieser // schulstunde passen boolean lessonAdded = false; TextView lastTextView = null; for (ICalEvent ev : weekData.events) { // ist event an diesem tag? if (ev.DTSTART.get(Calendar.DAY_OF_WEEK) == x) { // ja // ist event zu dieser schulstunde? Time st = new Time(); st.set(ev.DTSTART.getTimeInMillis()); int start = GetSchulstundeOfDateTime(st); Time et = new Time(); et.set(ev.DTEND.getTimeInMillis() - 60000); int end = GetSchulstundeOfDateTime(et); // ende der schulstunde herausfinden if (((start != end) && y >= start && y <= end) || start == y || end == y) { // ja event ist in dieser stunde // ist eine Doopelbelegung fr diese Stunde? if (lessonAdded && lastTextView != null) { // ja, doppelbelegung String newText = ""; if (weekData.typeId.equalsIgnoreCase("4")) { newText = lastTextView.getText() + "\r\n" + ev.DESCRIPTION + " " + ev.SUMMARY; } else { newText = lastTextView.getText() + "\r\n" + ev.DESCRIPTION.replace(weekData.elementId, "") + " " + ev.SUMMARY + " " + ev.LOCATION; } lastTextView.setText(newText); } else { // prfen, ob dieses event eine gelschte // stunde ist if (ev.UID.equalsIgnoreCase("deleted")) { // gelschtes event lastTextView = addColumn(" --- " + " " + " --- " + " " + " --- ", "#FF0000", tr); } else { String color = "#3A599A"; if (ev.UID.equalsIgnoreCase("diff")) color = "#FF0000"; if (weekData.typeId.equalsIgnoreCase("4")) { lastTextView = addColumn(ev.DESCRIPTION + " " + ev.SUMMARY, color, tr); } else { lastTextView = addColumn(ev.DESCRIPTION.replace(weekData.elementId, "") + " " + ev.SUMMARY + " " + ev.LOCATION, color, tr); } } } lessonAdded = true; } } } if (!lessonAdded) { // ja event ist in dieser stunde addColumn("", "#3A599A", tr); } } } tl.addView(tr); } TextView syncTime = (TextView) page.findViewById(R.id.syncTime); Calendar sync = new GregorianCalendar(); sync.setTimeInMillis(weekData.syncTime); String minute = String.valueOf(sync.get(Calendar.MINUTE)); if (minute.length() == 1) minute = "0" + minute; syncTime.setText(weekData.elementId + " | Stand vom " + sync.get(Calendar.DAY_OF_MONTH) + "." + (sync.get(Calendar.MONTH) + 1) + "." + sync.get(Calendar.YEAR) + " " + sync.get(Calendar.HOUR_OF_DAY) + ":" + minute + " Uhr"); return page; }
From source file:com.nextgis.firereporter.GetFiresService.java
protected void GetScanexData(boolean bShowProgress) { //2 hours = 120 min = 7200 sec = 7200000 Time testTime = new Time(); testTime.setToNow();//from w ww .j av a 2 s. com if (msScanexLoginCookie.equals("setting")) return; if (msScanexLoginCookie.equals("not_set") || msScanexLoginCookie.length() == 0 || testTime.toMillis(true) - mSanextCookieTime.toMillis(true) > 7200000) { SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS); String sLogin = prefs.getString(SettingsActivity.KEY_PREF_SRV_SCAN_USER, "new@kosmosnimki.ru"); String sPass = prefs.getString(SettingsActivity.KEY_PREF_SRV_SCAN_PASS, "test123"); msScanexLoginCookie = "setting"; mnCurrentExec++; new ScanexHttpLogin(this, 4, getResources().getString(R.string.stChecking), mFillDataHandler, bShowProgress).execute(sLogin, sPass); return; } //5. send updates to client mnCurrentExec++; new HttpGetter(this, 3, getResources().getString(R.string.stDownLoading), mFillDataHandler, bShowProgress) .execute(SCANEX_API + "/Subscribe/Get/?CallBackName=" + USER_ID, msScanexLoginCookie); if (mmoSubscriptions.size() > 0) StoreScanexData(); }
From source file:cw.kop.autobackground.settings.WearSettingsFragment.java
private void drawDigital() { canvas = surfaceView.getHolder().lockCanvas(); if (canvas == null) { return;/*from w w w . jav a2s .c o m*/ } setPaints(); Time time = new Time(); time.setToNow(); time.set(time.toMillis(false) + timeOffset); float centerX = watchContainer.getWidth() * 0.222f; float centerY = watchContainer.getHeight() * 0.222f; if (imageBitmap != null) { canvas.drawBitmap(imageBitmap, 0, 0, bitmapPaint); } float x = xOffset + (time.hour < 10 ? hourPaint.measureText("0") : 0); float hourWidth = hourPaint.measureText("" + time.hour); float minuteWidth = minutePaint.measureText(String.format("%02d", time.minute)); canvas.drawText("" + time.hour, x - 2.0f, centerY - 2.0f, hourShadowPaint); canvas.drawText("" + time.hour, x, centerY, hourPaint); x += hourPaint.measureText("" + time.hour); canvas.drawText(timeSeparator, x - 2.0f, centerY - 2.0f, separatorShadowPaint); canvas.drawText(timeSeparator, x, centerY, separatorPaint); x += separatorWidth; canvas.drawText(String.format("%02d", time.minute), x - 2.0f, centerY - 2.0f, minuteShadowPaint); canvas.drawText(String.format("%02d", time.minute), x, centerY, minutePaint); x += minutePaint.measureText(String.format("%02d", time.minute)); canvas.drawText(timeSeparator, x - 2.0f, centerY - 2.0f, separatorShadowPaint); canvas.drawText(timeSeparator, x, centerY, separatorPaint); x += separatorWidth; canvas.drawText(String.format("%02d", time.second), x - 2.0f, centerY - 2.0f, secondShadowPaint); canvas.drawText(String.format("%02d", time.second), x, centerY, secondPaint); surfaceView.getHolder().unlockCanvasAndPost(canvas); }
From source file:info.hl.mediam.MyProfileActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case GET_IMAGE_DIALOG: mGetImageDialog = new Dialog(MyProfileActivity.this, R.style.TransparentDialogTheme); mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM); mGetImageDialog.setContentView(R.layout.dialog_get_image); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); Window window = mGetImageDialog.getWindow(); params.copyFrom(window.getAttributes()); params.width = WindowManager.LayoutParams.MATCH_PARENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(params);//from ww w . j av a 2 s .com final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(MyProfileActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("profile", true); MyProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE); mGetImageDialog.dismiss(); } }); final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(MyProfileActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("profile", true); MyProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE); mGetImageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mNewAvatarId = ""; gProfileImage = null; Utils.displayImage(mNewAvatarId, mIvProfileImage, mPbLoading, ImageLoader.LARGE, R.drawable.user_stub_large, false); mGetImageDialog.dismiss(); } }); return mGetImageDialog; case GET_BIRTHDAY_DIALOG: int intMaxYear = Calendar.getInstance().get(Calendar.YEAR); int intMaxMonth = Calendar.getInstance().get(Calendar.MONTH); int intMaxDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); mGetBirthdayDialog = new DatePickerDialogWithRange(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Time chosenDate = new Time(); chosenDate.set(dayOfMonth, monthOfYear, year); mNewBirthday = chosenDate.toMillis(true) / 1000; CharSequence stringDate = DateFormat.format(getString(R.string.hookup_date_format), chosenDate.toMillis(true)); mEtUserBirthday.setText(stringDate.toString()); } }, intMaxYear, intMaxMonth, intMaxDay); mGetBirthdayDialog.setMessage(getString(R.string.when_is_your_birthday)); return mGetBirthdayDialog; default: return null; } }
From source file:com.cloverstudio.spika.MyProfileActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case GET_IMAGE_DIALOG: mGetImageDialog = new Dialog(MyProfileActivity.this, R.style.TransparentDialogTheme); mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM); mGetImageDialog.setContentView(R.layout.dialog_get_image); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); Window window = mGetImageDialog.getWindow(); params.copyFrom(window.getAttributes()); params.width = WindowManager.LayoutParams.MATCH_PARENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(params);//from w w w . j a v a 2s. c o m final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(MyProfileActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("profile", true); MyProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE); mGetImageDialog.dismiss(); } }); final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(MyProfileActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("profile", true); MyProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE); mGetImageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mNewAvatarId = ""; gProfileImage = null; Utils.displayImage(mNewAvatarId, mIvProfileImage, mPbLoading, ImageLoader.LARGE, R.drawable.user_stub_large, false); mGetImageDialog.dismiss(); } }); return mGetImageDialog; case GET_BIRTHDAY_DIALOG: int intMaxYear = Calendar.getInstance().get(Calendar.YEAR); int intMaxMonth = Calendar.getInstance().get(Calendar.MONTH); int intMaxDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); mGetBirthdayDialog = new DatePickerDialogWithRange(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Time chosenDate = new Time(); chosenDate.set(dayOfMonth, monthOfYear, year); mNewBirthday = chosenDate.toMillis(true) / 1000; CharSequence stringDate = DateFormat.format(getString(R.string.hookup_date_format), chosenDate.toMillis(true)); mEtUserBirthday.setText(stringDate.toString()); } }, intMaxYear, intMaxMonth, intMaxDay); mGetBirthdayDialog.setMessage(getString(R.string.when_is_your_birthday)); return mGetBirthdayDialog; default: return null; } }
From source file:com.xandy.calendar.AllInOneActivity.java
private void initFragments(long timeMillis, int viewType, Bundle icicle) { if (DEBUG) {/*ww w. ja v a2s. c om*/ Log.d(TAG, "Initializing to " + timeMillis + " for view " + viewType); } // FragmentTransaction ft = getFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (mShowCalendarControls) { Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true); ft.replace(R.id.mini_month, miniMonthFrag); mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag); Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment(); ft.replace(R.id.calendar_list, selectCalendarsFrag); mController.registerEventHandler(R.id.calendar_list, (EventHandler) selectCalendarsFrag); } if (!mShowCalendarControls || viewType == ViewType.EDIT) { mMiniMonth.setVisibility(View.GONE); mCalendarsList.setVisibility(View.GONE); } EventInfo info = null; if (viewType == ViewType.EDIT) { mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW); long eventId = -1; Intent intent = getIntent(); Uri data = intent.getData(); if (data != null) { try { eventId = Long.parseLong(data.getLastPathSegment()); } catch (NumberFormatException e) { if (DEBUG) { Log.d(TAG, "Create new event"); } } } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) { eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID); } long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1); long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1); info = new EventInfo(); if (end != -1) { info.endTime = new Time(); info.endTime.set(end); } if (begin != -1) { info.startTime = new Time(); info.startTime.set(begin); } info.id = eventId; // We set the viewtype so if the user presses back when they are // done editing the controller knows we were in the Edit Event // screen. Likewise for eventId mController.setViewType(viewType); mController.setEventId(eventId); } else { mPreviousView = viewType; } setMainPane(ft, R.id.main_pane, viewType, timeMillis, true); ft.commit(); // this needs to be after setMainPane() Time t = new Time(mTimeZone); t.set(timeMillis); if (viewType == ViewType.AGENDA && icicle != null) { mController.sendEvent(this, EventType.GO_TO, t, null, icicle.getLong(BUNDLE_KEY_EVENT_ID, -1), viewType); } else if (viewType != ViewType.EDIT) { mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType); } }
From source file:com.android.mms.ui.MessageUtils.java
public static String formatTimeStampString(Context context, long when, boolean fullFormat) { Time then = new Time(); then.set(when);/*from ww w.jav a 2 s . c o m*/ Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | /// M: Fix ALPS00419488 to show 12:00, so mark DateUtils.FORMAT_ABBREV_ALL //DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { // Otherwise, if the message is from today, show the time. format_flags |= DateUtils.FORMAT_SHOW_TIME; } // If the caller has asked for full details, make sure to show the date // and time no matter what we've determined above (but still make showing // the year only happen if it is a different year from today). if (fullFormat) { format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); } String dateTime = sOpMessageUtilsExt.formatTimeStampString(context, when, format_flags); if (dateTime != null) { return dateTime; } return DateUtils.formatDateTime(context, when, format_flags); }