public boolean logout() { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(App.getAppContext()); List<AbstractMap.SimpleEntry<String, String>> params = new ArrayList<>(); AbstractMap.SimpleEntry<String, String> username = new AbstractMap.SimpleEntry<>("username", preferences.getString("username", "")); AbstractMap.SimpleEntry<String, String> token = new AbstractMap.SimpleEntry<>("token", preferences.getString("token", "")); params.add(username); params.add(token); String response = App.HTMLPOST(App.Prefs().getString("domain", "") + "/API/logout", params); // TODO: Redo, this whole thing is flawed. if (response.equals("Logout successful")) { final SharedPreferences.Editor editor = preferences.edit(); editor.clear(); editor.commit(); return true; } return false; } catch (Exception e) { return false; } }
public boolean login(String username, String password) { // Login List<AbstractMap.SimpleEntry<String, String>> params = new ArrayList<>(); AbstractMap.SimpleEntry<String, String> entryUsername = new AbstractMap.SimpleEntry<>("username", username); AbstractMap.SimpleEntry<String, String> entryPassword = new AbstractMap.SimpleEntry<>("password", password); params.add(entryUsername); params.add(entryPassword); String response = App.HTMLPOST(App.Prefs().getString("domain", "") + "/API/login/", params); if (response == null) return false; else { // Split the string and save the username, the token, and the admin state // It doesn't matter if the user spoofs the admin login, server checks for rights every // request anyway. try { String[] data = response.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); if (data[0] != null & data[1] != null) { return this.login(username, data[0], data[1], data[2]); } else return false; } catch (Exception e) { return false; } } }
public List<WiFiApConfig> getSortedWifiApConfigsList() { App.getTraceUtils().startTrace(TAG, "getSortedWifiApConfigsList", Log.DEBUG); if (getWifiNetworkStatus().isEmpty()) { updateWifiApConfigs(); App.getTraceUtils() .partialTrace(TAG, "getSortedWifiApConfigsList", "updateWifiApConfigs", Log.DEBUG); } List<WiFiApConfig> list = null; synchronized (wifiNetworkStatusLock) { list = new ArrayList<WiFiApConfig>(getWifiNetworkStatus().values()); App.getTraceUtils() .partialTrace(TAG, "getSortedWifiApConfigsList", "new ArrayList", Log.DEBUG); try { Collections.sort(list); } catch (IllegalArgumentException e) { Timber.e("config_list", configListToDBG().toString()); Timber.e(e, "Exception during sort of WiFiAPConfigs"); } } App.getTraceUtils() .partialTrace(TAG, "getSortedWifiApConfigsList", "Collections.sort", Log.DEBUG); App.getTraceUtils().stopTrace(TAG, "getSortedWifiApConfigsList", Log.DEBUG); return list; }
public Collection<Module> shardModules(Settings settings) { List<Module> modules = Lists.newArrayList(); for (App app : moduleApps.values()) { modules.addAll(app.shardModules(settings)); } return modules; }
/** * Calculates max possible length of sms-text to send according to sms used * * @param amountOfSMS amount of SMS that is required to send the message * @return max possible length of sms-text to send */ private int getMaxSMSLengthPossible(int amountOfSMS) { if (app.getMaxSMSpossible() == 0) { return 0; } else { return app.getSmsLength() * app.getMaxSMSpossible() - calculateCharDelta(amountOfSMS); } }
/** A helper method for checking if all mandatory apps are present. */ private void checkMandatory() { String[] mandatoryApps = settings.getAsArray("apps.mandatory", null); if (mandatoryApps != null) { Set<String> missingApps = Sets.newHashSet(); for (String mandatoryApp : mandatoryApps) { boolean found = false; // do not check versions for (App app : apps.values()) { String appName = app.groupId() + ":" + app.artifactId(); if (mandatoryApp.startsWith(appName)) { found = true; } } if (!found && !missingApps.contains(mandatoryApp)) { missingApps.add(mandatoryApp); } } if (!missingApps.isEmpty()) { throw new ElasticSearchException( "Missing mandatory apps [" + Strings.collectionToDelimitedString(missingApps, ", ") + "]"); } } }
@Override protected void onStart() { log("onStart"); super.onStart(); App.get().setCurrentActivity(this); App.get().setActiveCase(getCase()); }
/** Called when the activity is first created */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = getIntent().getExtras(); this.trackId = bundle.getLong("track_id", 0); app = ((App) getApplicationContext()); // initializing with last known location, so we can calculate distance // to track points // currentLocation = app.getCurrentLocation(); serviceConnection = new AppServiceConnection(this, appServiceConnectionCallback); registerForContextMenu(this.getListView()); updateWaypointsArray(); // cursorAdapter = new WaypointsCursorAdapter(this, cursor); waypointsArrayAdapter = new WaypointsArrayAdapter(this, R.layout.waypoint_list_item, waypoints); // setListAdapter(cursorAdapter); setListAdapter(waypointsArrayAdapter); elevationUnit = app.getPreferences().getString("elevation_units", "m"); distanceUnit = app.getPreferences().getString("distance_units", "km"); sortMethod = app.getPreferences().getInt("trackpoints_sort", 0); }
private void save() throws UserCancelException { if (app.workspace().forceSaveAs()) { saveAs(); } else { doSave(app.workspace().getModelPath()); } }
public Collection<Class<? extends CloseableIndexComponent>> shardServices() { List<Class<? extends CloseableIndexComponent>> services = Lists.newArrayList(); for (App app : moduleApps.values()) { services.addAll(app.shardServices()); } return services; }
private void updateWithoutTrace(GeoElement geo) { GPoint location = geo.getSpreadsheetCoords(); if (location != null && location.x < app.getMaxSpreadsheetColumnsVisible() && location.y < app.getMaxSpreadsheetRowsVisible()) { highestUsedColumn = Math.max(highestUsedColumn, location.x); highestUsedRow = Math.max(highestUsedRow, location.y); if (location.y >= getRowCount()) { setRowCount(location.y + 1); } if (location.x >= getColumnCount()) { // table.setMyColumnCount(location.x + 1); // JViewport cH = spreadsheet.getColumnHeader(); // bugfix: double-click to load ggb file gives cH = null // if (cH != null) cH.revalidate(); } setValueAt(geo, location.y, location.x); /* * DONE ELSEWHERE // add tracing geos to the trace collection if * (!isIniting && geo.getSpreadsheetTrace()) { * app.getTraceManager().addSpreadsheetTraceGeo(geo); } */ } }
public Collection<Class<? extends Module>> shardModules() { List<Class<? extends Module>> modules = Lists.newArrayList(); for (App app : moduleApps.values()) { modules.addAll(app.shardModules()); } return modules; }
public void render(App a) { a.fill(100, 100, 255); a.rect(x, y, 70, 30); a.fill(0); a.textSize(20); a.text(name, x + 10, y + 25); }
public Settings updatedSettings() { ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder().put(this.settings); for (App app : moduleApps.values()) { builder.put(app.additionalSettings()); } return builder.build(); }
public Collection<Class<? extends LifecycleComponent>> services() { List<Class<? extends LifecycleComponent>> services = Lists.newArrayList(); for (App app : moduleApps.values()) { services.addAll(app.services()); } return services; }
// 初始化list数据函数 public void InitListDataForHistory(String url, JSONObject json, AjaxStatus status) { if (status.getCode() == AjaxStatus.NETWORK_ERROR && app.GetServiceData("user_Histories") == null) { aq.id(R.id.ProgressText).gone(); app.MyToast(aq.getContext(), getResources().getString(R.string.networknotwork)); return; } ObjectMapper mapper = new ObjectMapper(); try { if (isLastisNext == 1) { m_ReturnUserPlayHistories = mapper.readValue(json.toString(), ReturnUserPlayHistories.class); app.SaveServiceData("user_Histories", json.toString()); } else if (isLastisNext > 1) { m_ReturnUserPlayHistories = null; m_ReturnUserPlayHistories = mapper.readValue(json.toString(), ReturnUserPlayHistories.class); } // 创建数据源对象 GetVideoMovies(); } catch (JsonParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JsonMappingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void readClusterFromZk() throws Exception { List<String> processes; List<String> tasks; tasks = zkClient.getChildren(taskPath); processes = zkClient.getChildren(processPath); taskNumber = tasks.size(); for (int i = 0; i < processes.size(); i++) { ZNRecord process = zkClient.readData(processPath + "/" + processes.get(i), true); if (process != null) { int partition = Integer.parseInt(process.getSimpleField("partition")); String host = process.getSimpleField("host"); int port = Integer.parseInt(process.getSimpleField("port")); String taskId = process.getSimpleField("taskId"); ClusterNode node = new ClusterNode(partition, port, host, taskId); nodes.add(node); } } app = new App(); app.cluster = clusterName; try { ZNRecord appRecord = zkClient.readData(appPath); app.name = appRecord.getSimpleField("name"); app.uri = appRecord.getSimpleField("s4r_uri"); } catch (ZkNoNodeException e) { logger.warn(appPath + " doesn't exist"); } }
public static String a(long paramLong) { long l1 = paramLong / 3600000L; long l2 = (paramLong - 3600000L * l1) / 60000L; String str5; if (l1 == 0L) { if (l2 == 0L) l2 = 1L; String str7 = App.Z.a(2131427329, (int) l2); Object[] arrayOfObject5 = new Object[1]; arrayOfObject5[0] = Integer.valueOf((int) l2); str5 = String.format(str7, arrayOfObject5); } while (true) { return str5; if (l2 == 0L) { String str6 = App.Z.a(2131427328, (int) l1); Object[] arrayOfObject4 = new Object[1]; arrayOfObject4[0] = Integer.valueOf((int) l1); str5 = String.format(str6, arrayOfObject4); } else { String str1 = App.Z.a(2131427329, (int) l2); Object[] arrayOfObject1 = new Object[1]; arrayOfObject1[0] = Integer.valueOf((int) l2); String str2 = String.format(str1, arrayOfObject1); String str3 = App.Z.a(2131427328, (int) l1); Object[] arrayOfObject2 = new Object[1]; arrayOfObject2[0] = Integer.valueOf((int) l1); String str4 = String.format(str3, arrayOfObject2); App localApp = App.Mb; Object[] arrayOfObject3 = new Object[2]; arrayOfObject3[0] = str4; arrayOfObject3[1] = str2; str5 = localApp.getString(2131296401, arrayOfObject3); } } }
public void setBlendMode(int mode) { oldBlendMode = blendMode; blendMode = mode; GL14.glBlendEquation(GL14.GL_FUNC_ADD); if (mode < 100) { g.setDrawMode(mode); return; } try { Reflection.invokePrivateMethod(mPredraw, g); } catch (Exception e) { App.getApp().handle(e); } gl.glEnable(SGL.GL_BLEND); gl.glColorMask(true, true, true, true); if (mode == BM_ADD || mode == BM_SUBTRACT) { gl.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE); if (mode == BM_SUBTRACT) { GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT); GL14.glBlendEquation(GL14.GL_FUNC_REVERSE_SUBTRACT); } } try { Reflection.invokePrivateMethod(mPostdraw, g); } catch (Exception e) { App.getApp().handle(e); } }
/** * Helper method to get the plugin module method hooks, the module references * * @param app the app to invoke * @return an immutable map of the on-module refs of the apps */ private List<OnModuleReference> onModuleRefs(App app) { List<OnModuleReference> list = Lists.newArrayList(); for (Method method : app.getClass().getDeclaredMethods()) { if (!method.getName().equals("onModule")) { continue; } if (method.getParameterTypes().length == 0 || method.getParameterTypes().length > 1) { logger.warn( "plugin {} implementing onModule with no parameters or more than one parameter", app.name()); continue; } Class moduleClass = method.getParameterTypes()[0]; if (!Module.class.isAssignableFrom(moduleClass)) { logger.warn( "plugin {} implementing onModule by the type is not of Module type {}", app.name(), moduleClass); continue; } method.setAccessible(true); list.add(new OnModuleReference(moduleClass, method)); } return list; }
@Override protected void setUp() throws Exception { super.setUp(); App app = (App) getInstrumentation().getTargetContext().getApplicationContext(); app.setMockMode(true); app.component().inject(this); }
@Test public void testGetNotify() throws Exception { Notify notify1 = APP.getNotify("/notify/test"); Notify notify2 = APP.getNotify("/notify/test/tmp"); Notify notify3 = APP.getNotify(new String("/notify/test/tmp")); assertNotEquals(notify1, notify2); assertEquals(notify3, notify2); }
/** * Rigorous Test :-) * * @throws IOException */ @Test public void testInstanceProp() throws IOException { App app = App.instance(); Notify notify = app.getNotify("/notify/test"); notify.replaceProperty("a".getBytes(), "I Love it.".getBytes()); byte[] v = notify.getProperty("a".getBytes()); System.out.println(new String(v)); }
@Test public void testContainsSubFolder() { Assert.assertTrue(App.containsSubFolder(new File("/tmp"))); Assert.assertFalse(App.containsSubFolder(new File("/etc/sysconfig/network-scripts"))); Assert.assertFalse( App.containsSubFolder(new File("/etc/sysconfig/network-scripts/ifcfg-dummy0"))); Assert.assertFalse( App.containsSubFolder(new File("/etc/sysconfig/network-scripts/ifcfg-dummy0"))); }
protected static App getAppFromMenuItem(MenuItem item, final App[] availableApps) { final int id = item.getItemId(); for (App app : availableApps) { if (app.getId() == id) { return app; } } return null; }
@Test public void setTestAndRetrieveValue() { final App app = new App(); final String val = "foo"; app.setTest(val); assertThat(app.getTest(), equalTo(val)); }
@Test(expected = NullPointerException.class) public void testClose() throws Exception { App app = new App(URL, 10000); app.notifyMap = null; try { app.getNotify("/notify/test"); } finally { app.close(); } }
/** Fragment Class implementation. */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String[] names = { "Tom", "Debra", "Connor", "Barbara", "Angela", "Aaron", "Sophie", "Megan", "Catalina", "Robin", "Mia", "Blue", "Katrina", "Adam", "Paul" }; String[] state = { "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY", "NY" }; String[] country = { "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA" }; if (mlist == null) { mlist = new ArrayList<App>(); for (int i = 0; i < 13; i++) { App item = new App(); item.Names = names[i]; item.States = state[i]; item.Countries = country[i]; mlist.add(item); } } GridView gridView = new GridView(getActivity()); Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { gridView.setNumColumns(5); } else { gridView.setNumColumns(3); } gridView.setAdapter( new AppListAdapter(getActivity(), R.layout.wallets_kids_fragment_community_filter, mlist)); return gridView; }
@Override protected void render(Block html) { if (app.getJob() == null) { html. h2($(TITLE)); return; } TaskType type = null; String symbol = $(TASK_TYPE); if (!symbol.isEmpty()) { type = MRApps.taskType(symbol); } TBODY<TABLE<Hamlet>> tbody = html. table("#tasks"). thead(). tr(). th("Task"). th("Progress"). th("State"). th("Start Time"). th("Finish Time"). th("Elapsed Time")._()._(). tbody(); StringBuilder tasksTableData = new StringBuilder("[\n"); for (Task task : app.getJob().getTasks().values()) { if (type != null && task.getType() != type) { continue; } TaskInfo info = new TaskInfo(task); String tid = info.getId(); String pct = percent(info.getProgress() / 100); tasksTableData.append("[\"<a href='").append(url("task", tid)) .append("'>").append(tid).append("</a>\",\"") //Progress bar .append("<br title='").append(pct) .append("'> <div class='").append(C_PROGRESSBAR).append("' title='") .append(join(pct, '%')).append("'> ").append("<div class='") .append(C_PROGRESSBAR_VALUE).append("' style='") .append(join("width:", pct, '%')).append("'> </div> </div>\",\"") .append(info.getState()).append("\",\"") .append(info.getStartTime()).append("\",\"") .append(info.getFinishTime()).append("\",\"") .append(info.getElapsedTime()).append("\"],\n"); } //Remove the last comma and close off the array of arrays if(tasksTableData.charAt(tasksTableData.length() - 2) == ',') { tasksTableData.delete(tasksTableData.length()-2, tasksTableData.length()-1); } tasksTableData.append("]"); html.script().$type("text/javascript"). _("var tasksTableData=" + tasksTableData)._(); tbody._()._(); }
/** Limits the length of the SMS textarea to an appropriate value */ private void messageKeyReleased(KeyEvent evt) { int length = message.getText().length(); if (length > getMaxSMSLengthPossible(app.getMaxSMSpossible())) { message.setText( message.getText().substring(0, getMaxSMSLengthPossible(app.getMaxSMSpossible()))); message.setSelection(getMaxSMSLengthPossible(app.getMaxSMSpossible())); length = getMaxSMSLengthPossible(app.getMaxSMSpossible()); } smsCount.setText(new Integer(calculateSMSCount(length)).toString()); numberCharsLeft.setText( new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible()) - length).toString()); }