package com.sirmvit.vtufest2k17;

import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.List;


public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {

    private GoogleMap mMap;
    public static final String TAG = MapsActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_map_activity, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_about) {
            return true;
        }
        if(id == R.id.action_setting) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near College.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap){
        mMap = googleMap;

        //style Map
        try {
            // Customise the styling of the base map using a JSON object defined
            // in a raw resource file.
            boolean success = googleMap.setMapStyle(
                    MapStyleOptions.loadRawResourceStyle(
                            this, R.raw.style_json));

            if (!success) {
                Log.e(TAG, "Style parsing failed.");
            }
        } catch (Resources.NotFoundException e) {
            Log.e(TAG, "Can't find style. Error: ", e);
        }

        //Marker icon - Breaks app
        Bitmap gpsMarker = BitmapFactory.decodeResource(getResources(),R.drawable.marker_vector);
        BitmapDescriptor iconGpsMaker = BitmapDescriptorFactory.fromBitmap(gpsMarker);

        //Place MArkers
        final List<MapsItem> list = MapsContent.ITEMS;
        for(int i=0; i<list.size();i++) {
            MapsItem current = list.get(i);
            mMap.addMarker(new MarkerOptions().position(current.position).title(current.title));
            if(i == 0) {
                CameraPosition cameraPosition = new CameraPosition.Builder()
                        .target(current.position)
                        .zoom(18)
                        .bearing(270)
                        .tilt(60)
                        .build();
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
            }
        }
    }

    @Override
    public void onBackPressed() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Are you sure you want to exit?")
                .setCancelable(false)
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        MapsActivity.this.finish();
                    }
                })
                .setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();

    }
}

@@ -374,16 +374,45 @@
 enuItem;
+%0Aimport android.widget.Toast;
 %0A%0Aimport
@@ -857,16 +857,65 @@
 ptions;%0A
+import com.google.android.gms.maps.model.Marker;%0A
 import c
@@ -1070,16 +1070,50 @@
 allback 
+, GoogleMap.OnMarkerClickListener 
 %7B%0A%0A    p
@@ -2331,16 +2331,17 @@
       if
+ 
 (id == R
@@ -3041,16 +3041,17 @@
 ogleMap)
+ 
 %7B%0A      
@@ -3070,16 +3070,60 @@
 gleMap;%0A
+        mMap.setOnMarkerClickListener(this);
 %0A       
@@ -3753,16 +3753,17 @@
 urces(),
+ 
 R.drawab
@@ -3963,20 +3963,25 @@
  for
+ 
 (int i
-=
+ = 
 0; i
-%3C
+ %3C 
 list
@@ -3988,16 +3988,17 @@
 .size();
+ 
 i++) %7B%0A 
@@ -4151,16 +4151,17 @@
       if
+ 
 (i == 0)
@@ -4544,32 +4544,225 @@
        %7D%0A    %7D%0A%0A
+    @Override%0A    public boolean onMarkerClick(Marker arg0) %7B%0A        Toast.makeText(MapsActivity.this, arg0.getTitle(), Toast.LENGTH_SHORT).show();// display toast%0A        return true;%0A    %7D%0A%0A
     @Override%0A  
@@ -5523,10 +5523,11 @@
 %0A%0A    %7D%0A
+%0A
 %7D%0A

Fix last commit