List of usage examples for android.text.format Time format2445
public String format2445()
From source file:com.osfans.trime.DictionaryHelper.java
static String getExportName() { Time t = new Time(); t.setToNow();/*from ww w . j ava 2 s. c o m*/ return String.format("trime_%s.db", t.format2445()); }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
/** * Constructs a search routes data URI.//from w ww .ja va 2s. c om * @param startPoint the start point * @param endPoint the end point * @param time the time, pass null for now * @param isTimeDeparture true if the time is departure time, false if arrival * @return the data uri */ public static Uri createRoutesUri(Site startPoint, Site endPoint, Time time, boolean isTimeDeparture) { Uri routesUri; String timeString = ""; String startLat = ""; String startLng = ""; String endLat = ""; String endLng = ""; if (time != null) { timeString = time.format2445(); } if (startPoint.getLocation() != null) { startLat = String.valueOf(startPoint.getLocation().getLatitude()); startLng = String.valueOf(startPoint.getLocation().getLongitude()); } if (endPoint.getLocation() != null) { endLat = String.valueOf(endPoint.getLocation().getLatitude()); endLng = String.valueOf(endPoint.getLocation().getLongitude()); } routesUri = Uri.parse(String.format( "journeyplanner://routes?" + "start_point=%s" + "&start_point_id=%s" + "&start_point_lat=%s" + "&start_point_lng=%s" + "&end_point=%s" + "&end_point_id=%s" + "&end_point_lat=%s" + "&end_point_lng=%s" + "&time=%s" + "&isTimeDeparture=%s", Uri.encode(startPoint.getName()), startPoint.getId(), startLat, startLng, Uri.encode(endPoint.getName()), endPoint.getId(), endLat, endLng, timeString, isTimeDeparture)); return routesUri; }
From source file:mtmo.test.mediadrm.MainActivity.java
private void setupDrmProcessButton(final int appMode) { final Button btnRegistration = (Button) findViewById(R.id.btn_registration); final Button btnSaveLicense = (Button) findViewById(R.id.btn_license); final Button btnDeregistration = (Button) findViewById(R.id.btn_deregistration); final Button btnCheckRights = (Button) findViewById(R.id.btn_check_rights); final Button btnRemoveRights = (Button) findViewById(R.id.btn_remove_rights); final Button btnStatus = (Button) findViewById(R.id.btn_check_regist); if (btnRegistration != null) { btnRegistration.setOnClickListener(new OnClickListener() { @Override/*from ww w . ja va2s .co m*/ public void onClick(View v) { mLogger.enter("requeseted registration..."); final TaskInfo taskInfo = new TaskInfo(TaskType.REGISTRATION, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnSaveLicense != null) { btnSaveLicense.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted getting License..."); final TaskInfo taskInfo = new TaskInfo(TaskType.LICENSE, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnDeregistration != null) { btnDeregistration.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted deregistration..."); final TaskInfo taskInfo = new TaskInfo(TaskType.DEREGISTRATION, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnCheckRights != null) { btnCheckRights.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted check License..."); TextView log = (TextView) findViewById(R.id.log); byte[] sessionId = null; MediaDrm mediaDrm = null; byte[] contentData = null; log.setText(""); try { mediaDrm = new MediaDrm(Constants.MBB_UUID); sessionId = mediaDrm.openSession(); switch (appMode) { case Constants.APP_MODE_ABS: ABSContentInfo absContentInfo = getABSContentInfo(); contentData = Utils.readPsshDataFromFile(true); mediaDrm.restoreKeys(sessionId, InitData.getPSSHTableForAndroid(contentData, absContentInfo.getVideoKid())); break; case Constants.APP_MODE_OFFLINE: contentData = Utils.readIPMPDataFromFile(true); mediaDrm.restoreKeys(sessionId, InitData.getIPMPTableForAndroid(contentData)); break; default: Toast.makeText(mContext, "Unknown App Mode", Toast.LENGTH_SHORT).show(); return; } HashMap<String, String> infoMap = mediaDrm.queryKeyStatus(sessionId); if (infoMap != null && infoMap.size() > 0) { StringBuilder sb = new StringBuilder(); Iterator<String> iterator = infoMap.keySet().iterator(); log.setText(""); Time time = new Time(); while (iterator.hasNext()) { String name = iterator.next(); time.set(Long.valueOf(infoMap.get(name))); mLogger.d("\t" + name + " = " + infoMap.get(name) + " [" + time.format2445() + "]"); sb.append( "\n\t" + name + " = " + infoMap.get(name) + " [" + time.format2445() + "]"); } log.append(sb); } mediaDrm.closeSession(sessionId); sessionId = null; Toast.makeText(MainActivity.this, "queryKeyStatus finished", Toast.LENGTH_LONG).show(); return; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (UnsupportedSchemeException e) { e.printStackTrace(); } catch (NotProvisionedException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } mediaDrm.closeSession(sessionId); sessionId = null; Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } }); } if (btnRemoveRights != null) { btnRemoveRights.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted removing License..."); Toast.makeText(MainActivity.this, "Not implementation", Toast.LENGTH_LONG).show(); } }); } if (btnStatus != null) { btnStatus.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.enter("Check registration Status..."); RequestParser parser = null; MediaDrm mediaDrm = null; byte[] sessionid = null; HashMap<String, String> optionalParameters = null; try { mediaDrm = new MediaDrm(Constants.MBB_UUID); sessionid = mediaDrm.openSession(); KeyRequest keyRequest = mediaDrm.getKeyRequest(sessionid, InitData.getPropertyTableForAndroid(Constants.QUERY_NAME_REGISTERED_STATE, Utils.accountIdToMarlinFormat(mAccountId), mServiceId), Constants.REQUEST_MIMETYPE_QUERY_PROPERTY, MediaDrm.KEY_TYPE_OFFLINE, optionalParameters); parser = new RequestParser(keyRequest.getData()); if (parser.parse()) { Toast.makeText(MainActivity.this, parser.getProperty(), Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } return; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (UnsupportedSchemeException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (NotProvisionedException e) { e.printStackTrace(); } Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } }); } }
From source file:ru.otdelit.astrid.opencrx.sync.OpencrxSyncProvider.java
protected void performSync() { labelMap = new HashMap<String, String>(); lastSync = new Time(); preferences.recordSyncStart();/*from w w w . j av a 2s.c o m*/ Log.i(OpencrxUtils.TAG, "Starting sync!"); try { // load user information JSONObject user = invoker.userUpdateOpencrx(); saveUserData(user); String userCrxId = user.getString("crxid_user"); Time cur = new Time(); String lastServerSync = Preferences.getStringValue(OpencrxUtilities.PREF_SERVER_LAST_SYNC); try { if (lastServerSync != null) { lastSync.parse(lastServerSync); } else { // very long time ago lastSync.set(1, 1, 1980); } } catch (TimeFormatException ex) { lastSync.set(1, 1, 1980); } String lastNotificationId = Preferences.getStringValue(OpencrxUtilities.PREF_SERVER_LAST_NOTIFICATION); String lastActivityId = Preferences.getStringValue(OpencrxUtilities.PREF_SERVER_LAST_ACTIVITY); // read dashboards updateCreators(); // read contacts updateContacts(); // read labels updateResources(userCrxId); // read activity process graph graph = invoker.getActivityProcessGraph(); ArrayList<OpencrxTaskContainer> remoteTasks = new ArrayList<OpencrxTaskContainer>(); JSONArray tasks = invoker.tasksShowListOpencrx(graph); for (int i = 0; i < tasks.length(); i++) { JSONObject task = tasks.getJSONObject(i); OpencrxTaskContainer remote = parseRemoteTask(task); // update reminder flags for incoming remote tasks to prevent annoying if (remote.task.hasDueDate() && remote.task.getValue(Task.DUE_DATE) < DateUtilities.now()) remote.task.setFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE, false); dataService.findLocalMatch(remote); remoteTasks.add(remote); } // TODO: delete Log.i(OpencrxUtils.TAG, "Matching local to remote..."); matchLocalTasksToRemote(remoteTasks); // TODO: delete Log.i(OpencrxUtils.TAG, "Matching local to remote finished"); // TODO: delete Log.i(OpencrxUtils.TAG, "Synchronizing tasks..."); SyncData<OpencrxTaskContainer> syncData = populateSyncData(remoteTasks); try { synchronizeTasks(syncData); } finally { syncData.localCreated.close(); syncData.localUpdated.close(); } // TODO: delete Log.i(OpencrxUtils.TAG, "Synchronizing tasks finished"); cur.setToNow(); Preferences.setString(OpencrxUtilities.PREF_SERVER_LAST_SYNC, cur.format2445()); preferences.recordSuccessfulSync(); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH); ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); // store lastIds in Preferences Preferences.setString(OpencrxUtilities.PREF_SERVER_LAST_NOTIFICATION, lastNotificationId); Preferences.setString(OpencrxUtilities.PREF_SERVER_LAST_ACTIVITY, lastActivityId); labelMap = null; lastSync = null; // TODO: delete Log.i(OpencrxUtils.TAG, "Sync successfull"); } catch (IllegalStateException e) { // occurs when application was closed } catch (Exception e) { handleException("opencrx-sync", e, true); //$NON-NLS-1$ } }