fork download
  1. /* aqui vai o nome do seu pacote */
  2.  
  3. import android.os.Bundle;
  4. import android.support.v4.app.Fragment;
  5. import android.text.Html;
  6. import android.util.Log;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.AdapterView;
  11. import android.widget.AutoCompleteTextView;
  12. import android.widget.TextView;
  13. import android.widget.Toast;
  14.  
  15. import com.google.android.gms.common.ConnectionResult;
  16. import com.google.android.gms.common.api.GoogleApiClient;
  17. import com.google.android.gms.common.api.PendingResult;
  18. import com.google.android.gms.common.api.ResultCallback;
  19. import com.google.android.gms.location.places.Place;
  20. import com.google.android.gms.location.places.PlaceBuffer;
  21. import com.google.android.gms.location.places.Places;
  22. import com.google.android.gms.maps.model.LatLng;
  23. import com.google.android.gms.maps.model.LatLngBounds;
  24.  
  25. public class AutoFragment extends Fragment implements
  26. GoogleApiClient.OnConnectionFailedListener,
  27. GoogleApiClient.ConnectionCallbacks {
  28. private static final String LOG_TAG = AutoFragment.class.getSimpleName();
  29. private static final int GOOGLE_API_CLIENT_ID = 0;
  30. private AutoCompleteTextView mAutocompleteTextView;
  31. private TextView mNameTextView;
  32. private TextView mAddressTextView;
  33. private TextView mIdTextView;
  34. private TextView mPhoneTextView;
  35. private TextView mWebTextView;
  36. private TextView mAttTextView;
  37. private GoogleApiClient mGoogleApiClient;
  38. private PlaceArrayAdapter mPlaceArrayAdapter;
  39. private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
  40. new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
  41.  
  42. @Override
  43. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  44. View view = inflater.inflate(R.layout.layout_fragment, container);
  45.  
  46. mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
  47. .addApi(Places.GEO_DATA_API)
  48. .enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, this)
  49. .addConnectionCallbacks(this)
  50. .build();
  51. mAutocompleteTextView = (AutoCompleteTextView) view.findViewById(R.id
  52. .autoCompleteTextView);
  53. mAutocompleteTextView.setThreshold(3);
  54. mNameTextView = (TextView) view.findViewById(R.id.name);
  55. mAddressTextView = (TextView) view.findViewById(R.id.address);
  56. mIdTextView = (TextView) view.findViewById(R.id.place_id);
  57. mPhoneTextView = (TextView) view.findViewById(R.id.phone);
  58. mWebTextView = (TextView) view.findViewById(R.id.web);
  59. mAttTextView = (TextView) view.findViewById(R.id.att);
  60. mAutocompleteTextView.setOnItemClickListener(mAutocompleteClickListener);
  61. mPlaceArrayAdapter = new PlaceArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
  62. BOUNDS_MOUNTAIN_VIEW, null);
  63. mAutocompleteTextView.setAdapter(mPlaceArrayAdapter);
  64.  
  65. return view;
  66. }
  67.  
  68. private AdapterView.OnItemClickListener mAutocompleteClickListener
  69. = new AdapterView.OnItemClickListener() {
  70. @Override
  71. public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  72. final PlaceArrayAdapter.PlaceAutocomplete item = mPlaceArrayAdapter.getItem(position);
  73. final String placeId = String.valueOf(item.placeId);
  74. Log.i(LOG_TAG, "Selected: " + item.description);
  75. PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
  76. .getPlaceById(mGoogleApiClient, placeId);
  77. placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
  78. Log.i(LOG_TAG, "Fetching details for ID: " + item.placeId);
  79. }
  80. };
  81.  
  82. private ResultCallback<PlaceBuffer> mUpdatePlaceDetailsCallback
  83. = new ResultCallback<PlaceBuffer>() {
  84. @Override
  85. public void onResult(PlaceBuffer places) {
  86. if (!places.getStatus().isSuccess()) {
  87. Log.e(LOG_TAG, "Place query did not complete. Error: " +
  88. places.getStatus().toString());
  89. return;
  90. }
  91. // Selecting the first object buffer.
  92. final Place place = places.get(0);
  93. CharSequence attributions = places.getAttributions();
  94.  
  95. mNameTextView.setText(Html.fromHtml(place.getName() + ""));
  96. mAddressTextView.setText(Html.fromHtml(place.getAddress() + ""));
  97. mIdTextView.setText(Html.fromHtml(place.getId() + ""));
  98. mPhoneTextView.setText(Html.fromHtml(place.getPhoneNumber() + ""));
  99. mWebTextView.setText(place.getWebsiteUri() + "");
  100. if (attributions != null) {
  101. mAttTextView.setText(Html.fromHtml(attributions.toString()));
  102. }
  103. }
  104. };
  105.  
  106. @Override
  107. public void onConnected(Bundle bundle) {
  108. mPlaceArrayAdapter.setGoogleApiClient(mGoogleApiClient);
  109. Log.i(LOG_TAG, "Google Places API connected.");
  110.  
  111. }
  112.  
  113. @Override
  114. public void onConnectionFailed(ConnectionResult connectionResult) {
  115. Log.e(LOG_TAG, "Google Places API connection failed with error code: "
  116. + connectionResult.getErrorCode());
  117.  
  118. Toast.makeText(getActivity(),
  119. "Google Places API connection failed with error code:" +
  120. connectionResult.getErrorCode(),
  121. Toast.LENGTH_LONG).show();
  122. }
  123.  
  124. @Override
  125. public void onConnectionSuspended(int i) {
  126. mPlaceArrayAdapter.setGoogleApiClient(null);
  127. Log.e(LOG_TAG, "Google Places API connection suspended.");
  128. }
  129. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:25: error: class AutoFragment is public, should be declared in a file named AutoFragment.java
