package com.example.GPS_DB02;


import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Display_datas_run extends Activity 
{

	Button btn_maps;
	
	DB_GPS db;
	private SQLiteDatabase dataBase;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.display_datas_run_layout);
		
		db = new DB_GPS(getApplicationContext());
		
		Bundle extras = getIntent().getExtras();
		String run_name = extras.getString("run_name");
		Toast.makeText(Display_datas_run.this, run_name, Toast.LENGTH_LONG).show();	
		
		// chargement des datas
		
		String requete = "SELECT * FROM table_run"; //  WHERE name = " + run_name ;
 	
		Cursor Cursor = db.DB_query(requete);
		int val = Cursor.getCount();
		
		if(val != 0)
		{
				if (Cursor.moveToFirst()) 
				{
 					do 
 					{
 							/*
							sid = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_ID_RUN ));
	 						titre = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_NAME_RUN ));
	 						start_timestamp = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_DATE_RUN ));
	 						end_timestamp = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_START_RUN ));
	 						phone = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_STOP_RUN ));
	 						
	 						
	 						option_delai = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_STEPS_COUNT_RUN ));
	 						option_vibrate = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_MODE_RUN ));
	 						option_ringtone = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_CALORIES_RUN ));

	 						
	 						notes = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_VITESSE_MOYENNE_RUN ));
	 						status = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_DISTANCE_RUN ));
	 						creation = Cursor.getString(Cursor.getColumnIndex(DBHelper.COLUMN_DURATION_RUN ));
	 						*/
	 						
 					} while (Cursor.moveToNext());
 					
				}
		}
		
	
		
		db.query(run_name);
		
		
	
		
	
		
		btn_maps = (Button) findViewById(R.id.btn_maps);    
		btn_maps.setOnClickListener(new OnClickListener() 
		{

				@Override
				public void onClick(View arg0) 
				{
					Intent Intent = new Intent(Display_datas_run.this, GPS_tracker_maps02.class);
		  			startActivity(Intent);
				}

		});
		
	}
}