本文整理汇总了Java中com.esri.arcgisruntime.concurrent.ListenableFuture.addDoneListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListenableFuture.addDoneListener方法的具体用法?Java ListenableFuture.addDoneListener怎么用?Java ListenableFuture.addDoneListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esri.arcgisruntime.concurrent.ListenableFuture
的用法示例。
在下文中一共展示了ListenableFuture.addDoneListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reverseGeocode
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Calls reverseGeocode on a Locator Task and, if there is a result, passes the result to a
* Callout method
* @param point user generated map point
* @param graphic used for marking the point on which the user touched
*/
private void reverseGeocode(final Point point, final Graphic graphic) {
if (mLocatorTask != null) {
final ListenableFuture<List<GeocodeResult>> results =
mLocatorTask.reverseGeocodeAsync(point, mReverseGeocodeParameters);
results.addDoneListener(new Runnable() {
public void run() {
try {
List<GeocodeResult> geocodeResult = results.get();
if (geocodeResult.size() > 0) {
graphic.getAttributes().put(
"Match_addr", geocodeResult.get(0).getLabel());
showCalloutForGraphic(graphic, point);
} else {
//no result was found
mMapView.getCallout().dismiss();
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
});
}
}
示例2: run
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
@Override
public void run (){
final LoadStatus status = mRouteTask.getLoadStatus();
// Has the route task loaded successfully?
if (status == LoadStatus.FAILED_TO_LOAD) {
Log.i(TAG, mRouteTask.getLoadError().getMessage());
Log.i(TAG, "CAUSE = " + mRouteTask.getLoadError().getCause().getMessage());
} else {
final ListenableFuture<RouteParameters> routeTaskFuture = mRouteTask
.createDefaultParametersAsync();
// Add a done listener that uses the returned route parameters
// to build up a specific request for the route we need
routeTaskFuture.addDoneListener(new Runnable() {
@Override
public void run() {
try {
final RouteParameters routeParameters = routeTaskFuture.get();
final TravelMode mode = routeParameters.getTravelMode();
mode.setImpedanceAttributeName("WalkTime");
mode.setTimeAttributeName("WalkTime");
// Set the restriction attributes for walk times
List<String> restrictionAttributes = mode.getRestrictionAttributeNames();
// clear default restrictions set for vehicles
restrictionAttributes.clear();
// add pedestrian restrictions
restrictionAttributes.add("Avoid Roads Unsuitable for Pedestrians");
restrictionAttributes.add("Preferred for Pedestrians");
restrictionAttributes.add("Walking");
// Add a stop for origin and destination
routeParameters.setTravelMode(mode);
routeParameters.getStops().add(origin);
routeParameters.getStops().add(destination);
// We want the task to return driving directions and routes
routeParameters.setReturnDirections(true);
routeParameters.setOutputSpatialReference(SpatialReferences.getWebMercator());
final ListenableFuture<RouteResult> routeResFuture = mRouteTask
.solveRouteAsync(routeParameters);
routeResFuture.addDoneListener(new Runnable() {
@Override
public void run() {
try {
final RouteResult routeResult = routeResFuture.get();
// Show route results
if (routeResult != null){
mCallback.onRouteReturned(routeResult);
}else{
Log.i(TAG, "NO RESULT FROM ROUTING");
}
} catch (final Exception e) {
Log.e(TAG, e.getMessage());
}
}
});
} catch (final Exception e1){
Log.e(TAG,e1.getMessage() );
}
}
});
}
}
示例3: search
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Searches a portal for webmaps matching query string in keyword textfield. The list view is updated with
* the results.
*/
@FXML
private void search() {
// create query parameters specifying the type WEBMAP
PortalQueryParameters params = new PortalQueryParameters();
params.setQuery(PortalItem.Type.WEBMAP, null, keyword.getText());
// find matching portal items
ListenableFuture<PortalQueryResultSet<PortalItem>> results = portal.findItemsAsync(params);
results.addDoneListener(() -> {
try {
// update the results list view with matching items
portalQueryResultSet = results.get();
List<PortalItem> portalItems = portalQueryResultSet.getResults();
resultsList.getItems().clear();
resultsList.getItems().addAll(portalItems);
moreButton.setDisable(false);
} catch (Exception e) {
e.printStackTrace();
}
});
}
示例4: getMoreResults
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Adds the next set of results to the list view.
*/
@FXML
private void getMoreResults() {
if (portalQueryResultSet.getNextQueryParameters() != null) {
// find matching portal items
ListenableFuture<PortalQueryResultSet<PortalItem>> results = portal.findItemsAsync(portalQueryResultSet.getNextQueryParameters());
results.addDoneListener(() -> {
try {
// replace the result set with the current set of results
portalQueryResultSet = results.get();
List<PortalItem> portalItems = portalQueryResultSet.getResults();
// add set of results to list view
resultsList.getItems().addAll(portalItems);
} catch (Exception e) {
e.printStackTrace();
}
});
} else {
showMessage("End of results", "There are no more results matching this query", Alert.AlertType.INFORMATION);
moreButton.setDisable(true);
}
}
示例5: handleSearchAction
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Searches through the symbol dictionary using the text from the search fields.
*/
@FXML
private void handleSearchAction() {
// get parameters from input fields
SymbolStyleSearchParameters searchParameters = new SymbolStyleSearchParameters();
searchParameters.getNames().add(nameField.getText());
searchParameters.getTags().add(tagField.getText());
searchParameters.getSymbolClasses().add(symbolClassField.getText());
searchParameters.getCategories().add(categoryField.getText());
searchParameters.getKeys().add(keyField.getText());
// search for any matching symbols
ListenableFuture<List<SymbolStyleSearchResult>> search = dictionarySymbol.searchSymbolsAsync(searchParameters);
search.addDoneListener(() -> {
try {
// update the result list (triggering the listener)
List<SymbolStyleSearchResult> searchResults = search.get();
searchResultsFound.setText(String.valueOf(searchResults.size()));
results.clear();
results.addAll(searchResults);
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace();
}
});
}
示例6: initialize
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
// initialize the component values
name.setText(styleSymbolSearchResult.getName());
tags.setText(styleSymbolSearchResult.getTags().toString());
symbolClass.setText(styleSymbolSearchResult.getSymbolClass());
category.setText(styleSymbolSearchResult.getCategory());
key.setText(styleSymbolSearchResult.getKey());
// set image for non-text symbols
if (!category.getText().startsWith("Text")) {
Symbol symbol = styleSymbolSearchResult.getSymbol();
ListenableFuture<Image> imageResult = symbol.createSwatchAsync(40, 40, 0x00FFFFFF, new Point(0, 0, 0));
imageResult.addDoneListener(() -> {
try {
imageView.setImage(imageResult.get());
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace();
}
});
}
}
示例7: applyEdits
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Sends any edits on the ServiceFeatureTable to the server.
*
* @param featureTable service feature table
*/
private void applyEdits(ServiceFeatureTable featureTable) {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
List<FeatureEditResult> edits = editResult.get();
// check if the server edit was successful
if (edits != null && edits.size() > 0) {
if (!edits.get(0).hasCompletedWithErrors()) {
displayMessage(null, "Feature successfully added");
} else {
throw edits.get(0).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
displayMessage("Exception applying edits on server", e.getCause().getMessage());
}
});
}
示例8: fetchAttachments
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Updates the UI with a list of a feature's attachments.
*/
private void fetchAttachments(ArcGISFeature feature) {
ListenableFuture<List<Attachment>> attachmentResults = feature.fetchAttachmentsAsync();
attachmentResults.addDoneListener(() -> {
try {
attachments = attachmentResults.get();
// update UI attachments list
Platform.runLater(() -> {
attachmentList.getItems().clear();
attachments.forEach(attachment -> attachmentList.getItems().add(attachment.getName()));
if (!attachments.isEmpty()) {
attachmentsLabel.setText("Attachments: ");
} else {
attachmentsLabel.setText("No Attachments!");
}
});
} catch (InterruptedException | ExecutionException e) {
displayMessage("Exception getting feature attachments", e.getCause().getMessage());
}
});
}
示例9: addAttachment
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Adds an attachment to a Feature.
*
* @param attachment byte array of attachment
*/
private void addAttachment(byte[] attachment) {
if (selected.canEditAttachments()) {
ListenableFuture<Attachment> addResult = selected.addAttachmentAsync(attachment, "image/png",
"symbols/destroyed.png");
addResult.addDoneListener(() -> {
// update feature table
ListenableFuture<Void> tableResult = featureTable.updateFeatureAsync(selected);
// apply update to server when new feature is added, and update the
// displayed list of attachments
tableResult.addDoneListener(() -> applyEdits(featureTable));
});
} else {
displayMessage(null, "Cannot add attachment.");
}
}
示例10: applyEdits
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Sends any edits on the ServiceFeatureTable to the server.
*
* @param featureTable service feature table
*/
private void applyEdits(ServiceFeatureTable featureTable) {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
List<FeatureEditResult> edits = editResult.get();
// check if the server edit was successful
if (edits != null && edits.size() > 0) {
if (!edits.get(0).hasCompletedWithErrors()) {
displayMessage(null, "Edited feature successfully");
} else {
throw edits.get(0).getError();
}
}
// update the displayed list of attachments
fetchAttachments(selected);
} catch (InterruptedException | ExecutionException e) {
displayMessage("Error applying edits on server ", e.getCause().getMessage());
}
});
}
示例11: applyEdits
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Sends any edits on the ServiceFeatureTable to the server.
*/
private static void applyEdits() {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
List<FeatureEditResult> edits = editResult.get();
// check if the server edit was successful
if (edits != null && edits.size() > 0) {
if (!edits.get(0).hasCompletedWithErrors()) {
displayMessage(null, "Geometry updated");
} else {
throw edits.get(0).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
displayMessage("Error applying edits on server", e.getCause().getMessage());
}
});
}
示例12: applyEdits
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Sends any edits on the ServiceFeatureTable to the server.
*
* @param featureTable service feature table
*/
private void applyEdits(ServiceFeatureTable featureTable) {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
List<FeatureEditResult> edits = editResult.get();
// check if the server edit was successful
if (edits != null && edits.size() > 0) {
if (!edits.get(0).hasCompletedWithErrors()) {
displayMessage(null, "Attributes updated.");
} else {
throw edits.get(0).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
displayMessage("Error applying edits on server", e.getCause().getMessage());
}
});
}
示例13: applyEdits
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Sends any edits on the ServiceFeatureTable to the server.
*
* @param featureTable service feature table
*/
private void applyEdits(ServiceFeatureTable featureTable) {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
List<FeatureEditResult> edits = editResult.get();
// check if the server edit was successful
if (edits != null && edits.size() > 0) {
if (!edits.get(0).hasCompletedWithErrors()) {
displayMessage(null, "Feature successfully deleted");
} else {
throw edits.get(0).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
displayMessage("Exception applying edits on server", e.getCause().getMessage());
}
});
}
示例14: applyEditsToServer
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* Applies edits to the FeatureService
*/
private void applyEditsToServer() {
final ListenableFuture<List<FeatureEditResult>> applyEditsFuture = ((ServiceFeatureTable) mFeatureLayer.getFeatureTable()).applyEditsAsync();
applyEditsFuture.addDoneListener(new Runnable() {
@Override
public void run() {
try {
// get results of edit
List<FeatureEditResult> featureEditResultsList = applyEditsFuture.get();
if (!featureEditResultsList.get(0).hasCompletedWithErrors()) {
Toast.makeText(getApplicationContext(), "Applied Geometry Edits to Server. ObjectID: " + featureEditResultsList.get(0).getObjectId(), Toast.LENGTH_SHORT).show();
}
} catch (InterruptedException | ExecutionException e) {
Log.e(getResources().getString(R.string.app_name), "Update feature failed: " + e.getMessage());
}
}
});
}
示例15: captureScreenshotAsync
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入方法依赖的package包/类
/**
* capture the map as an image
*/
private void captureScreenshotAsync() {
// export the image from the mMapView
final ListenableFuture<Bitmap> export = mMapView.exportImageAsync();
export.addDoneListener(new Runnable() {
@Override
public void run() {
try {
Bitmap currentMapImage = export.get();
// play the camera shutter sound
MediaActionSound sound = new MediaActionSound();
sound.play(MediaActionSound.SHUTTER_CLICK);
Log.d(TAG,"Captured the image!!");
// save the exported bitmap to an image file
SaveImageTask saveImageTask = new SaveImageTask();
saveImageTask.execute(currentMapImage);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.map_export_failure) + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e(TAG, getResources().getString(R.string.map_export_failure) + e.getMessage());
}
}
});
}