当前位置: 首页>>代码示例>>Java>>正文


Java ListenableFuture类代码示例

本文整理汇总了Java中com.esri.arcgisruntime.concurrent.ListenableFuture的典型用法代码示例。如果您正苦于以下问题:Java ListenableFuture类的具体用法?Java ListenableFuture怎么用?Java ListenableFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ListenableFuture类属于com.esri.arcgisruntime.concurrent包,在下文中一共展示了ListenableFuture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的com.esri.arcgisruntime.concurrent.ListenableFuture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。