package com.appli.gui;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.ListView;

import com.appli.patoche.R;

import java.io.File;
//import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class main_image extends ListActivity  
{
	
	private File currentDir;
	//private FileArrayAdapter adapter; 
	
	private List<String> fileList = new ArrayList<String>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);

		setContentView(R.layout.grid_image_layout);
		//https://diptimayapatra.wordpress.com/2013/07/08/xamarin-display-single-image-in-imageview-from-sd-card-in-android/
		
		//http://www.androidbegin.com/tutorial/android-display-images-from-sd-card-tutorial/
		//http://tutorial4android.com/android_file_folder.php
		
		//http://windrealm.org/tutorials/android/android-listview.php
		//http://www.techrepublic.com/blog/software-engineer/android-coders-guide-to-browsing-external-storage/
			
		//https://developer.xamarin.com/recipes/android/data/files/browse_files/
		
		//currentDir = new File("/sdcard/");	
		
		File dir = Environment.getExternalStorageDirectory(); 
		File[] files = dir.listFiles();
		
		
		try 
		  {
			  	for (File ff : files) 
			  	{
			  		String name = ff.getName();
			  		long taille = ff.length();
		    
			  		
			  	}
		  } 
		  
		  catch (Exception e)
		  {

		  }
		
		//File root = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
		//ListDir(root);
		
	}
	
	
	
	
	/*
	void ListDir(File f)
	{
	     File[] files = f.listFiles();
	     fileList.clear();
	     for (File file : files)
	     {
	      fileList.add(file.getPath());  
	     }
	      
	     ArrayAdapter<String> directoryList  = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, fileList);
	     setListAdapter(directoryList); 
	    }
	*/
	
	private void fill(File f) 
	{
		  File[] dirs = f.listFiles();
		  //this.setTitle("Current Dir: " + f.getName());
		  List dir = new ArrayList();
		  List fls = new ArrayList();
		  
		  try 
		  {
			  	for (File ff : dirs) 
			  	{
			  		String name = ff.getName();
			  		long taille = ff.length();
		    
			  		
			  	}
		  } 
		  
		  catch (Exception e)
		  {

		  }
		  
	 }
	
	
	
	
}