package es.craftsmanship.toledo.katangapp.activities;

import android.app.Activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;

/**
 * @author Cristóbal Hermida
 */
public class MainActivity extends Activity {

    private SeekBar seekBar;
    private TextView txtKatangaLabel;
    private ImageView button;
    private TextView txtradiolabel;
    private ProgressBar progressBar;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        initializeVariables();

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            int progress = 0;

            @Override
            public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {

                progress = progresValue;

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

                // Toast.makeText(getApplicationContext(), "Radio de búsqueda", Toast.LENGTH_SHORT).show();
                //se debe poner el valor más vistoso

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

                txtradiolabel.setText(String.valueOf(progress));

            }
        });



    }

    // A private method to help us initialize our variables.
    private void initializeVariables() {

        // text view label
        txtKatangaLabel = (TextView) findViewById(R.id.title_katanga);
        seekBar = (SeekBar) findViewById(R.id.seekBar);
        txtradiolabel = (TextView)findViewById(R.id.txtradiolabel);
        button = (ImageView) findViewById(R.id.button);
        progressBar = (ProgressBar) findViewById(R.id.progressBar1);


    }

}
@@ -97,17 +97,103 @@
 oid.
-os.Bundle
+content.Intent;%0Aimport android.os.AsyncTask;%0Aimport android.os.Bundle;%0Aimport android.view.View
 ;%0Aim
@@ -322,16 +322,166 @@
 tView;%0A%0A
+import java.io.BufferedReader;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0A%0A
 /**%0A * @
@@ -1660,23 +1660,1743 @@
  %7D);%0A%0A%0A%0A
-
     %7D%0A%0A
+    // AsyncTask %3CTypeOfVarArgParams , ProgressValue , ResultValue%3E .%0A    private class ServiceConnectionTask extends AsyncTask%3CString, Integer, String%3E %7B%0A%0A        @Override%0A        protected void onPreExecute() %7B%0A%0A            progressBar.setVisibility(View.VISIBLE);%0A            super.onPreExecute();%0A        %7D%0A%0A        @Override%0A        protected void onProgressUpdate(Integer... values) %7B%0A            super.onProgressUpdate(values);%0A%0A        %7D%0A%0A        @Override%0A        protected String doInBackground(String... urls) %7B%0A            String response = %22%22;%0A            String s = null;%0A            URL url;%0A            HttpURLConnection urlConnection = null;%0A            try %7B%0A                url = new URL(urls%5B0%5D);%0A%0A                urlConnection = (HttpURLConnection) url.openConnection();%0A%0A                InputStream in = urlConnection.getInputStream();%0A%0A                BufferedReader buffer = new BufferedReader(new InputStreamReader(in));%0A%0A                while ((s = buffer.readLine()) != null) %7B%0A                    response += s;%0A                %7D%0A%0A            %7D catch (Exception e) %7B%0A                e.printStackTrace();%0A            %7D finally %7B%0A                if (urlConnection != null) %7B%0A                    urlConnection.disconnect();%0A                %7D%0A            %7D%0A%0A            return response;%0A        %7D%0A%0A        @Override%0A        protected void onPostExecute(String result) %7B%0A            progressBar.setVisibility(View.INVISIBLE);%0A            Intent intent = new Intent(MainActivity.this, ShowStopsActivity.class);%0A            intent.putExtra(%22stopslist%22,result);%0A            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);%0A            getApplicationContext().startActivity(intent);%0A        %7D%0A    %7D%0A%0A%0A
     // A

add async task to call rest service