Created
May 21, 2016 22:00
-
-
Save nohe427/f34f74ae84915ad1796bf5987471ebbd to your computer and use it in GitHub Desktop.
updateFeature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ashleyandalexander.esri.addafeature; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import com.esri.android.map.MapView; | |
import com.esri.android.map.ags.ArcGISFeatureLayer; | |
import com.esri.core.geodatabase.GeodatabaseEditError; | |
import com.esri.core.geodatabase.GeodatabaseFeature; | |
import com.esri.core.geodatabase.GeodatabaseFeatureServiceTable; | |
import com.esri.core.geometry.Point; | |
import com.esri.core.map.CallbackListener; | |
import com.esri.core.map.Feature; | |
import com.esri.core.map.FeatureResult; | |
import com.esri.core.table.TableException; | |
import com.esri.core.tasks.query.QueryParameters; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
public class MainActivity extends AppCompatActivity { | |
GeodatabaseFeatureServiceTable gdb; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Log.e("NOHE", "TEST"); | |
gdb = new GeodatabaseFeatureServiceTable("https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/NoheLayer2/FeatureServer/", 0); | |
gdb.setFeatureRequestMode(GeodatabaseFeatureServiceTable.FeatureRequestMode.ON_INTERACTION_CACHE); | |
gdb.initialize(new CallbackListener<GeodatabaseFeatureServiceTable.Status>() { | |
@Override | |
public void onCallback(GeodatabaseFeatureServiceTable.Status status) { | |
if (status == GeodatabaseFeatureServiceTable.Status.INITIALIZED) { | |
Log.e("NOHE", "TEST"); | |
Feature feature = null; | |
try { | |
QueryParameters qp = new QueryParameters(); | |
qp.setWhere("1=1"); | |
gdb.queryFeatures(qp, new CallbackListener<FeatureResult>() { | |
@Override | |
public void onCallback(FeatureResult objects) { | |
long x = objects.featureCount(); | |
long z = gdb.getNumberOfFeatures(); | |
Log.e("NOHE", ""+z); | |
try { | |
Feature feature1 = gdb.getFeature(1); | |
Map<String, Object> attr = feature1.getAttributes(); | |
attr.put("MyNumber", 999); | |
gdb.updateFeature(1, attr); | |
gdb.applyEdits(new CallbackListener<List<GeodatabaseEditError>>() { | |
@Override | |
public void onCallback(List<GeodatabaseEditError> geodatabaseEditErrors) { | |
} | |
@Override | |
public void onError(Throwable throwable) { | |
} | |
}); | |
} catch (TableException e) { | |
e.printStackTrace(); | |
} | |
} | |
@Override | |
public void onError(Throwable throwable) { | |
} | |
}); | |
/*Map<String, Object> attributes = new HashMap<String, Object>(); | |
attributes.put("MyNumber", 1); | |
GeodatabaseFeature gdbFeature = new GeodatabaseFeature(attributes, new Point(0,0), gdb); | |
long id = gdb.addFeature(gdbFeature); | |
gdb.applyEdits(new CallbackListener<List<GeodatabaseEditError>>() { | |
@Override | |
public void onCallback(List<GeodatabaseEditError> geodatabaseEditErrors) { | |
for(GeodatabaseEditError editError : geodatabaseEditErrors) { | |
Log.e("NOHE", editError.toString()); | |
} | |
} | |
@Override | |
public void onError(Throwable throwable) { | |
} | |
}); | |
Log.e("NOHE", ""+id);*/ | |
} catch (Exception e) { | |
e.printStackTrace(); | |
Log.e("NOHE", e.getMessage()); | |
} | |
} | |
} | |
@Override | |
public void onError(Throwable throwable) { | |
Log.e("NOHE", throwable.getMessage()); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment