Search in sources :

Example 1 with OnBitmapResponseListener

use of app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener 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)

Aggregations

Dialog (android.app.Dialog)1 ContentValues (android.content.ContentValues)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ArrayAdapter (android.widget.ArrayAdapter)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 GooglePlaceSearch (app.akexorcist.gdaplibrary.GooglePlaceSearch)1 OnBitmapResponseListener (app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener)1 OnPlaceResponseListener (app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener)1 ArrayList (java.util.ArrayList)1 Document (org.w3c.dom.Document)1