package com.example.patrice.http01;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import java.io.File;
import android.view.View.OnClickListener;

//http://www.dev2qa.com/android-listview-example/

public class activity02 extends AppCompatActivity
{
    Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10, btn11;
    ImageView img;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity02);

        btn1 = (Button) findViewById(R.id.btn1);
        btn2 = (Button) findViewById(R.id.btn2);
        btn3 = (Button) findViewById(R.id.btn3);
        btn4 = (Button) findViewById(R.id.btn4);
        btn5 = (Button) findViewById(R.id.btn5);
        btn6 = (Button) findViewById(R.id.btn6);
        btn7 = (Button) findViewById(R.id.btn7);
        btn8 = (Button) findViewById(R.id.btn8);
        btn9 = (Button) findViewById(R.id.btn9);
        btn10 = (Button) findViewById(R.id.btn10);
        btn11 = (Button) findViewById(R.id.btn11);

        btn1.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                Toast.makeText(getApplicationContext(), "Display image stored in sdcard", Toast.LENGTH_LONG).show();
                tools01 id = new tools01();
                id.download_image();

                // on affiche l'image qui a été telechargée
                String filepath = "/sdcard/pippo.jpg";
                File imagefile = new File(filepath);
                Bitmap bitmap = BitmapFactory.decodeFile(filepath);
                img = (ImageView)findViewById(R.id.imageView);

                img.setImageBitmap(bitmap);

            }
        });

        btn2.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //////////// OK /////////
                String url = "http://analog-design.net/WORKAREA/WEBSITE/Codebar/http_request.php?data=75";

                tools01 id = new tools01();
                id.new http_request().execute(new String[] { url });
                //OuterMainClass outer = new OuterMainClass();
                //outer.new InnerAsyncClass(param).execute();

            }
        });

        btn3.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                Intent myIntent = new Intent(activity02.this, AsyncResponse01.class);
                startActivity(myIntent);

            }
        });

        btn4.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                String URL = "http://analog-design.net/WORKAREA/WEBSITE/Codebar/pdf.pdf";
                new DownloadTask(activity02.this, URL);


            }
        });

        btn5.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, cam_capture05.class);
                //Intent myIntent = new Intent(activity02.this, upload03.class);
                startActivity(myIntent);

            }
        });

        btn6.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, DownloadFile.class);
                startActivity(myIntent);

            }
        });

        btn7.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, ListViewItem01.class);
                startActivity(myIntent);

            }
        });

        btn8.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, listview01.class);
                startActivity(myIntent);

            }
        });

        btn9.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, listview02.class);
                startActivity(myIntent);

            }
        });

        btn10.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, listview03.class);
                startActivity(myIntent);

            }
        });


        btn11.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //Intent myIntent = new Intent(activity02.this, android_asynchro.class);
                Intent myIntent = new Intent(activity02.this, listview04.class);
                startActivity(myIntent);

            }
        });

  /*
        // dowload image
        btn1.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                Toast.makeText(getApplicationContext(), "Display image stored in sdcard", Toast.LENGTH_LONG).show();
                tools01 id = new tools01();
                id.download_image();


                String filepath = "/sdcard/pippo.jpg";
                File imagefile = new File(filepath);
                Bitmap bitmap = BitmapFactory.decodeFile(filepath);
                img = (ImageView)findViewById(R.id.imageView);

                img.setImageBitmap(bitmap);




            }
        });
*/
        /*
        btn2.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                //////////// OK /////////
                String url = "http://analog-design.net/WORKAREA/WEBSITE/Codebar/http_request.php?data=75";

               // tools01 id = new tools01();
                //id.new http_request().execute(new String[] { url });
                //OuterMainClass outer = new OuterMainClass();
                //outer.new InnerAsyncClass(param).execute();



            }
        });
*/




    }

}