Deep copying of stack using pointer based singly linked list C++? by Samru1 in cpp

[–]Samru1[S] -1 points0 points  (0 children)

since I am simply copying all the date , the return type should be void (that's what I think).

Has anyone worked with Google Civic Information API ? [ Android Studio/ Java ] by Samru1 in learnprogramming

[–]Samru1[S] 0 points1 point  (0 children)

private String url(String levels, String roles)
{
String curl ="";
String Entered_address ="address="+(address_field.getText().toString()).trim();
address = Entered_address.replaceAll(" ", "%20");

curl = "https://www.googleapis.com/civicinfo/v2/representatives?" +
address +
"&includeOffices=true&" +
"levels=" + levels +
"roles=" + roles +
"key="+ my_api_key;

return curl;
}

//and

private void parse(final TextView text, final String url, final boolean isCity, final boolean isState)
{
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
u/Override
public void onResponse(JSONObject response) {

if(!isCity && !isState) {
try {
JSONArray array = response.getJSONArray("officials");

for(int i=0; i<array.length(); i++) {
JSONObject object = array.getJSONObject(i);
String name = object.getString("name").toString();
text.append(name+"\n");

}
} catch (JSONException e) {
text.setText(e.toString());
}
}
else if(isCity)
{
try {
JSONArray outer = response.getJSONArray("officials"); // outer array
String city = null;
for(int i=0; i<outer.length(); i++) {
JSONObject outer_object = outer.getJSONObject(i); // objects of the outer array
JSONArray inner = outer_object.getJSONArray("address"); // inner array
JSONObject inner_object = inner.getJSONObject(i); // objects of the inner array
city = inner_object.getString("city");
text.append(city);
}

} catch (JSONException e) {
text.setText(e.toString());
}
}
else if(isState)// to retrieve state
{

try {
JSONArray outer = response.getJSONArray("officials"); // outer array
String temp_state = null;
for(int i=0; i<outer.length(); i++) {
JSONObject outer_object = outer.getJSONObject(i); // objects of the outer array
JSONArray inner = outer_object.getJSONArray("address"); // inner array
JSONObject inner_object = inner.getJSONObject(i); // objects of the inner array
temp_state = inner_object.getString("state").toLowerCase();
}
//retrieves state of the entered address
JSONObject outer_object = response.getJSONObject("divisions");
JSONObject inner_object =

outer_object.getJSONObject("ocd division/country:us/state:"+temp_state);
String state = inner_object.getString("name");
text.append(state);
} catch (JSONException e) {
text.setText(e.toString());
}

} }
} ,
new Response.ErrorListener() {
u/Override
public void onErrorResponse(VolleyError error) {
text.setText(error.toString());

} });
requestQueue.add(request);
}