List of usage examples for java.util ArrayList removeAll
public boolean removeAll(Collection<?> c)
From source file:com.soomla.store.billing.google.GoogleIabHelper.java
/** * Fetches items details for a given list of items. * * @throws RemoteException/*from ww w . j a v a2 s . c o m*/ * @throws JSONException */ private int querySkuDetails(String itemType, IabInventory inv, List<String> skus) throws RemoteException, JSONException { SoomlaUtils.LogDebug(TAG, "Querying SKU details."); // a list here is a bug no matter what, there is no point in // querying duplicates, and it can only create other bugs // on top of degrading performance // however, we need a subList later for chunks, so just // make the list through a Set 'filter' Set<String> skuSet = new HashSet<String>(skus); ArrayList<String> skuList = new ArrayList<String>(skuSet); if (skuList.size() == 0) { SoomlaUtils.LogDebug(TAG, "queryPrices: nothing to do because there are no SKUs."); return IabResult.BILLING_RESPONSE_RESULT_OK; } // see: http://stackoverflow.com/a/21080893/1469004 int chunkIndex = 1; while (skuList.size() > 0) { ArrayList<String> skuSubList = new ArrayList<String>( skuList.subList(0, Math.min(SKU_QUERY_MAX_CHUNK_SIZE, skuList.size()))); skuList.removeAll(skuSubList); final int chunkResponse = querySkuDetailsChunk(itemType, inv, skuSubList); if (chunkResponse != IabResult.BILLING_RESPONSE_RESULT_OK) { // todo: TBD skip chunk or abort? // for now aborting at that point SoomlaUtils.LogDebug(TAG, String.format("querySkuDetails[chunk=%d] failed: %s", chunkIndex, IabResult.getResponseDesc(chunkResponse))); return chunkResponse; // ABORT } chunkIndex++; } return IabResult.BILLING_RESPONSE_RESULT_OK; }
From source file:edu.uga.cs.fluxbuster.clustering.ClusterGenerator.java
/** * Copies candidate flux domains into a list if its corresponding 2LD is present * in a list of recent flux domains up to a limit on the size of the list. The * candidate flux domains are copied from a map of candidate flux domains. Domains * are only considered if they appear in the all domains list. Once a candidate flux * domain is copied it's corresponding domain name is removed from the all domains list. * //from w w w .jav a 2 s. c o m * @param recentFluxDomains the list of recent flux 2LD's * @param maxCandidateDomains the limit on the total number of domains to add * @param resultBuf the list in which to store the candidate flux domains * @param seenDomains the map of candidate flux domains. * @param allDomains this list of domains to consider */ private void addRecentFluxDomains(Set<String> recentFluxDomains, int maxCandidateDomains, List<CandidateFluxDomain> resultBuf, HashMap<String, CandidateFluxDomain> seenDomains, ArrayList<String> allDomains) { ArrayList<String> removeDomains = new ArrayList<String>(); Collections.shuffle(allDomains); // this is probably not necessary for (String domainname : allDomains) { if (resultBuf.size() == maxCandidateDomains) { break; } String domainname2LD = DomainNameUtils.extractEffective2LD(domainname); if (domainname2LD != null && recentFluxDomains.contains(domainname2LD)) { resultBuf.add(seenDomains.get(domainname)); removeDomains.add(domainname); } } allDomains.removeAll(removeDomains); }
From source file:me.ccrama.redditslide.DragSort.ReorderSubreddits.java
public void doCollection() { final ArrayList<String> subs2 = UserSubscriptions.sort(UserSubscriptions.getSubscriptions(this)); subs2.remove("frontpage"); subs2.remove("all"); ArrayList<String> toRemove = new ArrayList<>(); for (String s : subs2) { if (s.contains(".") || s.contains(MULTI_REDDIT)) { toRemove.add(s);//from w ww . j a v a 2 s.c o m } } subs2.removeAll(toRemove); final CharSequence[] subsAsChar = subs2.toArray(new CharSequence[subs2.size()]); MaterialDialog.Builder builder = new MaterialDialog.Builder(ReorderSubreddits.this); builder.title(R.string.reorder_subreddits_title).items(subsAsChar) .itemsCallbackMultiChoice(null, new MaterialDialog.ListCallbackMultiChoice() { @Override public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) { ArrayList<String> selectedSubs = new ArrayList<>(); for (int i : which) { selectedSubs.add(subsAsChar[i].toString()); } StringBuilder b = new StringBuilder(); for (String s : selectedSubs) { b.append(s); b.append("+"); } String finalS = b.toString().substring(0, b.length() - 1); Log.v(LogUtil.getTag(), finalS); int pos = addSubAlphabetically(finalS); adapter.notifyDataSetChanged(); recyclerView.smoothScrollToPosition(pos); return true; } }).positiveText(R.string.btn_add).negativeText(R.string.btn_cancel).show(); }
From source file:FastArrayList.java
/** * Remove from this collection all of its elements that are contained * in the specified collection.//from ww w . j a v a 2 s . c om * * @param collection Collection containing elements to be removed * * @exception UnsupportedOperationException if this optional operation * is not supported by this list */ public boolean removeAll(Collection collection) { if (fast) { synchronized (this) { ArrayList temp = (ArrayList) list.clone(); boolean result = temp.removeAll(collection); list = temp; return (result); } } else { synchronized (list) { return (list.removeAll(collection)); } } }
From source file:de.sanandrew.mods.claysoldiers.entity.EntityClayMan.java
@Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); if (!this.worldObj.isRemote) { if (damageSource.isFireDamage() && this.dollItem != null) { ItemStack brickItem = new ItemStack(RegistryItems.dollBrick, this.dollItem.stackSize); brickItem.setTagCompound(this.dollItem.getTagCompound()); this.dollItem = brickItem; }/*from w w w .j a va 2 s.co m*/ ArrayList<ItemStack> drops = new ArrayList<>(); if (!this.nexusSpawn) { if (this.dollItem != null) { drops.add(this.dollItem.copy()); } for (SoldierUpgradeInst upg : this.p_upgrades.values()) { upg.getUpgrade().onItemDrop(this, upg, drops); } drops.removeAll(Collections.singleton(null)); for (ItemStack drop : drops) { this.entityDropItem(drop, 0.0F); } } for (SoldierUpgradeInst upg : this.p_upgrades.values()) { upg.getUpgrade().onSoldierDeath(this, upg, damageSource); } for (SoldierEffectInst eff : this.p_effects.values()) { eff.getEffect().onSoldierDeath(this, eff, damageSource); } } }
From source file:com.erudika.para.search.ElasticSearch.java
/** * Processes the results of searcQueryRaw() and fetches the results from the data store (can be disabled). * @param <P> type of object/*from ww w. j a v a2 s . c o m*/ * @param appid name of the {@link com.erudika.para.core.App} * @param hits the search results from a query * @return the list of object found */ private <P extends ParaObject> List<P> searchQuery(String appid, SearchHits hits) { if (hits == null) { return Collections.emptyList(); } ArrayList<P> results = new ArrayList<P>(hits.getHits().length); ArrayList<String> keys = new ArrayList<String>(hits.getHits().length); try { for (SearchHit hit : hits) { keys.add(hit.getId()); if (Config.READ_FROM_INDEX) { P pobj = ParaObjectUtils.setAnnotatedFields(hit.getSource()); results.add(pobj); } } if (!Config.READ_FROM_INDEX && !keys.isEmpty()) { Map<String, P> fromDB = dao.readAll(appid, keys, true); if (!fromDB.isEmpty()) { results.addAll(fromDB.values()); } } int sizeBefore = results.size(); results.removeAll(Collections.singleton(null)); int sizeAfter = results.size(); if (sizeBefore > (sizeAfter + 1)) { ArrayList<String> nullz = new ArrayList<String>(); for (int i = 0; i < results.size(); i++) { P obj = results.get(i); if (obj == null) { nullz.add(keys.get(i)); } } logger.warn("Found {} objects that are indexed but no longer exist in the database. Ids: {}", sizeBefore - sizeAfter, nullz); } logger.debug("Search.searchQuery() {}", results.size()); } catch (Exception e) { logger.warn(null, e); } return results; }
From source file:com.rickendirk.rsgwijzigingen.ZoekService.java
private ArrayList<String> checkerClusters() { ArrayList<String> tempList = new ArrayList<>(); //String van klas halen uit SP String klasTextS = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getString("pref_klas", ""); String url = "http://www.rsgtrompmeesters.nl/roosters/roosterwijzigingen/Lijsterbesstraat/subst_001.htm"; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); //Clusters ophalen uit SP ArrayList<String> clusters = new ArrayList<>(); for (int a = 1; a < 15; a++) { //String initializen, anders kan hij hem niet toevoegen String clusterLowCase = ""; String cluster = sp.getString("pref_cluster" + a, ""); //If om nullpointer te voorkomen if (!cluster.equals("")) { clusterLowCase = cluster.substring(0, 1).toLowerCase() + cluster.substring(1); }// w w w . j a v a 2 s .com clusters.add(clusterLowCase); } //Lege clusters weghalen uit arraylist TODO: Kijken of singleton werkt/wat het is clusters.removeAll(Collections.singleton("")); //Er moeten wel clusters zijn ingevoerd: Zo nee, komt AlertDialog via onPostExecute if (clusters.isEmpty()) { tempList.add("geenClusters"); return tempList; } //Checken of klas niet leeg is if (klasTextS.equals("")) { tempList.add("geenKlas"); return tempList; } //Eerste teken klas mag geen letter zijn if (Character.isLetter(klasTextS.charAt(0))) { tempList.add("EersteTekenLetter"); return tempList; } //String opsplitsen in 2 delen, om naar hoofdletters te converteren char charcijfer = klasTextS.charAt(0); String klascijfer = String.valueOf(charcijfer); char charafdeling = klasTextS.charAt(1); String klasafdelingBig = String.valueOf(charafdeling).toUpperCase(); //Onderstaand voor hoofdlettercorrectie String klasCorrect; //KlasCorrect is klas na hoofdlettercorrectie switch (klasTextS.length()) { case 2: klasCorrect = klascijfer + klasafdelingBig; break; case 3: char klasabc = klasTextS.charAt(2); String klasabcSmall = String.valueOf(klasabc).toLowerCase(); klasCorrect = klascijfer + klasafdelingBig + klasabcSmall; break; case 4: char klasafdeling2 = klasTextS.charAt(2); String klasafdeling2Big = String.valueOf(klasafdeling2).toUpperCase(); klasabc = klasTextS.charAt(3); klasabcSmall = String.valueOf(klasabc).toLowerCase(); klasCorrect = klascijfer + klasafdelingBig + klasafdeling2Big + klasabcSmall; break; default: tempList.add("klasMeerDan4Tekens"); return tempList; } //Try en catch in het geval dat de internetverbinding mist try { Document doc = Jsoup.connect(url).get(); Elements tables = doc.select("table"); if (tables.size() < 1) { //Geen geschikte tabel aanwezig tempList.add("geenTabel"); return tempList; } Element table = tables.get(1); Elements rows = table.select("tr"); //Eerste loop is om 2e loop te herhalen voor iedere cluster, tweede loop //doorzoekt dan op zowel klas als cluster for (int b = 0; b < clusters.size(); b++) { for (int i = 2; i < rows.size(); i++) { Element row = rows.get(i); Elements cols = row.select("td"); if (cols.get(0).text().contains(klasCorrect) && cols.get(2).text().contains(clusters.get(b))) { String vakOud = Jsoup.parse(cols.get(2).toString()).text(); String docentOud = Jsoup.parse(cols.get(3).toString()).text(); String vakNieuw = Jsoup.parse(cols.get(4).toString()).text(); String docentNieuw = Jsoup.parse(cols.get(5).toString()).text(); //If in geval van uitval, else ingeval van wijziging if (Jsoup.parse(cols.get(6).toString()).text().contains("--")) { //2 opties: wordt verplaatst of valt uit if (Jsoup.parse(cols.get(8).toString()).text().contains("Uitval")) { String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur " + Jsoup.parse(cols.get(2).toString()).text() + " valt uit"; tempList.add(wijziging); } else { //Uur wordt verplaatst String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur " + "wordt verplaatst naar " + Jsoup.parse(cols.get(8).toString()).text(); tempList.add(wijziging); } } else if (vakOud.equals(vakNieuw) && docentOud.equals(docentNieuw)) { String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur " + vakOud + " wordt verplaatst naar " + Jsoup.parse(cols.get(6).toString()).text(); tempList.add(wijziging); } else { String wijzigingKaal = // Voegt alle kolommen samen tot 1 string // .text() zorgt voor leesbare text // Spaties voor leesbaarheid Jsoup.parse(cols.get(1).toString()).text() + "e uur " + Jsoup.parse(cols.get(2).toString()).text() + " " + Jsoup.parse(cols.get(3).toString()).text() + " wordt " + Jsoup.parse(cols.get(4).toString()).text() + " " + Jsoup.parse(cols.get(5).toString()).text() + " in " + Jsoup.parse(cols.get(6).toString()).text(); //ipv en naar bevatten een "/" ivm uren (ma 12-04 / 4) String ipv = ""; if (Jsoup.parse(cols.get(7).toString()).text().contains("/")) { ipv = "ipv " + Jsoup.parse(cols.get(7).toString()).text(); } String naar = ""; if (Jsoup.parse(cols.get(8).toString()).text().contains("/")) { naar = "naar " + Jsoup.parse(cols.get(8).toString()).text() + " "; } String vervangingsTekst = ""; // staat in lege cell, encoding enz, zie volgende link: // http://stackoverflow.com/questions/26837034/how-to-tell-if-a-html-table-has-an-empty-cell-nbsp-using-jsoup if (cols.size() > 9) { if (!Jsoup.parse(cols.get(9).toString()).text().equals("\u00a0")) { vervangingsTekst = "(" + Jsoup.parse(cols.get(9).toString()).text() + ")"; } } String wijziging = wijzigingKaal + " " + ipv + " " + naar + " " + vervangingsTekst; tempList.add(wijziging); } } //Geen wijzigingen pas bij laatste rij en de laatste cluster if (i == rows.size() - 1 && b == clusters.size() - 1) { //Checken of tempList leeg is, zo ja 1 ding toevoegen if (tempList.isEmpty()) { tempList.add("Er zijn geen wijzigingen"); } //Dag waarvoor wijzigingen zijn ophalen Element dag = doc.select("body > div > div:nth-child(2) > p > b > span").first(); //Compatibiliteit met andere opmaak, om NPE te voorkomen if (dag == null) { dag = doc.select("body > center:nth-child(2) > div").first(); } String dagStr = dag.text().toLowerCase(); // Woorden staan verkeerd om: omwisselen int indexVanSpatie = dagStr.indexOf(" "); String datum = dagStr.substring(0, indexVanSpatie); String rest = dagStr.substring(indexVanSpatie + 1); String dagGoed = rest + " " + datum; tempList.add(dagGoed); //Stand ophalen: staat in 1e tabel van HTML Element tableDate = doc.select("table").get(0); String dateFullText = tableDate.getElementsContainingOwnText("Stand:").text(); //Deel achter "Stand:" pakken String FullTextSplit[] = dateFullText.split("Stand:"); tempList.add(FullTextSplit[1]); return tempList; } } } } catch (java.io.IOException e) { //Error toevoegen aan tempList, dat wordt weergegeven in messagebox tempList.clear(); tempList.add("verbindFout"); return tempList; } //Zover hoort de method NOOIT te komen tempList.add("andereFout"); return tempList; }
From source file:jp.surbiton.billing_utilities.IabHelper.java
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus) throws RemoteException, JSONException { logDebug("Querying SKU details."); ArrayList<String> skuList = new ArrayList<String>(); skuList.addAll(inv.getAllOwnedSkus(itemType)); if (moreSkus != null) { for (String sku : moreSkus) { if (!skuList.contains(sku)) { skuList.add(sku);/* ww w. ja v a 2s.co m*/ } } } if (skuList.size() == 0) { logDebug("queryPrices: nothing to do because there are no SKUs."); return BILLING_RESPONSE_RESULT_OK; } while (skuList.size() > 0) { ArrayList<String> skuSubList = new ArrayList<String>(skuList.subList(0, Math.min(19, skuList.size()))); skuList.removeAll(skuSubList); Bundle querySkus = new Bundle(); querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuSubList); Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus); if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) { int response = getResponseCodeFromBundle(skuDetails); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getSkuDetails() failed: " + getResponseDesc(response)); return response; } else { logError("getSkuDetails() returned a bundle with neither an error nor a detail list."); return IABHELPER_BAD_RESPONSE; } } ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); for (String thisResponse : responseList) { SkuDetails d = new SkuDetails(itemType, thisResponse); logDebug("Got sku details: " + d); inv.addSkuDetails(d); } } return BILLING_RESPONSE_RESULT_OK; }
From source file:org.dmfs.webcal.utils.billing.IabHelper.java
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus) throws RemoteException, JSONException { logDebug("Querying SKU details."); Context context = mContext;/* w ww . j a v a 2 s . co m*/ IInAppBillingService service = mService; if (context == null || service == null) { return IABHELPER_BAD_RESPONSE; } ArrayList<String> skuList = new ArrayList<String>(); skuList.addAll(inv.getAllOwnedSkus(itemType)); if (moreSkus != null) { for (String sku : moreSkus) { if (!skuList.contains(sku)) { skuList.add(sku); } } } if (skuList.size() == 0) { logDebug("queryPrices: nothing to do because there are no SKUs."); return BILLING_RESPONSE_RESULT_OK; } while (skuList.size() > 0) { ArrayList<String> skuSubList = new ArrayList<String>(skuList.subList(0, Math.min(19, skuList.size()))); skuList.removeAll(skuSubList); Bundle querySkus = new Bundle(); querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuSubList); Bundle skuDetails = service.getSkuDetails(3, context.getPackageName(), itemType, querySkus); if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) { int response = getResponseCodeFromBundle(skuDetails); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getSkuDetails() failed: " + getResponseDesc(response)); return response; } else { logError("getSkuDetails() returned a bundle with neither an error nor a detail list."); return IABHELPER_BAD_RESPONSE; } } ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); for (String thisResponse : responseList) { SkuDetails d = new SkuDetails(itemType, thisResponse); logDebug("Got sku details: " + d); inv.addSkuDetails(d); } } return BILLING_RESPONSE_RESULT_OK; }
From source file:org.pentaho.chart.plugin.openflashchart.OpenFlashChartFactoryEngine.java
private Palette getPalette(Plot plot) { Palette palette = new Palette(); if (plot.getPalette() != null) { palette.addAll(plot.getPalette()); }/*from ww w. j ava 2 s .com*/ ArrayList<Integer> defaultColors = new ArrayList<Integer>(Plot.DEFAULT_PALETTE); defaultColors.removeAll(palette); palette.addAll(defaultColors); return palette; }