package com.camera.simplemjpeg;

import java.io.File;
import java.sql.Date;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;


public class browser extends Activity
{
	
	private File currentDir;
	
	public void onCreate(Bundle savedInstanceState) 
	{
			super.onCreate(savedInstanceState);
			setContentView(R.layout.browser);
			
			currentDir = new File("/sdcard/");
	        fill(currentDir); 
	}
	
	private void fill(File f)
    {
    		File[]dirs = f.listFiles(); 
    		//this.setTitle("Current Dir: "+f.getName());
    		List<class_browser>dir = new ArrayList<class_browser>();
    		List<class_browser>fls = new ArrayList<class_browser>();
		 
    		try{
    				for(File ff: dirs)
    				{ 
    					Date lastModDate = new Date(ff.lastModified()); 
    					DateFormat formater = DateFormat.getDateTimeInstance();
    					String date_modify = formater.format(lastModDate);
    					if(ff.isDirectory())
    					{
    						File[] fbuf = ff.listFiles(); 
    						int buf = 0;
    						if(fbuf != null)
    						{ 
    							buf = fbuf.length;
    						} 
					
    						else buf = 0; 
    							String num_item = String.valueOf(buf);
					
    						if(buf == 0) num_item = num_item + " item";
								else num_item = num_item + " items";
					
    						//String formated = lastModDate.toString();
    						dir.add(new class_browser(ff.getName(),num_item,date_modify,ff.getAbsolutePath(),"directory_icon")); 
    					}
    					else
    					{
							fls.add(new class_browser(ff.getName(),ff.length() + " Byte", date_modify, ff.getAbsolutePath(),"file_icon"));
    					}
    				}
    				
		 }
    		
    	 catch(Exception e)
		 {    
			 
		 }

    
    }
	
}
	

