本文整理汇总了Java中com.esri.arcgisruntime.concurrent.ListenableFuture类的典型用法代码示例。如果您正苦于以下问题:Java ListenableFuture类的具体用法?Java ListenableFuture怎么用?Java ListenableFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListenableFuture类属于com.esri.arcgisruntime.concurrent包,在下文中一共展示了ListenableFuture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: 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() );
}
}
});
}
}
开发者ID:Esri,项目名称:nearby-android,代码行数:68,代码来源:LocationService.java
示例2: 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();
}
}
});
}
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:30,代码来源:MobileMapViewActivity.java
示例3: queryEmuSummaryStatistics
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入依赖的package包/类
/**
* Query for all EMU summary statistics (~40 rows of data).
* This is done once and the results cached locally.
* @param callback - The StatCallback called when query is completed
*/
public void queryEmuSummaryStatistics(final ServiceApi.StatCallback callback){
if (summary_table.size() > 0){
callback.onStatsLoaded(true);
}else{
mSummaryStats.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.MANUAL_CACHE);
mSummaryStats.loadAsync();
mSummaryStats.addDoneLoadingListener(new Runnable() {
@Override public void run() {
final QueryParameters queryParameters = new QueryParameters();
// Get all the rows in the table
queryParameters.setWhereClause("1 = 1");
final Collection<String> outFields = new ArrayList<String>();
// Get all the fields in the table
outFields.add("*");
final ListenableFuture<FeatureQueryResult> futureResult = mSummaryStats.populateFromServiceAsync(queryParameters,true,outFields);
processQueryForEmuStats(futureResult, callback);
}
});
}
}
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:26,代码来源:DataManager.java
示例4: 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();
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:27,代码来源:WebmapKeywordSearchController.java
示例5: 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);
}
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:WebmapKeywordSearchController.java
示例6: 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();
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:28,代码来源:SymbolDictionaryController.java
示例7: 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();
}
});
}
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:23,代码来源:SymbolView.java
示例8: 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());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:AddFeaturesSample.java
示例9: 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());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:EditFeatureAttachmentsSample.java
示例10: 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.");
}
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:23,代码来源:EditFeatureAttachmentsSample.java
示例11: 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());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:28,代码来源:EditFeatureAttachmentsSample.java
示例12: 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());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:24,代码来源:UpdateGeometriesSample.java
示例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, "Attributes updated.");
} else {
throw edits.get(0).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
displayMessage("Error applying edits on server", e.getCause().getMessage());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:UpdateAttributesSample.java
示例14: 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());
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:DeleteFeaturesSample.java
示例15: 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());
}
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:21,代码来源:MainActivity.java
示例16: 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());
}
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:27,代码来源:MainActivity.java
示例17: identifyResult
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入依赖的package包/类
/**
* Performs an identify on layers at the given screenpoint and calls handleIdentifyResults(...) to process them.
*
* @param screenPoint in Android graphic coordinates.
*/
private void identifyResult(android.graphics.Point screenPoint) {
final ListenableFuture<List<IdentifyLayerResult>> identifyLayerResultsFuture = mMapView
.identifyLayersAsync(screenPoint, 12, false, 10);
identifyLayerResultsFuture.addDoneListener(new Runnable() {
@Override public void run() {
try {
List<IdentifyLayerResult> identifyLayerResults = identifyLayerResultsFuture.get();
handleIdentifyResults(identifyLayerResults);
} catch (InterruptedException | ExecutionException e) {
Log.e(TAG, "Error identifying results: " + e.getMessage());
}
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:22,代码来源:MainActivity.java
示例18: deleteAttachment
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入依赖的package包/类
/**
* Delete the attachment from the feature
*
* @param pos position of the attachment in the list view to be deleted
*/
private void deleteAttachment(int pos) {
progressDialog.setTitle(getApplication().getString(R.string.deleting_attachments));
progressDialog.setMessage(getApplication().getString(R.string.wait));
progressDialog.show();
ListenableFuture<Void> deleteResult = mSelectedArcGISFeature.deleteAttachmentAsync(attachments.get(pos));
attachmentList.remove(pos);
adapter.notifyDataSetChanged();
deleteResult.addDoneListener(new Runnable() {
@Override
public void run() {
ListenableFuture<Void> tableResult = mServiceFeatureTable.updateFeatureAsync(mSelectedArcGISFeature);
// apply changes back to the server
tableResult.addDoneListener(new Runnable() {
@Override
public void run() {
applyServerEdits();
}
});
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:29,代码来源:EditAttachmentActivity.java
示例19: fetchCredentials
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入依赖的package包/类
/**
* fetch the OAuth token from the OAuthLogin Manager
*
* @param intent
*/
private void fetchCredentials(Intent intent) {
// Fetch oauth access token.
final ListenableFuture<OAuthTokenCredential> future = oauthLoginManager.fetchOAuthTokenCredentialAsync(intent);
future.addDoneListener(new Runnable() {
@Override
public void run() {
try {
oauthCred = future.get();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:21,代码来源:MapSaveActivity.java
示例20: dispatchFireTruck
import com.esri.arcgisruntime.concurrent.ListenableFuture; //导入依赖的package包/类
@FXML
private void dispatchFireTruck() {
// apply the changes to the server
ListenableFuture<List<FeatureEditResult>> editResult = pointsFeatureTable.applyEditsAsync();
editResult.addDoneListener(() -> {
try {
// check if the server edit was successful
List<FeatureEditResult> edits = editResult.get();
if (edits != null && edits.size() > 0 && !edits.get(0).hasCompletedWithErrors()) {
displayMessage("Report sent successfully");
}
} catch (InterruptedException | ExecutionException exception) {
exception.printStackTrace();
}
});
truckButton.setDisable(true);
helicopterButton.setDisable(false);
}
开发者ID:Esri,项目名称:arcgis-runtime-demo-java,代码行数:21,代码来源:MonitorController.java
注:本文中的com.esri.arcgisruntime.concurrent.ListenableFuture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论