/* Copyright 2016 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.esri.arcgisruntime.sample.addgraphicsrenderer;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.SpatialReferences;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Map;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleRenderer;

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // inflate MapView from layout
        mMapView = (MapView) findViewById(R.id.mapView);
        // create a map with the Basemap Type topographic
        Map mMap = new Map(Basemap.Type.TOPOGRAPHIC, 15.169193, 16.333479, 2);
        // add graphics overlay
        addGraphicsOverlay();
        // set the map to be displayed in this view
        mMapView.setMap(mMap);
    }

    private void addGraphicsOverlay(){
        // point graphic
        Point pointGeometry = new Point(32.076, 34.979, SpatialReferences.getWebMercator());
        SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(Color.rgb(255, 0, 0), 30, SimpleMarkerSymbol.Style.DIAMOND);
        Graphic pointGraphic = new Graphic(pointGeometry);

        // create a graphic overlay for the point
        GraphicsOverlay pointGraphicOverlay = new GraphicsOverlay();
        // create simple renderer
        SimpleRenderer pointRenderer = new SimpleRenderer();
        pointRenderer.setSymbol(pointSymbol);
        pointGraphicOverlay.setRenderer(pointRenderer);
        // add graphic to overlay
        pointGraphicOverlay.getGraphics().add(pointGraphic);
        // add graphics overlay to the MapView
        mMapView.getGraphicsOverlays().add(pointGraphicOverlay);
    }

    @Override
    protected void onPause(){
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume(){
        super.onResume();
        mMapView.resume();
    }
}

@@ -794,16 +794,72 @@
 .Point;%0A
+import com.esri.arcgisruntime.geometry.PolylineBuilder;%0A
 import c
@@ -908,16 +908,16 @@
 rences;%0A
-
 import c
@@ -1162,16 +1162,74 @@
 apView;%0A
+import com.esri.arcgisruntime.symbology.SimpleLineSymbol;%0A
 import c
@@ -2080,22 +2080,18 @@
 int(
-32.076, 34.979
+40e5, 40e5
 , Sp
@@ -2125,16 +2125,55 @@
 tor());%0A
+        // yellow diamond point symbol%0A
         
@@ -2238,25 +2238,17 @@
 lor.
-rgb(255, 0, 0), 3
+YELLOW, 1
 0, S
@@ -2281,16 +2281,52 @@
 AMOND);%0A
+        // create graphic for point%0A
         
@@ -2376,17 +2376,16 @@
 metry);%0A
-%0A
         
@@ -2591,43 +2591,8 @@
 rer(
-);%0A        pointRenderer.setSymbol(
 poin
@@ -2795,24 +2795,24 @@
 the MapView%0A
-
         mMap
@@ -2860,24 +2860,919 @@
 icOverlay);%0A
+%0A        // line graphic%0A        PolylineBuilder lineGeometry = new PolylineBuilder(SpatialReferences.getWebMercator());%0A        lineGeometry.addPoint(-10e5, 40e5);%0A        lineGeometry.addPoint(20e5, 50e5);%0A        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 5);%0A        Graphic lineGraphic = new Graphic(lineGeometry.toGeometry());%0A        // create graphic overlay for polyline%0A        GraphicsOverlay lineGraphicOverlay = new GraphicsOverlay();%0A        // create simple renderer%0A        SimpleRenderer lineRenderer = new SimpleRenderer(lineSymbol);%0A        // add graphic to overlay%0A        lineGraphicOverlay.setRenderer(lineRenderer);%0A        // add graphic to overlay%0A        lineGraphicOverlay.getGraphics().add(lineGraphic);%0A        // add graphics overlay to the MapView%0A        mMapView.getGraphicsOverlays().add(lineGraphicOverlay);%0A%0A
     %7D%0A%0A    @

update point graphic, added polyline graphic