@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         Bundle savedInstanceState) {
   Bundle args = getArguments();
   double lats = args.getDouble(LATS, Lats);
   double logs = args.getDouble(LOGS, Logs);
    final Bundle bundle = new Bundle();
    bundle.putDouble(RestaurantAdapter.LATS, lats);
    bundle.putDouble(RestaurantAdapter.LOGS, logs);
     StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("https://maps.googleapis.com/maps/api/place/textsearch/json?");
RequestQueue requestQueue = Volley.newRequestQueue(RestaurantFragment.this.getContext().getApplicationContext());
JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.GET, stringBuilder.toString(),null,
        new Response.Listener<JSONObject>() {
            @Override
    public void onResponse(JSONObject response) {
       try {JSONArray jsonObject = response.getJSONArray("results");
            for (int i = 0; i <= response.length(); i++) {
                JSONObject jsonObject1 = jsonObject.getJSONObject(i);
                String name = jsonObject1.get("name").toString();
                String place = jsonObject1.get("formatted_address").toString();
                objforRest objforRest = new objforRest(name,place);
                arrayList1.add(objforRest);
            }
           Toast toast = Toast.makeText(RestaurantFragment.this.getContext(),arrayList1.toString(),Toast.LENGTH_LONG);
           toast.show();
        } catch (JSONException e) {
            e.printStackTrace();
        }
}
        },new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) { }
});
requestqueue.add(objectRequestj);
   RecyclerView videoRecycler = (RecyclerView) inflater.inflate(
                R.layout.fragment_restaurant2, container, false);
        videoRecycler.setHasFixedSize(true);
        RestaurantAdapter adapter = new RestaurantAdapter(bundle, RestaurantFragment.this.getContext(),arrayList1);
        videoRecycler.setAdapter(adapter);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        videoRecycler.setLayoutManager(layoutManager);
        return videoRecycler;
}
                       
                    
0 Answer(s)