package com.example.patrice.rerservation01;

import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.util.Pair;
import android.widget.Toast;

public class Selection_jeu extends Activity
{
    Button btnEmprunter;
    Button btnRetour;

    String pid;

    private static final String TAG_ID = "id";


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.selection_jeu_layout);

        btnEmprunter = (Button) findViewById(R.id.btnEmprunter);
        btnRetour = (Button) findViewById(R.id.btnRetour);
        EditText inputName = (EditText) findViewById(R.id.inputName);

        Intent i = getIntent();
        pid = i.getStringExtra(TAG_ID);

        inputName.setText(pid);

        btnEmprunter.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View arg0)
            {
                confirm_emprunter_dialog();
            }
        });

        btnRetour.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View arg0)
            {
                finish();
            }
        });

    }

    private void confirm_emprunter_dialog()
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Confirmation de l'emprunt !");
        builder.setMessage("Voulez-vous vraiment emprunter ce jeu ?");
        builder.setCancelable(false);

        builder.setPositiveButton("Oui", new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Toast.makeText(getApplicationContext(), "La réservation est validée", Toast.LENGTH_LONG).show();
            }
        });

        builder.setNegativeButton("Non", new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Toast.makeText(getApplicationContext(), "Abandon", Toast.LENGTH_SHORT).show();
            }
        });

        builder.show();
    }





}