Search in sources :

Example 1 with OnPlaceResponseListener

use of app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity3 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_1);
    textStatus = (TextView) findViewById(R.id.textStatus);
    listView = (ListView) findViewById(R.id.listView);
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            textStatus.setText("Status : " + status);
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                ArrayList<String> array = new ArrayList<String>();
                final ArrayList<String> array_photo = new ArrayList<String>();
                for (int i = 0; i < arr_data.size(); i++) {
                    array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
                    array_photo.add(arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHOTO));
                }
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity3.this, R.layout.listview_text, array);
                listView.setAdapter(adapter);
                listView.setOnItemClickListener(new OnItemClickListener() {

                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        Dialog dialog = new Dialog(PlaceActivity3.this);
                        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        dialog.setContentView(R.layout.dialog_photo);
                        dialog.setCancelable(true);
                        final ImageView imgPhoto = (ImageView) dialog.findViewById(R.id.imgPhoto);
                        dialog.show();
                        gp.getPhotoBitmapByWidth(array_photo.get(arg2), 600, "", new OnBitmapResponseListener() {

                            public void onResponse(Bitmap bm, String tag) {
                                imgPhoto.setImageBitmap(bm);
                            }
                        });
                    }
                });
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language, keyword);
}
Also used : ContentValues(android.content.ContentValues) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) Document(org.w3c.dom.Document) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Bitmap(android.graphics.Bitmap) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) Dialog(android.app.Dialog) AdapterView(android.widget.AdapterView) OnBitmapResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener) ImageView(android.widget.ImageView) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with OnPlaceResponseListener

use of app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity1 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_1);
    textStatus = (TextView) findViewById(R.id.textStatus);
    listView = (ListView) findViewById(R.id.listView);
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            textStatus.setText("Status : " + status);
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                ArrayList<String> array = new ArrayList<String>();
                for (int i = 0; i < arr_data.size(); i++) {
                    array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
                }
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity1.this, R.layout.listview_text, array);
                listView.setAdapter(adapter);
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language, keyword);
//gp.getTextSearch(keyword, type, false, language);
//gp.getRadarSearch(latitude, longitude, radius, type, language, false, keyword);
}
Also used : ContentValues(android.content.ContentValues) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) ArrayList(java.util.ArrayList) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) Document(org.w3c.dom.Document) ArrayAdapter(android.widget.ArrayAdapter)

Example 3 with OnPlaceResponseListener

use of app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity2 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_2);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            Toast.makeText(getApplicationContext(), status, Toast.LENGTH_SHORT).show();
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                for (int i = 0; i < arr_data.size(); i++) {
                    String title = arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME);
                    double lat = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LATITUDE);
                    double lng = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LONGITUDE);
                    LatLng pos = new LatLng(lat, lng);
                    mMap.addMarker(new MarkerOptions().position(pos).title(title));
                }
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language);
//gp.getRadarSearch(latitude, longitude, radius, type, language, false);
}
Also used : ContentValues(android.content.ContentValues) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) LatLng(com.google.android.gms.maps.model.LatLng) Document(org.w3c.dom.Document)

Aggregations

ContentValues (android.content.ContentValues)3 GooglePlaceSearch (app.akexorcist.gdaplibrary.GooglePlaceSearch)3 OnPlaceResponseListener (app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener)3 Document (org.w3c.dom.Document)3 ArrayAdapter (android.widget.ArrayAdapter)2 ArrayList (java.util.ArrayList)2 Dialog (android.app.Dialog)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 OnBitmapResponseListener (app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener)1 LatLng (com.google.android.gms.maps.model.LatLng)1 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)1