public class AutoFragment extends Fragment implements
       ^
Main.java:3: error: package android.os does not exist
import android.os.Bundle;
                 ^
Main.java:4: error: package android.support.v4.app does not exist
import android.support.v4.app.Fragment;
                             ^
Main.java:5: error: package android.text does not exist
import android.text.Html;
                   ^
Main.java:6: error: package android.util does not exist
import android.util.Log;
                   ^
Main.java:7: error: package android.view does not exist
import android.view.LayoutInflater;
                   ^
Main.java:8: error: package android.view does not exist
import android.view.View;
                   ^
Main.java:9: error: package android.view does not exist
import android.view.ViewGroup;
                   ^
Main.java:10: error: package android.widget does not exist
import android.widget.AdapterView;
                     ^
Main.java:11: error: package android.widget does not exist
import android.widget.AutoCompleteTextView;
                     ^
Main.java:12: error: package android.widget does not exist
import android.widget.TextView;
                     ^
Main.java:13: error: package android.widget does not exist
import android.widget.Toast;
                     ^
Main.java:15: error: package com.google.android.gms.common does not exist
import com.google.android.gms.common.ConnectionResult;
                                    ^
Main.java:16: error: package com.google.android.gms.common.api does not exist
import com.google.android.gms.common.api.GoogleApiClient;
                                        ^
Main.java:17: error: package com.google.android.gms.common.api does not exist
import com.google.android.gms.common.api.PendingResult;
                                        ^
Main.java:18: error: package com.google.android.gms.common.api does not exist
import com.google.android.gms.common.api.ResultCallback;
                                        ^
Main.java:19: error: package com.google.android.gms.location.places does not exist
import com.google.android.gms.location.places.Place;
                                             ^
Main.java:20: error: package com.google.android.gms.location.places does not exist
import com.google.android.gms.location.places.PlaceBuffer;
                                             ^
Main.java:21: error: package com.google.android.gms.location.places does not exist
import com.google.android.gms.location.places.Places;
                                             ^
Main.java:22: error: package com.google.android.gms.maps.model does not exist
import com.google.android.gms.maps.model.LatLng;
                                        ^
