public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
nPath =
new
String(
"/storage/sdcard0/engdict/"
);
PathList_prev =
new
ArrayList<String>();
PathList_next =
new
ArrayList<String>();
makeFileList();
}
public
void
onConfigurationChanged(Configuration newConfig) {
super
.onConfigurationChanged(newConfig);
setContentView(R.layout.main);
makeFileList();
}
------------------------------------
public
void
updateFileList(String sPath) {
String ext = Environment.getExternalStorageState();
String path =
null
;
ListData temp;
int
type;
long
size =
0
;
String name;
if
(sPath ==
null
) {
if
(ext.equals(Environment.MEDIA_MOUNTED)) {
path = Environment.getExternalStorageDirectory().getAbsolutePath() +
"/"
;
}
else
{
path = Environment.MEDIA_UNMOUNTED;
}
}
else
{
path = sPath;
}
dirText.setText(path);
nPath = path;
File files =
new
File(path);
if
(files.listFiles().length ==
0
)
{
path =
"/storage/extSdCard/Data/"
;
dirText.setText(path);
nPath = path;
files =
new
File(path);
}
arrayList =
new
ArrayList<ListData>();
if
(files.listFiles().length ==
0
) {
updateFileList(
null
);
}
if
(files.listFiles().length >=
0
) {
for
(File file : files.listFiles()) {
name = file.getName();
if
(file.getName().endsWith(
".mpg"
)
||file.getName().endsWith(
".avi"
)
||file.getName().endsWith(
".wmv"
)
||file.getName().endsWith(
".asf"
)
||file.getName().endsWith(
".mp4"
)
||file.getName().endsWith(
".mkv"
)
||file.getName().endsWith(
".m4v"
)
||file.getName().endsWith(
".3gp"
)) {
type =
1
;
size = file.length();
temp =
new
ListData(type, name, size);
arrayList.add(temp);
}
}
}
adapter =
new
GroupAdapter(
this
,R.layout.listview,arrayList);
fileList.setAdapter(adapter);
}
private
class
GroupAdapter
extends
ArrayAdapter<Object> {
private
ArrayList<ListData> item;
private
ListData temp;
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
GroupAdapter(Context ctx,
int
resourceID, ArrayList item) {
super
(ctx, resourceID, item);
this
.item = item;
}
public
View getView(
int
position, View convertView, ViewGroup parent) {
View v = convertView;
if
(v ==
null
) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.listview,
null
);
}
temp = item.get(position);
Bitmap image = ThumbnailUtils.createVideoThumbnail(nPath+temp.getname(), android.provider.MediaStore.Video.Thumbnails.MICRO_KIND);
if
(temp ==
null
){
}
if
(temp !=
null
) {
ImageView icon = (ImageView)v.findViewById(R.id.imageView1);
TextView name = (TextView)v.findViewById(R.id.textView1);
TextView size = (TextView)v.findViewById(R.id.textView2);
switch
(temp.gettype()) {
case
0
:
icon.setImageResource(R.drawable.folder_horizontal);
break
;
case
1
:
icon.setImageBitmap(image);
break
;
case
2
:
icon.setImageResource(R.drawable.application_blue);
break
;
default
:
icon.setImageResource(R.drawable.document);
break
;
}
name.setText(temp.getname());
if
(temp.gettype() ==
0
) {
size.setText(
"(폴더)"
);
}
else
{
size.setText(
"("
+ byteTranslater(temp.getsize()) +
")"
);
}
}
return
v;
}
}
8000
이 max라 부분부분 넣었습니다.