List of usage examples for java.util Collections swap
private static void swap(Object[] arr, int i, int j)
From source file:tech.town.app.com.apptowntech.adapter.RecyclerListAdapter.java
@Override public boolean onItemMove(int fromPosition, int toPosition) { Collections.swap(stList, fromPosition, toPosition); stList.get(toPosition).setSelected(true); notifyItemMoved(fromPosition, toPosition); return true;/*from w w w . ja v a 2 s. c om*/ }
From source file:tripin.com.tripin_shipper.adapter.AddressSwapDropAdapter.java
@Override public boolean onItemMove(int fromPosition, int toPosition) { Collections.swap(mItems, fromPosition, toPosition); notifyItemMoved(fromPosition, toPosition); Log.e("moved", " items moved " + fromPosition + " " + toPosition); return true;/* w ww .j a v a 2 s. com*/ }
From source file:net.hyx.app.volumenotification.adapter.ListViewAdapter.java
@Override public boolean onItemMove(int fromPosition, int toPosition) { Collections.swap(items, fromPosition, toPosition); notifyItemMoved(fromPosition, toPosition); return true;/* w w w . jav a 2 s . c o m*/ }
From source file:gr.abiss.calipso.wicket.components.dataview.DataViewAssetTypeLookupValue.java
private void moveUp(CustomAttributeLookupValue lookupValue) { int siz = dataList.size(); int currentPos = dataList.indexOf(lookupValue); if (currentPos - 1 > 0) { Collections.swap(dataList, currentPos, currentPos - 1); }/*from w ww . j a va 2s .c o m*/ }
From source file:com.ubershy.streamsis.project.SisScene.java
/** * Moves down Actor name in SisScene Actor name list. Only useful for GUI. * /*w ww. ja v a 2s .c o m*/ * @param actorName * the name of Actor */ public void moveDownActorName(String actorName) { int index = actorNames.indexOf(actorName); if (actorNames.size() != index + 1) Collections.swap(actorNames, index, index + 1); }
From source file:ca.simplegames.micro.extensions.i18n.I18NExtension.java
public Extension register(String name, SiteContext site, Map<String, Object> locales) throws Exception { Assert.notNull(name, "The name of the extension must not be null!"); this.name = StringUtils.defaultIfBlank(name, "i18N"); if (locales != null) { Map interceptConfig = (Map<String, Object>) locales.get("intercept"); if (interceptConfig != null) { intercept = StringUtils.defaultString((String) interceptConfig.get("parameter_name"), "lang"); scopesSrc = StringUtils.defaultString((String) interceptConfig.get("scope"), "context"); scopes = StringUtils.split(scopesSrc, ","); }// w ww . j a v a 2 s .c o m defaultEncoding = StringUtils.defaultString((String) locales.get("default_encoding"), Globals.UTF8); fallbackToSystemLocale = locales.get("fallback_to_system_locale") != null ? (Boolean) locales.get("fallback_to_system_locale") : true; resourceCacheRefreshInterval = Integer .parseInt(StringUtils.defaultString((locales.get("resource_cache")).toString(), "10")); List<String> paths = (List<String>) locales.get("base_names"); if (paths != null && !paths.isEmpty()) { List<String> absPaths = new ArrayList<String>(); for (String path : paths) { File realPath = new File(path); if (!realPath.exists()) { realPath = new File(site.getWebInfPath().getAbsolutePath(), path); } try { absPaths.add(realPath.toURI().toURL().toString()); //absPaths.add(pathConfig.getValue()); } catch (MalformedURLException e) { e.printStackTrace(); } } resourceBasePaths = absPaths.toArray(new String[absPaths.size()]); } else { resourceBasePaths = new String[] { "config/locales/messages" }; } //Configure the i18n messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setDefaultEncoding(defaultEncoding); messageSource.setFallbackToSystemLocale(fallbackToSystemLocale); messageSource.setCacheSeconds(resourceCacheRefreshInterval); messageSource.setBasenames(resourceBasePaths); Filter i18N = new I18NFilter(this); final FilterManager filterManager = site.getFilterManager(); filterManager.addFilter(i18N); // now make sure the i18N filter is always first (if present) Collections.swap(filterManager.getBeforeFilters(), 0, filterManager.getBeforeFilters().size() - 1); infoDetails.add(String.format(" default encoding ........: %s", defaultEncoding)); infoDetails.add(String.format(" fallback to system locale: %s", fallbackToSystemLocale)); infoDetails.add(String.format(" cache refresh ...........: %s", resourceCacheRefreshInterval)); infoDetails.add(String.format(" resource bundle .........: %s", Arrays.toString(resourceBasePaths))); infoDetails.add(String.format(" Listening for ...........: '%s'", intercept)); infoDetails.add(String.format(" in scope(s) ........: %s", scopesSrc)); } return this; }
From source file:gr.abiss.calipso.wicket.components.dataview.DataViewAssetTypeLookupValue.java
private void moveDown(CustomAttributeLookupValue lookupValue) { int siz = dataList.size(); int currentPos = dataList.indexOf(lookupValue); if (currentPos + 1 < siz) { Collections.swap(dataList, currentPos, currentPos + 1); }/*from w w w. j av a 2 s. co m*/ }
From source file:com.ubershy.streamsis.project.SisScene.java
/** * Moves up Actor name in SisScene Actor name list. Only useful for GUI. * * @param actorName//from w ww. j a v a 2 s. co m * the name of Actor */ public void moveUpActorName(String actorName) { int index = actorNames.indexOf(actorName); if (index != 0) Collections.swap(actorNames, index, index - 1); }
From source file:ec.edu.chyc.manejopersonal.managebean.GestorArticulo.java
public void moverArriba(PersonaArticulo personaArticuloMover, Integer indexActual) { if (indexActual != 0) { //Collections.swap intercambia el contenido de las posiciones dadas Collections.swap(listaPersonaArticulo, indexActual, indexActual - 1); }//from ww w . j av a2 s . co m }
From source file:com.heliosdecompiler.helios.gui.controller.PathEditorController.java
@FXML private void up(MouseEvent event) { int selected = list.getSelectionModel().getSelectedIndex(); if (selected != -1) { if (selected > 0) { Collections.swap(list.getItems(), selected, selected - 1); this.list.getSelectionModel().select(selected - 1); } else {/* w ww.j a va2 s .c o m*/ this.list.getSelectionModel().select(0); } this.list.requestFocus(); } }