Main.java:23: error: package com.google.android.gms.maps.model does not exist
import com.google.android.gms.maps.model.LatLngBounds;
                                        ^
Main.java:25: error: cannot find symbol
public class AutoFragment extends Fragment implements
                                  ^
  symbol: class Fragment
Main.java:26: error: package GoogleApiClient does not exist
        GoogleApiClient.OnConnectionFailedListener,
                       ^
Main.java:27: error: package GoogleApiClient does not exist
        GoogleApiClient.ConnectionCallbacks {
                       ^
Main.java:30: error: cannot find symbol
    private AutoCompleteTextView mAutocompleteTextView;
            ^
  symbol:   class AutoCompleteTextView
  location: class AutoFragment
Main.java:31: error: cannot find symbol
    private TextView mNameTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:32: error: cannot find symbol
    private TextView mAddressTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:33: error: cannot find symbol
    private TextView mIdTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:34: error: cannot find symbol
    private TextView mPhoneTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:35: error: cannot find symbol
    private TextView mWebTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:36: error: cannot find symbol
    private TextView mAttTextView;
            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:37: error: cannot find symbol
    private GoogleApiClient mGoogleApiClient;
            ^
  symbol:   class GoogleApiClient
  location: class AutoFragment
Main.java:38: error: cannot find symbol
    private PlaceArrayAdapter mPlaceArrayAdapter;
            ^
  symbol:   class PlaceArrayAdapter
  location: class AutoFragment
Main.java:39: error: cannot find symbol
    private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
                         ^
  symbol:   class LatLngBounds
  location: class AutoFragment
Main.java:43: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                             ^
  symbol:   class LayoutInflater
  location: class AutoFragment
Main.java:43: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                                                      ^
  symbol:   class ViewGroup
  location: class AutoFragment
Main.java:43: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                                                                           ^
  symbol:   class Bundle
  location: class AutoFragment
Main.java:43: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
           ^
  symbol:   class View
  location: class AutoFragment
Main.java:68: error: package AdapterView does not exist
    private AdapterView.OnItemClickListener mAutocompleteClickListener
                       ^
Main.java:82: error: cannot find symbol
    private ResultCallback<PlaceBuffer> mUpdatePlaceDetailsCallback
            ^
  symbol:   class ResultCallback
  location: class AutoFragment
Main.java:82: error: cannot find symbol
    private ResultCallback<PlaceBuffer> mUpdatePlaceDetailsCallback
                           ^
  symbol:   class PlaceBuffer
  location: class AutoFragment
Main.java:107: error: cannot find symbol
    public void onConnected(Bundle bundle) {
                            ^
  symbol:   class Bundle
  location: class AutoFragment
Main.java:114: error: cannot find symbol
    public void onConnectionFailed(ConnectionResult connectionResult) {
                                   ^
  symbol:   class ConnectionResult
  location: class AutoFragment
Main.java:39: error: cannot find symbol
    private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
                                                                 ^
  symbol:   class LatLngBounds
  location: class AutoFragment
Main.java:40: error: cannot find symbol
            new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
                ^
  symbol:   class LatLng
  location: class AutoFragment
Main.java:40: error: cannot find symbol
            new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
                                                    ^
  symbol:   class LatLng
  location: class AutoFragment
Main.java:42: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:44: error: cannot find symbol
        View view = inflater.inflate(R.layout.layout_fragment, container);
        ^
  symbol:   class View
  location: class AutoFragment
Main.java:44: error: package R does not exist
        View view = inflater.inflate(R.layout.layout_fragment, container);
                                      ^
Main.java:48: error: cannot find symbol
                .enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, this)
                                  ^
  symbol:   method getActivity()
  location: class AutoFragment
Main.java:47: error: cannot find symbol
                .addApi(Places.GEO_DATA_API)
                        ^
  symbol:   variable Places
  location: class AutoFragment
Main.java:46: error: package GoogleApiClient does not exist
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                                              ^
Main.java:46: error: cannot find symbol
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                                                       ^
  symbol:   method getActivity()
  location: class AutoFragment
Main.java:51: error: cannot find symbol
        mAutocompleteTextView = (AutoCompleteTextView) view.findViewById(R.id
                                 ^
  symbol:   class AutoCompleteTextView
  location: class AutoFragment
Main.java:51: error: package R does not exist
        mAutocompleteTextView = (AutoCompleteTextView) view.findViewById(R.id
                                                                          ^
Main.java:54: error: cannot find symbol
        mNameTextView = (TextView) view.findViewById(R.id.name);
                         ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:54: error: package R does not exist
        mNameTextView = (TextView) view.findViewById(R.id.name);
                                                      ^
Main.java:55: error: cannot find symbol
        mAddressTextView = (TextView) view.findViewById(R.id.address);
                            ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:55: error: package R does not exist
        mAddressTextView = (TextView) view.findViewById(R.id.address);
                                                         ^
Main.java:56: error: cannot find symbol
        mIdTextView = (TextView) view.findViewById(R.id.place_id);
                       ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:56: error: package R does not exist
        mIdTextView = (TextView) view.findViewById(R.id.place_id);
                                                    ^
Main.java:57: error: cannot find symbol
        mPhoneTextView = (TextView) view.findViewById(R.id.phone);
                          ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:57: error: package R does not exist
        mPhoneTextView = (TextView) view.findViewById(R.id.phone);
                                                       ^
Main.java:58: error: cannot find symbol
        mWebTextView = (TextView) view.findViewById(R.id.web);
                        ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:58: error: package R does not exist
        mWebTextView = (TextView) view.findViewById(R.id.web);
                                                     ^
Main.java:59: error: cannot find symbol
        mAttTextView = (TextView) view.findViewById(R.id.att);
                        ^
  symbol:   class TextView
  location: class AutoFragment
Main.java:59: error: package R does not exist
        mAttTextView = (TextView) view.findViewById(R.id.att);
                                                     ^
Main.java:61: error: cannot find symbol
        mPlaceArrayAdapter = new PlaceArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
                                 ^
  symbol:   class PlaceArrayAdapter
  location: class AutoFragment
Main.java:61: error: cannot find symbol
        mPlaceArrayAdapter = new PlaceArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
                                                   ^
  symbol:   method getActivity()
  location: class AutoFragment
Main.java:61: error: package android.R does not exist
        mPlaceArrayAdapter = new PlaceArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
                                                                           ^
Main.java:69: error: package AdapterView does not exist
            = new AdapterView.OnItemClickListener() {
                             ^
Main.java:83: error: cannot find symbol
            = new ResultCallback<PlaceBuffer>() {
                  ^
  symbol:   class ResultCallback
  location: class AutoFragment
Main.java:83: error: cannot find symbol
            = new ResultCallback<PlaceBuffer>() {
                                 ^
  symbol:   class PlaceBuffer
  location: class AutoFragment
Main.java:106: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:109: error: cannot find symbol
        Log.i(LOG_TAG, "Google Places API connected.");
        ^
  symbol:   variable Log
  location: class AutoFragment
Main.java:113: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:115: error: cannot find symbol
        Log.e(LOG_TAG, "Google Places API connection failed with error code: "
        ^
  symbol:   variable Log
  location: class AutoFragment
Main.java:118: error: cannot find symbol
        Toast.makeText(getActivity(),
                       ^
  symbol:   method getActivity()
  location: class AutoFragment
Main.java:121: error: cannot find symbol
                Toast.LENGTH_LONG).show();
                ^
  symbol:   variable Toast
  location: class AutoFragment
Main.java:118: error: cannot find symbol
        Toast.makeText(getActivity(),
        ^
  symbol:   variable Toast
  location: class AutoFragment
Main.java:124: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:127: error: cannot find symbol
        Log.e(LOG_TAG, "Google Places API connection suspended.");
        ^
  symbol:   variable Log
  location: class AutoFragment
82 errors
stdout
Standard output is empty