package br.com.adley.myseriesproject;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;

import br.com.adley.tvmaze.GetTVShowJsonData;

public class MainActivity extends AppCompatActivity {

    private ListView idSeriesList;
    private Button idSearchButton;
    private EditText idInputNameSerie;
    private static final String APIURL="http://api.tvmaze.com";

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

        idSearchButton = (Button) findViewById(R.id.idSearchButton);
        idInputNameSerie = (EditText) findViewById(R.id.idInputNameSerie);

        idSearchButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (idInputNameSerie.getText().toString().isEmpty()) {
                        Toast.makeText(MainActivity.this, "ERRO: Insira um nome", Toast.LENGTH_SHORT).show();
                    }else {
                        //String url = APIURL + "/search/shows?q=" + idInputNameSerie.getText().toString();
                        Toast.makeText(MainActivity.this, "Buscando...", Toast.LENGTH_LONG).show();
                        GetTVShowJsonData jsonData = new GetTVShowJsonData(idInputNameSerie.getText().toString());
                        jsonData.execute();
                    }
                }
            });
    }
    /*
    public class JSONTask extends AsyncTask<String,String,List<String> > {
        @Override
        protected List<String> doInBackground(String... params) {

            BufferedReader reader = null;
            HttpURLConnection connection = null;
            try {
                URL reqURL = new URL(params[0]);
                connection = (HttpURLConnection) (reqURL.openConnection());
                connection.connect();
                //connection.setRequestMethod("GET");
                InputStream in = new BufferedInputStream(connection.getInputStream());

                reader = new BufferedReader(new InputStreamReader(in));
                String line;
                StringBuilder result = new StringBuilder();
                while ((line = reader.readLine()) != null) {
                    result.append(line);
                }
                String finalJson = result.toString();
                List<String> listNames = new ArrayList<String>();
                JSONArray jsonArray = new JSONArray(finalJson);
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonobject = jsonArray.getJSONObject(i);
                    JSONObject oneShowJsonObject = new JSONObject(jsonobject.toString());
                    JSONObject show = oneShowJsonObject.getJSONObject("show");
                    listNames.add(show.getString("name"));
                }

                return listNames;

            } catch (MalformedURLException e) {
                e.printStackTrace();
                Toast.makeText(MainActivity.this, "MalformedUrlException error", Toast.LENGTH_LONG).show();
            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(MainActivity.this, "IoException error", Toast.LENGTH_LONG).show();
            } catch (JSONException e) {
                e.printStackTrace();
                Toast.makeText(MainActivity.this, "JSONException error", Toast.LENGTH_LONG).show();
            } finally {
                try{
                    if (connection != null) {
                        connection.disconnect();
                    }
                    if (reader != null) {
                        reader.close();
                    }
                }catch (IOException e){
                    Toast.makeText(MainActivity.this, "Finally IOException error", Toast.LENGTH_LONG).show();
                }
                catch (Exception e){
                    Toast.makeText(MainActivity.this, "Finally Exception error", Toast.LENGTH_LONG).show();
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(final List<String> listNames) {
            super.onPostExecute(listNames);
            if(!listNames.isEmpty()) {
                idSeriesList = (ListView) findViewById(R.id.idSeriesList);
                ArrayAdapter<String> adaptador = new ArrayAdapter<String>(
                        getApplicationContext(),
                        android.R.layout.simple_list_item_2,
                        android.R.id.text2,
                        listNames
                );
                idSeriesList.setAdapter(adaptador);
                idSeriesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        Toast.makeText(MainActivity.this, listNames.get(position).toString() , Toast.LENGTH_SHORT).show();
                    }
                });
            }else{
                Toast.makeText(MainActivity.this, "Ocorreu um erro no onPostExecute", Toast.LENGTH_LONG).show();
            }
        }
    }
    */
}

@@ -506,17 +506,19 @@
 g APIURL
-=
+ = 
 %22http://
@@ -919,36 +919,32 @@
 ) %7B%0A            
-    
 @Override%0A      
@@ -929,36 +929,32 @@
       @Override%0A
-    
             publ
@@ -975,28 +975,24 @@
 k(View v) %7B%0A
-    
             
@@ -1062,36 +1062,32 @@
                 
