Hello Everyone,
Given below are my scenario
Query the service Url with object id then if it contains any attachment then display it and facilitate the user to add attachments.
I have referred the samples and found the Edit attachment. But in that it has been done through ListenableFuture<IdentifyLayerResult>. But instead I want to do it with ListenableFuture<FeatureQueryResult>
Everything fine till the query and getting result. After getting result and iterating through next. I am getting result as feature and could not find any method to convert from com.esri.arcgisruntime.data.Feature to com.esri.arcgisruntime.data.ArcGISFeature. Please suggest me on this.
Given below Code Snap private void QueryFeatureandLoad() { mServiceFeatureTable = new ServiceFeatureTable(getString(R.string.sample_service_url)); mServiceFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_CACHE); // create the feature layer using the service feature table mFeatureLayer = new FeatureLayer(mServiceFeatureTable); // clear any previous selection mFeatureLayer.clearSelection(); mSelectedArcGISFeature = null; final QueryParameters query = new QueryParameters(); final String searchString ="objectid=77"; //make search case insensitive query.setWhereClause(searchString); final ListenableFuture<FeatureQueryResult> future = mServiceFeatureTable.queryFeaturesAsync(query, ServiceFeatureTable.QueryFeatureFields.LOAD_ALL); // add done loading listener to fire when the selection returns future.addDoneListener(new Runnable() { @Override public void run() { try { // call get on the future to get the result FeatureQueryResult result = future.get(); // check there are some results if (result.iterator().hasNext()) { // get the extend of the first feature in the result to zoom to Feature feature = result.iterator().next(); Envelope envelope = feature.getGeometry().getExtent(); mMapView.setViewpointGeometryAsync(envelope, 10); //Select the feature mFeatureLayer.selectFeature(feature); //*** GOT STUCKUP HERE * mselectedArcGISFeature is ArcGISFeature ---- How to Convert Feature to ArcGISFeature mAttributeID = mSelectedArcGISFeature.getAttributes().get("objectid").toString(); // get the number of attachments final ListenableFuture<List<Attachment>> attachmentResults = mSelectedArcGISFeature.fetchAttachmentsAsync(); attachmentResults.addDoneListener(new Runnable() { @Override public void run() { try { attachments = attachmentResults.get(); Log.d("number of attachments :", attachments.size() + ""); // show callout with the value for the attribute "typdamage" of the selected feature mSelectedArcGISFeatureAttributeValue = (String) mSelectedArcGISFeature.getAttributes().get("typdamage"); if (progressDialog.isShowing()) { progressDialog.dismiss(); } showCallout(mSelectedArcGISFeatureAttributeValue, attachments.size(),mapPoint); Toast.makeText(MainActivity.this, getApplication().getString(R.string.info_button_message), Toast.LENGTH_SHORT).show(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } }); } else { Toast.makeText(MainActivity.this, "No states found with name: " + searchString, Toast.LENGTH_SHORT).show(); } } catch (Exception e) { Toast.makeText(MainActivity.this, "Feature search failed for: " + searchString + ". Error=" + e.getMessage(), Toast.LENGTH_SHORT).show(); Log.e(getResources().getString(R.string.app_name), "Feature search failed for: " + searchString + ". Error=" + e.getMessage()); } } }); }
I have implemented given below code and the issue got resolved now
mSelectedArcGISFeature = (ArcGISFeature)result.iterator().next();