use of mpicbg.trakem2.util.Pair in project gh4a by slapperwan.
the class RepositoryActivity method loadOrShowRefSelection.
private void loadOrShowRefSelection() {
if (mBranches != null) {
showRefSelectionDialog();
} else {
final RepositoryBranchService branchService = ServiceFactory.get(RepositoryBranchService.class, false);
final RepositoryService repoService = ServiceFactory.get(RepositoryService.class, false);
Single<List<Branch>> branchSingle = ApiHelpers.PageIterator.toSingle(page -> branchService.getBranches(mRepoOwner, mRepoName, page));
Single<List<Branch>> tagSingle = ApiHelpers.PageIterator.toSingle(page -> repoService.getTags(mRepoOwner, mRepoName, page));
registerTemporarySubscription(Single.zip(branchSingle, tagSingle, Pair::create).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
mBranches = result.first;
mTags = result.second;
showRefSelectionDialog();
}, this::handleLoadFailure));
}
}
use of mpicbg.trakem2.util.Pair in project Osmand by osmandapp.
the class PagerSlidingTabStrip method getIndicatorCoordinates.
private Pair<Float, Float> getIndicatorCoordinates() {
// default: line below current tab
View currentTab = tabsContainer.getChildAt(currentPosition);
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
// if there is an offset, start interpolating left and right coordinates between current and next tab
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
View nextTab = tabsContainer.getChildAt(currentPosition + 1);
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
return new Pair<Float, Float>(lineLeft, lineRight);
}
use of mpicbg.trakem2.util.Pair in project Osmand by osmandapp.
the class MapSourceAction method execute.
@Override
public void execute(MapActivity activity) {
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams();
Pair<String, String> currentSource = settings.MAP_ONLINE_DATA.get() ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get()) : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data));
Pair<String, String> nextSource = sources.get(0);
int index = sources.indexOf(currentSource);
if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1);
}
if (nextSource.first.equals(LAYER_OSM_VECTOR)) {
settings.MAP_ONLINE_DATA.set(false);
activity.getMapLayers().updateMapSource(activity.getMapView(), null);
} else {
settings.MAP_TILE_SOURCES.set(nextSource.first);
settings.MAP_ONLINE_DATA.set(true);
activity.getMapLayers().updateMapSource(activity.getMapView(), settings.MAP_TILE_SOURCES);
}
Toast.makeText(activity, activity.getString(R.string.quick_action_map_source_switch, nextSource.second), Toast.LENGTH_SHORT).show();
}
}
use of mpicbg.trakem2.util.Pair in project streamline by hortonworks.
the class KafkaServiceRegistrar method createKafkaBrokerComponent.
private Pair<Component, List<ComponentProcess>> createKafkaBrokerComponent(Config config, Map<String, String> flattenConfigMap) {
if (!config.contains(PARAM_LISTENERS)) {
throw new IllegalArgumentException("Required parameter " + PARAM_LISTENERS + " not present.");
}
Map<String, String> confMap = new HashMap<>();
confMap.put(PARAM_LISTENERS, config.getString(PARAM_LISTENERS));
Component kafkaBroker = new Component();
kafkaBroker.setName(COMPONENT_KAFKA_BROKER);
List<KafkaBrokerListeners.ListenersPropEntry> parsedProps = new KafkaBrokerListeners.ListenersPropParsed(confMap).getParsedProps();
List<ComponentProcess> componentProcesses = parsedProps.stream().map(propEntry -> {
ComponentProcess cp = new ComponentProcess();
cp.setHost(propEntry.getHost());
cp.setPort(propEntry.getPort());
cp.setProtocol(propEntry.getProtocol().name());
return cp;
}).collect(toList());
return new Pair<>(kafkaBroker, componentProcesses);
}
use of mpicbg.trakem2.util.Pair in project streamline by hortonworks.
the class StormServiceRegistrar method createNimbusComponent.
private Pair<Component, List<ComponentProcess>> createNimbusComponent(Config config, Map<String, String> flatConfigMap) {
if (!config.contains(PARAM_NIMBUS_SEEDS)) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " not present.");
}
if (!config.contains(PARAM_NIMBUS_THRIFT_PORT)) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_THRIFT_PORT + " not present.");
}
String nimbusSeeds;
try {
nimbusSeeds = config.getString(PARAM_NIMBUS_SEEDS);
} catch (ClassCastException e) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " should be a string.");
}
Number nimbusThriftPort = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_PORT);
Component nimbus = new Component();
nimbus.setName(COMPONENT_NIMBUS);
List<ComponentProcess> componentProcesses = Arrays.stream(nimbusSeeds.split(",")).map(nimbusHost -> {
ComponentProcess cp = new ComponentProcess();
cp.setHost(nimbusHost);
cp.setPort(nimbusThriftPort.intValue());
return cp;
}).collect(toList());
return new Pair<>(nimbus, componentProcesses);
}
Aggregations