-   
- 
 Toast.makeText(M
@@ -1168,29 +1168,26 @@
             
-    
 %7D
+ 
 else %7B%0A     
@@ -1201,20 +1201,16 @@
         
-  
-  
 //String
@@ -1297,36 +1297,32 @@
                 
-    
 Toast.makeText(M
@@ -1401,20 +1401,16 @@
         
- 
-   
 GetTVSho
@@ -1512,20 +1512,16 @@
         
-    
 jsonData
@@ -1544,34 +1544,26 @@
             
-    %7D%0A    
+%7D%0A
             
@@ -1564,36 +1564,32 @@
       %7D%0A        
-  
-  
 %7D);%0A    %7D%0A    /*
@@ -1586,3797 +1586,6 @@
   %7D%0A
-    /*%0A    public class JSONTask extends AsyncTask%3CString,String,List%3CString%3E %3E %7B%0A        @Override%0A        protected List%3CString%3E doInBackground(String... params) %7B%0A%0A            BufferedReader reader = null;%0A            HttpURLConnection connection = null;%0A            try %7B%0A                URL reqURL = new URL(params%5B0%5D);%0A                connection = (HttpURLConnection) (reqURL.openConnection());%0A                connection.connect();%0A                //connection.setRequestMethod(%22GET%22);%0A                InputStream in = new BufferedInputStream(connection.getInputStream());%0A%0A                reader = new BufferedReader(new InputStreamReader(in));%0A                String line;%0A                StringBuilder result = new StringBuilder();%0A                while ((line = reader.readLine()) != null) %7B%0A                    result.append(line);%0A                %7D%0A                String finalJson = result.toString();%0A                List%3CString%3E listNames = new ArrayList%3CString%3E();%0A                JSONArray jsonArray = new JSONArray(finalJson);%0A                for (int i = 0; i %3C jsonArray.length(); i++) %7B%0A                    JSONObject jsonobject = jsonArray.getJSONObject(i);%0A                    JSONObject oneShowJsonObject = new JSONObject(jsonobject.toString());%0A                    JSONObject show = oneShowJsonObject.getJSONObject(%22show%22);%0A                    listNames.add(show.getString(%22name%22));%0A                %7D%0A%0A                return listNames;%0A%0A            %7D catch (MalformedURLException e) %7B%0A                e.printStackTrace();%0A                Toast.makeText(MainActivity.this, %22MalformedUrlException error%22, Toast.LENGTH_LONG).show();%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A                Toast.makeText(MainActivity.this, %22IoException error%22, Toast.LENGTH_LONG).show();%0A            %7D catch (JSONException e) %7B%0A                e.printStackTrace();%0A                Toast.makeText(MainActivity.this, %22JSONException error%22, Toast.LENGTH_LONG).show();%0A            %7D finally %7B%0A                try%7B%0A                    if (connection != null) %7B%0A                        connection.disconnect();%0A                    %7D%0A                    if (reader != null) %7B%0A                        reader.close();%0A                    %7D%0A                %7Dcatch (IOException e)%7B%0A                    Toast.makeText(MainActivity.this, %22Finally IOException error%22, Toast.LENGTH_LONG).show();%0A                %7D%0A                catch (Exception e)%7B%0A                    Toast.makeText(MainActivity.this, %22Finally Exception error%22, Toast.LENGTH_LONG).show();%0A                %7D%0A            %7D%0A            return null;%0A        %7D%0A%0A        @Override%0A        protected void onPostExecute(final List%3CString%3E listNames) %7B%0A            super.onPostExecute(listNames);%0A            if(!listNames.isEmpty()) %7B%0A                idSeriesList = (ListView) findViewById(R.id.idSeriesList);%0A                ArrayAdapter%3CString%3E adaptador = new ArrayAdapter%3CString%3E(%0A                        getApplicationContext(),%0A                        android.R.layout.simple_list_item_2,%0A                        android.R.id.text2,%0A                        listNames%0A                );%0A                idSeriesList.setAdapter(adaptador);%0A                idSeriesList.setOnItemClickListener(new AdapterView.OnItemClickListener() %7B%0A                    @Override%0A                    public void onItemClick(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A                        Toast.makeText(MainActivity.this, listNames.get(position).toString() , Toast.LENGTH_SHORT).show();%0A                    %7D%0A                %7D);%0A            %7Delse%7B%0A                Toast.makeText(MainActivity.this, %22Ocorreu um erro no onPostExecute%22, Toast.LENGTH_LONG).show();%0A            %7D%0A        %7D%0A    %7D%0A    */%0A
 %7D%0A

Remove commented block