package com.paniaravindkv.ilovezappos;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

    EditText searchEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        searchEditText = (EditText) findViewById(R.id.searchEditText);
    }

    public void searchAction(View view) {

        String searchText = searchEditText.getText().toString();

        Log.i("INFO", "Search Button Tapped");
        Log.i("INFO", "Search Text - " + searchText);
    }
}

@@ -170,16 +170,201 @@
 ditText;
+%0Aimport android.widget.Toast;%0A%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0Aimport java.util.concurrent.ExecutionException;%0A%0A/**%0A * Created by Pani Aravind on 2/3/17.%0A */
 %0A%0Apublic
@@ -431,16 +431,47 @@
 ditText;
+%0A    DownloadTask downloadTask;
 %0A%0A    @O
@@ -862,16 +862,16 @@
 pped%22);%0A
-
         
@@ -911,21 +911,1070 @@
 searchText);
+%0A%0A        downloadTask = new DownloadTask();%0A%0A        String baseUrl = getString(R.string.api_base_url);%0A        String apiKey = getString(R.string.api_key);%0A%0A        String urlString = baseUrl + %22?term=%22 + searchText + %22&key=%22 + apiKey;%0A%0A        String result = %22%22;%0A%0A        Log.i(%22INFO%22, %22Search API URL - %22 + urlString);%0A%0A        try %7B%0A            result = downloadTask.execute(urlString).get();%0A%0A            Log.i(%22INFO%22, %22API call result - %22 + result);%0A%0A            JSONObject resultInJSON = new JSONObject(result);%0A%0A            Log.i(%22INFO%22, %22API call result count - %22 + resultInJSON.getString(%22currentResultCount%22));%0A%0A            if (resultInJSON.getString(%22currentResultCount%22).equals(%220%22)) %7B%0A%0A                Toast.makeText(getApplicationContext(), %22No results found!!%22, Toast.LENGTH_LONG).show();%0A            %7D%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D catch (ExecutionException e) %7B%0A            e.printStackTrace();%0A        %7D catch (JSONException e) %7B%0A            e.printStackTrace();%0A        %7D
 %0A    %7D%0A%7D%0A

call API and log result