<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Move a point of ArcGISFeatureLayer with onDragPointerMove in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423339#M2877</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gakumin, Just a quick follow-up. Your approach is a good work-around for now, as it turns out you cannot freeze/unfreeze the map in the current SDK. I've entered an enhancement request and discussed with the Android team. As part of the enhancement request I added that there should also be a sample to demonstrate the functionality.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Jul 2013 15:22:37 GMT</pubDate>
    <dc:creator>AndyGup</dc:creator>
    <dc:date>2013-07-31T15:22:37Z</dc:date>
    <item>
      <title>Move a point of ArcGISFeatureLayer with onDragPointerMove</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423335#M2873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been having a hard time to implement drag and drop a point of ArcGISFeatureLayer for a couple days...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using these listeners: onDragPointerMove and onDragPointerUp.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ultimately, what I would like to do is, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. grab a point from selected ArcGISFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. move it with "drag and drop", which is intuitive way&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. update the location of the point with "applyEdits(...)"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Therefore, suggestions on completely different approaches are also more than appreciated)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are two issues I would like the forum to help me out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem 1: My code works in emulator. But it does NOT on an actual device... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But, once I run a code in debugging mode line by line, then it works on my actual device... This means there might be some issues related to processing time or network communication time?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem 2: Once the program does not detect any point to move, I would like to overwrite listener to default, which is pan of map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I defined that by "setDefaultTouchListener" in my code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Current my program stays stuck in drag and drop listener forever after it failed to grab a point to move... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//This method is called when "Move" button is clicked 
 public void movepoint_OnClick(View v) {
&amp;nbsp; if (!mMapView.isLoaded()) {
&amp;nbsp;&amp;nbsp; return;
&amp;nbsp; }

&amp;nbsp; Toast t = Toast.makeText(getApplicationContext(),
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Drag a point to move",
&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast.LENGTH_LONG);
&amp;nbsp; t.show();
&amp;nbsp; 
&amp;nbsp; //Start drag listener to move a point
&amp;nbsp; myTouchListener = new MyTouchListener(this, mMapView);
&amp;nbsp; mMapView.setOnTouchListener(myTouchListener);
&amp;nbsp; 
 }
 // Set drag listener
 // onDragPointerMove on map causes movement of a point
 public class MyTouchListener extends MapOnTouchListener {
&amp;nbsp; 
&amp;nbsp; private SimpleMarkerSymbol _simpleMarkerSymbol;
&amp;nbsp; private Point startPoint = null;
&amp;nbsp; private Point endpoint = null;
&amp;nbsp; private Proximity2DResult targetPoint_2DResult = null;
&amp;nbsp; private Point targetPoint = null;
&amp;nbsp; private HashMap&amp;lt;String, Object&amp;gt; attributes = new HashMap&amp;lt;String, Object&amp;gt;();
&amp;nbsp; private int[] number;
&amp;nbsp; private Graphic gr;

&amp;nbsp; public MyTouchListener(Context context, MapView view) {
&amp;nbsp;&amp;nbsp; super(context, view);
&amp;nbsp;&amp;nbsp; // TODO Auto-generated constructor stub
&amp;nbsp;&amp;nbsp; _simpleMarkerSymbol = new SimpleMarkerSymbol(Color.RED, 4, STYLE.CIRCLE);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; /**
&amp;nbsp;&amp;nbsp; * Clears all drawing graphics.
&amp;nbsp;&amp;nbsp; */
&amp;nbsp; public void clearDrawGraphicsLayer(){
&amp;nbsp;&amp;nbsp; graphicsLayer.removeAll();
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; public boolean onDragPointerMove(MotionEvent from, MotionEvent to) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; endpoint = mMapView.toMapPoint(to.getX(), to.getY());
&amp;nbsp;&amp;nbsp; startPoint = mMapView.toMapPoint(from.getX(), from.getY());&amp;nbsp; 
&amp;nbsp;&amp;nbsp; number = featureLayer.getGraphicIDs(from.getX(), from.getY(), 20);

///////Currently, every time I tried to grab a point with "featureLayer.getGraphicIDs(from.getX(), from.getY(), 20)" above,
///////then the program goes to "number.length == 0" and show the toast, and stuck there forever...
///////
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if (number.length == 0){
&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast.makeText(getApplicationContext(), "Please grab a point. Click 'Move' again for retry", Toast.LENGTH_SHORT).show();&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if (number.length &amp;gt; 0){
&amp;nbsp;&amp;nbsp;&amp;nbsp; gr = featureLayer.getGraphic(number[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; attributes = (HashMap&amp;lt;String, Object&amp;gt;) gr.getAttributes();
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; return super.onDragPointerMove(from, to);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; @Override
&amp;nbsp; public boolean onDragPointerUp(MotionEvent from, MotionEvent to) {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; /*
&amp;nbsp;&amp;nbsp;&amp;nbsp; * When user releases finger, add the last point to polyline.
&amp;nbsp;&amp;nbsp;&amp;nbsp; */
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if (number.length == 0){
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if (number.length &amp;gt; 0){
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Graphic updatePoint = new Graphic(endpoint, null, attributes, null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Conduct Update feature layer on the background
&amp;nbsp;&amp;nbsp;&amp;nbsp; new updateMovePoint(updatePoint).execute();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Restores the MapOnTouchListener to its default 
&amp;nbsp;&amp;nbsp;&amp;nbsp; setDefaultTouchListener();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; return super.onDragPointerUp(from, to);
&amp;nbsp; }
&amp;nbsp; 

&amp;nbsp; /**
&amp;nbsp;&amp;nbsp; * Restores the MapOnTouchListener to its default 
&amp;nbsp;&amp;nbsp; */
&amp;nbsp; public void setDefaultTouchListener(){
&amp;nbsp;&amp;nbsp; MapOnTouchListener ml = new MapOnTouchListener(getApplicationContext(), mMapView);
&amp;nbsp;&amp;nbsp; mMapView.setOnTouchListener(ml);
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; 
 }

 private class updateMovePoint extends AsyncTask&amp;lt;Void, Void, Void&amp;gt;{
&amp;nbsp; private Graphic updatePoint;
&amp;nbsp; 
&amp;nbsp; public updateMovePoint(Graphic updatePoint){
&amp;nbsp;&amp;nbsp; super();
&amp;nbsp;&amp;nbsp; this.updatePoint = updatePoint; 
&amp;nbsp; }

&amp;nbsp; @Override
&amp;nbsp; protected Void doInBackground(Void... params) {
&amp;nbsp;&amp;nbsp; // TODO Auto-generated method stub
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; featureLayer.applyEdits(null, null, new Graphic[]{updatePoint}, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new CallbackListener&amp;lt;FeatureEditResult[][]&amp;gt;() {

&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void onCallback(FeatureEditResult[][] arg0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO Auto-generated method stub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Log.e(TAG, "applyEdits onCallback #obs: " 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + arg0.length);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void onError(Throwable e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO Auto-generated method stub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Log.e(TAG, "apply Edits onError",e); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; 
&amp;nbsp;&amp;nbsp; });&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //Remove all graphics
&amp;nbsp;&amp;nbsp; graphicsLayer.removeAll();
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; return null;
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; @Override
&amp;nbsp; protected void onPostExecute(Void result) {
&amp;nbsp;&amp;nbsp; // TODO Auto-generated method stub
&amp;nbsp;&amp;nbsp; super.onPostExecute(result);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; Toast.makeText(getApplicationContext(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString(R.string.points_submitted),Toast.LENGTH_SHORT).show();
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; setDefaultTapActions();

&amp;nbsp; }
 }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions and comments are really appreciated...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gakumin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:27:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423335#M2873</guid>
      <dc:creator>GakuminKato</dc:creator>
      <dc:date>2021-12-12T16:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Move a point of ArcGISFeatureLayer with onDragPointerMove</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423336#M2874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gakumin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for problem #1, I agree. If the app only runs in debugger then there is an execution timing problem. Those are very hard to troubleshoot. Here is a blog post I wrote that shows a pattern for trying to narrow down execution timing and threading issues that may help: &lt;/SPAN&gt;&lt;A href="http://www.andygup.net/troubleshooting-multi-threading-problems-related-to-androids-onresume/"&gt;http://www.andygup.net/troubleshooting-multi-threading-problems-related-to-androids-onresume/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem #2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Double check the context that is being used in this line of code. You might change it to use getApplicationContext() rather than using "this". It's just a guess:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;myTouchListener = new MyTouchListener(this, mMapView);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also in your onDragPointerUp() method make sure it always returns to the default touch listener. It looked like it only returned to the default listener under certain circumstances.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jun 2013 14:17:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423336#M2874</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2013-06-25T14:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Move a point of ArcGISFeatureLayer with onDragPointerMove</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423337#M2875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Andy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for my late reply. I really appreciate your advice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, I could not figure out how to use the onDragPointerMove and onDragPointerUp. They did not work for my program at an actual device... Therefore, I compromised. In order to move a point, now my program asks a user to specify a point to move first. Then, the program asks again the user to specify a destination point with single tap. This is not fancy. But, it works at least...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If possible, I would like to have a sample application which shows how to move a point of featureservice with the onDragPointerMove and onDragPointerUp. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gakumin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 15:33:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423337#M2875</guid>
      <dc:creator>GakuminKato</dc:creator>
      <dc:date>2013-07-19T15:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Move a point of ArcGISFeatureLayer with onDragPointerMove</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423338#M2876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gakumin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good suggestion, I agree that would be a good sample to have. I'll pass the suggestion to the Android team.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2013 17:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423338#M2876</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2013-07-23T17:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Move a point of ArcGISFeatureLayer with onDragPointerMove</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423339#M2877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gakumin, Just a quick follow-up. Your approach is a good work-around for now, as it turns out you cannot freeze/unfreeze the map in the current SDK. I've entered an enhancement request and discussed with the Android team. As part of the enhancement request I added that there should also be a sample to demonstrate the functionality.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 15:22:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/move-a-point-of-arcgisfeaturelayer-with/m-p/423339#M2877</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2013-07-31T15:22:37Z</dc:date>
    </item>
  </channel>
</rss>

