package com.upmoon.alexanderbean.barcrawlr.fragments;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.upmoon.alexanderbean.barcrawlr.R;

import static android.app.Activity.RESULT_OK;

/**
 * A simple {@link Fragment} subclass.
 */
public class PlaceListFragment extends Fragment {
    private static final int PLACE_PICKER_REQUEST = 1;

    /*
    *   Update: added place picker button
    *   TODO: add places list to aggregate all places for the plan
    */
    public PlaceListFragment() {
        // Required empty public constructor
    }
}

@@ -767,31 +767,777 @@
    p
-rivate static final int
+ublic PlaceListFragment() %7B%0A        // Required empty public constructor%0A    %7D%0A%0A    @Override%0A    public View onCreateView(LayoutInflater inflater, ViewGroup container,%0A                             Bundle savedInstanceState) %7B%0A        // Inflate the layout for this fragment%0A        View v = inflater.inflate(R.layout.fragment_place_list, container, false);%0A%0A        final Button addPlaceButton = (Button) v.findViewById(R.id.add_place_button);%0A        addPlaceButton.setOnClickListener(new View.OnClickListener() %7B%0A            public void onClick(View v) %7B%0A                onPickButtonClick(v);%0A            %7D%0A        %7D);%0A%0A        return v;%0A    %7D%0A%0A    @Override%0A    public void onActivityResult(int requestCode, int resultCode, Intent data) %7B%0A        if (requestCode ==
  PLA
@@ -1557,179 +1557,611 @@
 UEST
- = 1;%0A%0A
+) %7B%0A  
     
-/*%0A
     
-*
   
- Update: added place picker button%0A    *   TODO: add places list to aggregate all places for the plan%0A    */%0A    public PlaceListFragment() %7B%0A
+if (resultCode == RESULT_OK) %7B%0A                Place place = PlacePicker.getPlace(getActivity(),data);%0A                String toastMsg = String.format(%22Place: %25s%22, place.getName());%0A                Toast.makeText(getActivity(), toastMsg, Toast.LENGTH_LONG).show();%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void onPickButtonClick(View v) %7B%0A        // Construct an intent for the place picker%0A        try %7B%0A            PlacePicker.IntentBuilder intentBuilder =%0A                    new PlacePicker.IntentBuilder();%0A            Intent intent = intentBuilder.build(getActivity());%0A  
         
 // R
@@ -2160,49 +2160,524 @@
     
+  
 // 
-Required empty public constructor
+Start the intent by requesting a result,%0A            // identified by a request code.%0A            startActivityForResult(intent, PLACE_PICKER_REQUEST);%0A%0A        %7D catch (GooglePlayServicesRepairableException e) %7B%0A            Toast.makeText(getActivity(), %22Google Play Services Repairable Exception%22, Toast.LENGTH_LONG).show();%0A        %7D catch (GooglePlayServicesNotAvailableException e) %7B%0A            Toast.makeText(getActivity(), %22Google Play Services Not Available%22, Toast.LENGTH_LONG).show();%0A        %7D
 %0A    %7D%0A
+%0A
 %7D%0A

Update PlaceListFragment.java