List of usage examples for java.util ArrayList toString
public String toString()
From source file:com.bearstech.android.myownsync.client.NetworkUtilities.java
/** * Fetches the list of friend data updates from the server * //from w w w . j av a2 s .com * @param account The account being synced. * @param authtoken The authtoken stored in AccountManager for this account * @param lastUpdated The last time that sync was performed * @return list The list of updates received from the server. */ public static List<User> fetchFriendUpdates(Account account, String authtoken, Date lastUpdated) throws JSONException, ParseException, IOException, AuthenticationException { final ArrayList<User> friendList = new ArrayList<User>(); final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(PARAM_USERNAME, account.name)); params.add(new BasicNameValuePair(PARAM_PASSWORD, authtoken)); if (lastUpdated != null) { final SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); params.add(new BasicNameValuePair(PARAM_UPDATED, formatter.format(lastUpdated))); } Log.i(TAG, params.toString()); HttpEntity entity = null; entity = new UrlEncodedFormEntity(params); final HttpPost post = new HttpPost(base_url + FETCH_FRIEND_UPDATES_URI); post.addHeader(entity.getContentType()); post.setEntity(entity); maybeCreateHttpClient(); final HttpResponse resp = mHttpClient.execute(post); final String response = EntityUtils.toString(resp.getEntity()); if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { // Succesfully connected to the samplesyncadapter server and // authenticated. // Extract friends data in json format. final JSONArray friends = new JSONArray(response); Log.d(TAG, response); for (int i = 0; i < friends.length(); i++) { friendList.add(User.valueOf(friends.getJSONObject(i))); } } else { if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { Log.e(TAG, "Authentication exception in fetching remote contacts"); throw new AuthenticationException(); } else { Log.e(TAG, "Server error in fetching remote contacts: " + resp.getStatusLine()); throw new IOException(); } } return friendList; }
From source file:com.data.pack.Util.java
public static void clearCacheVideos(Context context, ArrayList<String> list) { try {/* w ww. j a v a 2s. co m*/ ArrayList<String> finalFilelist = new ArrayList<String>(); String deletedFile = ""; for (int i = 0; i < list.size(); ++i) { finalFilelist.add(list.get(i)); } String cacheFiles = finalFilelist.toString(); File cacheDir = context.getCacheDir(); File[] files = cacheDir.listFiles(); if (files != null) { for (File file : files) { String fname = file.getName(); if (!fname.equalsIgnoreCase("completed_exercise_de.mp4") && !fname.equalsIgnoreCase("completed_exercise.mp4") && !fname.equalsIgnoreCase("next_exercise_de.mp4") && !fname.equalsIgnoreCase("next_exercise.mp4") && !fname.equalsIgnoreCase("otherside_exercise_de.mp4") && !fname.equalsIgnoreCase("otherside_exercise.mp4") && !fname.equalsIgnoreCase("recovery_15_de.mp4") && !fname.equalsIgnoreCase("recovery_15.mp4") && !fname.equalsIgnoreCase("recovery_30_de.mp4") && !fname.equalsIgnoreCase("recovery_30.mp4") && !fname.equalsIgnoreCase("stop_exercise_de.mp4") && !fname.equalsIgnoreCase("stop_exercise.mp4") && fname.contains(".mp4") ) if (file.exists()) { deletedFile = fname; if (!cacheFiles.contains(deletedFile) && deletedFile.contains(".mp4")) { file.delete(); } } } } } catch (Exception e) { // TODO: handle exception String st = e.toString(); st = st + ""; } }
From source file:com.senechaux.rutino.utils.NetworkUtilities.java
/** * Fetches the list of entities from the server * /*from w w w . j av a 2 s.com*/ * @param account * The account being synced. * @param authtoken * The authtoken stored in AccountManager for this account * @param lastUpdated * The last time that sync was performed * @return list The list of updates received from the server. */ public static List<BaseEntity> fetchEntityUpdates(Context ctxt, Account account, String authtoken, Date lastUpdated, String url, Class<?> myClass) throws JSONException, ParseException, IOException, AuthenticationException { final ArrayList<BaseEntity> entityList = new ArrayList<BaseEntity>(); final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); // params.add(new BasicNameValuePair(PARAM_USERNAME, account.name)); // params.add(new BasicNameValuePair(PARAM_PASSWORD, authtoken)); // if (lastUpdated != null) { // final SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm"); // formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // params.add(new BasicNameValuePair(PARAM_UPDATED, formatter.format(lastUpdated))); // } Log.i(TAG, params.toString()); Log.v(TAG, "authtoken: " + authtoken); HttpEntity entity = null; entity = new UrlEncodedFormEntity(params); url = url + "?user_id=" + authtoken; Log.v(TAG, "url: " + url); final HttpGet get = new HttpGet(url); get.addHeader(entity.getContentType()); maybeCreateHttpClient(); final HttpResponse resp = mHttpClient.execute(get); final String response = EntityUtils.toString(resp.getEntity()); if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { // Succesfully connected to the samplesyncadapter server and // authenticated. // Extract wallets data in json format. final JSONArray entities = new JSONArray(response); Log.d(TAG, response); for (int i = 0; i < entities.length(); i++) { if (myClass == Wallet.class) { entityList.add(Wallet.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == Report.class) { entityList.add(Report.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == AccountType.class) { entityList.add(AccountType.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == Currency.class) { entityList.add(Currency.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == AccountEntity.class) { entityList.add(AccountEntity.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == Transaction.class) { entityList.add(Transaction.valueOf(ctxt, entities.getJSONObject(i))); } else if (myClass == PeriodicTransaction.class) { entityList.add(PeriodicTransaction.valueOf(ctxt, entities.getJSONObject(i))); } } } else { if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { Log.e(TAG, "Authentication exception in fetching remote data"); throw new AuthenticationException(); } else { Log.e(TAG, "Server error in fetching remote data: " + resp.getStatusLine()); throw new IOException(); } } return entityList; }
From source file:com.felkertech.n.ActivityUtils.java
public static void openPluginPicker(final boolean newChannel, final JsonChannel queriedChannel, final Activity activity) { final PackageManager pm = activity.getPackageManager(); final Intent plugin_addchannel = new Intent(CumulusTvPlugin.ACTION_ADD_CHANNEL); final List<ResolveInfo> plugins = pm.queryIntentActivities(plugin_addchannel, 0); ArrayList<String> plugin_names = new ArrayList<String>(); for (ResolveInfo ri : plugins) { plugin_names.add(ri.loadLabel(pm).toString()); }// w w w . j a v a2 s . c o m String[] plugin_names2 = plugin_names.toArray(new String[plugin_names.size()]); if (DEBUG) { Log.d(TAG, "Load plugins " + plugin_names.toString()); } if (plugin_names.size() == 1) { Intent intent = new Intent(); if (newChannel) { if (DEBUG) { Log.d(TAG, "Try to start "); } ResolveInfo plugin_info = plugins.get(0); if (DEBUG) { Log.d(TAG, plugin_info.activityInfo.applicationInfo.packageName + " " + plugin_info.activityInfo.name); } intent.setClassName(plugin_info.activityInfo.applicationInfo.packageName, plugin_info.activityInfo.name); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_ACTION, CumulusTvPlugin.INTENT_ADD); } else { ResolveInfo plugin_info = plugins.get(0); Log.d(TAG, plugin_info.activityInfo.applicationInfo.packageName + " " + plugin_info.activityInfo.name); intent.setClassName(plugin_info.activityInfo.applicationInfo.packageName, plugin_info.activityInfo.name); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_ACTION, CumulusTvPlugin.INTENT_EDIT); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_JSON, queriedChannel.toString()); } activity.startActivity(intent); } else { new MaterialDialog.Builder(activity).items(plugin_names2).title(R.string.choose_an_app) .content(R.string.choose_default_app).itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { Intent intent = new Intent(); if (newChannel) { if (DEBUG) { Log.d(TAG, "Try to start"); } ResolveInfo plugin_info = plugins.get(i); if (DEBUG) { Log.d(TAG, plugin_info.activityInfo.applicationInfo.packageName + " " + plugin_info.activityInfo.name); } intent.setClassName(plugin_info.activityInfo.applicationInfo.packageName, plugin_info.activityInfo.name); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_ACTION, CumulusTvPlugin.INTENT_ADD); } else { ResolveInfo plugin_info = plugins.get(i); intent.setClassName(plugin_info.activityInfo.applicationInfo.packageName, plugin_info.activityInfo.name); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_ACTION, CumulusTvPlugin.INTENT_EDIT); intent.putExtra(CumulusTvPlugin.INTENT_EXTRA_JSON, queriedChannel.toString()); } activity.startActivity(intent); } }).show(); } }
From source file:cl.smartcities.isci.transportinspector.adapters.viewPagerAdapters.OutOfBusPagerAdapter.java
@Override public void callback(ArrayList<Event> response) { Log.i(TAG, response.toString()); }
From source file:ru.kaefik.isaifutdinov.an_weather_widget.utils.Utils.java
public static ArrayList<String> getLikeNameCity(String searchNameCity) { String APPID = "76d6de6e46c704733f12c8738307dbb5"; Log.i(ConfigActivity.TAG_SERVICE, " CityModel getLikeNameCity -> start "); String url = "http://api.openweathermap.org/data/2.5/find?q=" + searchNameCity + "&type=like&APPID=" + APPID;//from www . j a v a2 s .c o m ArrayList<String> result = new ArrayList<String>(); String res = Utils.getHttpRequestFromUrl(url); Gson gson = new Gson(); if (res == null) { // TODO: System.out.println(" "); } else { Log.i(ConfigActivity.TAG_SERVICE, " CityModel getLikeNameCity -> res " + res); ArrayCityModel cc = gson.fromJson(res, ArrayCityModel.class); System.out.println(cc.getCount()); for (int i = 0; i < cc.getCount(); i++) { result.add(cc.getList(i).getName()); } } Log.i(ConfigActivity.TAG_SERVICE, " CityModel getLikeNameCity -> " + result.toString()); return result; }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Updater.java
public static void updateNoGUI(Address ftpAddress, String name, String myTopic, Address address) { logger.debug("Update (with CLI) command received"); FTPIP = ftpAddress.getIPaddress();/* w w w . ja v a 2 s . c om*/ FTPPORT = ftpAddress.getPort(); jarName = name; setSeparator(); downloadJar(jarName, "upd"); //DOWNLOADED_JAR_PATH+SEPARATOR+ File fDown = new File(DOWNLOADED_JAR_PATH + SEPARATOR + jarName); File fDest = new File(jarName); try { //FileUtils.copyFile(fDown, fDest); copyFile(fDown, fDest); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } try { ArrayList<String> command = new ArrayList<String>(); command.add("java"); //command.add("-jar"); command.add("-cp"); command.add(fDest.getAbsolutePath()); command.add(DMasonWorker.class.getName()); command.add(address.getIPaddress()); command.add(address.getPort()); command.add(myTopic); command.add("update"); System.out.println(command); logger.info("Restarting with command: " + command.toString()); ProcessBuilder builder = new ProcessBuilder(command); Process process = builder.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /*Timer timer = new Timer(4000, new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); timer.start(); */ }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Updater.java
public static void updateWithGUI(Address FTPaddress, String name, String myTopic, Address address) { logger.debug("Update (with GUI) command received"); FTPIP = FTPaddress.getIPaddress();/*from w ww . ja v a2 s .com*/ FTPPORT = FTPaddress.getPort(); jarName = name; setSeparator(); downloadJar(jarName, "upd"); //DOWNLOADED_JAR_PATH+SEPARATOR+ File fDown = new File(DOWNLOADED_JAR_PATH + SEPARATOR + jarName); File fDest = new File(jarName); try { //FileUtils.copyFile(fDown, fDest); copyFile(fDown, fDest); try { ArrayList<String> command = new ArrayList<String>(); command.add("java"); //command.add("-jar"); command.add("-cp"); command.add(fDest.getAbsolutePath()); command.add(DMasonWorkerWithGui.class.getName()); command.add(address.getIPaddress()); command.add(address.getPort()); command.add(myTopic); command.add("update"); logger.info("Restarting with command: " + command.toString()); ProcessBuilder builder = new ProcessBuilder(command); Process process = builder.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /*Timer timer = new Timer(4000, new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); timer.start(); */ } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:jsentvar.FindTermsTest.java
/** * Test of found method, of class FindTerms. *//* w ww . ja va 2s.c om*/ @Test public void testFound() throws IOException { System.out.println("FindTerms.found() test"); RDFReader lector = new RDFReader(); String filename; //filename = "resources/test/miniReasoner.owl"; filename = "resources/IEEE_reasoner20022016.owl"; Model model; model = lector.reader(filename); DataMapper dm = new DataMapper(); dm.setModel(model); ArrayList<String> labels = dm.getAllLabels(); //System.out.println(labels.size()); FindTerms finder = new FindTerms(); FindTerms.vocabulary = labels; String docFile = "resources/test/findtermsdoc.txt"; String doc = FileUtils.readFileToString(new File(docFile), "utf8"); ArrayList<String> f = finder.found(doc); String expResult = f.toString(); String result = FileUtils.readFileToString(new File("resources/test/findtermsdocResult.txt"), "utf8"); assertEquals(expResult, result); }
From source file:eu.cassandra.utils.Utils.java
/** * This function is used to remove the smallest points of interest from a list * in order to make its size viable to estimate the pairs. * //from w ww . ja v a 2s .co m * @param pois * The list of points of interest. * @return The list of points of interest with a percentage of the points * removed. */ public static ArrayList<PointOfInterest> removePoints(ArrayList<PointOfInterest> pois) { ArrayList<PointOfInterest> result = new ArrayList<PointOfInterest>(); int number = pois.size() - Constants.REMOVAL_MAX_POINTS; log.debug("Initial Size: " + pois.size() + " Removing: " + number); Collections.sort(pois, Constants.comp4); log.debug("Initial POIS: " + pois.toString()); Collections.sort(result, Constants.comp4); for (int i = 0; i < number; i++) result.add(pois.remove(pois.size() - 1)); log.debug("Removed POIS: " + result.toString()); return result; }