package org.leoly.guglefile.activities;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
import org.leoly.guglefile.R;
import org.leoly.guglefile.threads.ManageFileThread;
import org.leoly.guglefile.threads.ZipFileThread;
import org.leoly.guglefile.utils.GugleConstants;
import org.leoly.guglefile.utils.GugleUtils;
import org.leoly.guglefile.utils.ZipTool;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
/**
* <pre>
* </pre>
* @author 255507
* @version 1.0, 2012-2-22
*/
public class GugleFileActivity extends Activity
{
// 列表数据集合 27
private ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
// 列表界面视图
private ListView listView;
// 列表数据与视图的适配器
private SimpleAdapter adapter;
// 目录层级的堆栈
private Stack<String> folderStack = new Stack<String>();
// 当前的目录
private String nowFolder;
// 返回次数,当为2时,退出软件
private int backIndex = 1;
// 是否是升序
private boolean isAsc = true;
// 共享属性的名称
private final String GUGLE_FILE_SET = "GUGLE_FILE";
private final String GF_SET_LIST_TYPE = "LIST_TYPE";
private SharedPreferences setting = null;
private ProgressDialog progressDialog;
private String fileManagePath;
private int fileOption = -1;
private ImageButton paseBtn;
private final int LIST_BY = 0;
private final int ALL_DELETE = 1;
private final int ALL_COPY = 2;
private final int ALL_MOVE = 3;
private final int ABOUT_APP = 4;
private final int CLOSE_APP = 5;
private final Animation animation = new AlphaAnimation(1, 0);
private final String OPEN_TAG = "OPEN_FILE";
private String TEMP_BASE = null;
// 处理文件转移数据
private Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
Bundle bundle = msg.getData();
int exitType = bundle.getInt("EXIT_TYPE");
if (exitType == 0)
{
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.optionSuccess));
}
else
{
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.optionFail));
}
freshList(nowFolder, setting.getInt(GF_SET_LIST_TYPE, GugleConstants.SORT_BY_WORD));
paseBtn.setVisibility(ImageButton.INVISIBLE);
setFileOption(-1);
progressDialog.dismiss();
}
};
// 处理压缩返回信息
private Handler zipHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
Bundle bundle = msg.getData();
int exitType = bundle.getInt("OPTION_STATUS");
switch (exitType)
{
case ZipTool.EXIST_UNZIPFILE:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.existunzipfile));
break;
case ZipTool.EXIST_ZIPFILE:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.existzipfile));
break;
case ZipTool.NOTEXIST_ZIPFILE:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.notexistzipfile));
break;
case ZipTool.NULL_ZIPPATH:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.nullinputzipfile));
break;
case ZipTool.ZIPOPTION_FAIL:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.optionFail));
break;
default:
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.optionSuccess));
break;
}
freshList(nowFolder, setting.getInt(GF_SET_LIST_TYPE, GugleConstants.SORT_BY_WORD));
progressDialog.dismiss();
}
};
// 处理文件信息数据
private Handler attrHandler = new Handler()
{
@Override
public void handleMessage(final Message msg)
{
Bundle bundle = msg.getData();
int exitType = bundle.getInt("EXIT_TYPE");
if (exitType == 0)
{
// 彈出輸入框
AlertDialog.Builder builder = new AlertDialog.Builder(GugleFileActivity.this);
builder.setIcon(android.R.drawable.btn_star_big_on).setTitle(R.string.fileinfo);
LayoutInflater flater = LayoutInflater.from(GugleFileActivity.this);
LinearLayout builderLayout = (LinearLayout) flater.inflate(R.layout.fileinfo, null);
File file = new File(getFileManagePath());
TextView filePathView = (TextView) builderLayout.findViewById(R.id.filePathText);
String filePath = file.getAbsolutePath();
filePathView.setText(filePath);
TextView fileNameView = (TextView) builderLayout.findViewById(R.id.fileNameText);
fileNameView.setText(file.getName());
TextView fileSizeView = (TextView) builderLayout.findViewById(R.id.fileSizeText);
TextView fileModifyView = (TextView) builderLayout.findViewById(R.id.fileModifyText);
fileModifyView.setText(GugleUtils.formatDate(file.lastModified()));
TextView fileCountView = (TextView) builderLayout.findViewById(R.id.fileCountText);
if (file.isDirectory())
{
String[] files = file.list();
fileCountView.setText(String.valueOf(files.length));
fileSizeView.setText(bundle.getString("FILE_SIZE"));
}
else
{
fileCountView.setText(String.valueOf(1));
fileSizeView.setText(GugleUtils.getFileSize(file.length()));
}
builder.setView(builderLayout);
builder.setNegativeButton(R.string.close_rss_menu, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
freshList(nowFolder, setting.getInt(GF_SET_LIST_TYPE, GugleConstants.SORT_BY_WORD));
dialog.dismiss();
}
});
builder.create();
builder.show();
setFileManagePath(null);
}
else
{
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.optionFail));
}
progressDialog.dismiss();
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = getIntent();
String openPath = intent.getStringExtra(OPEN_TAG);
File sdFile = null;
if (GugleUtils.isEmpty(openPath))
{
// 取得SD卡要目录的文件
sdFile = GugleUtils.getSDFile();
if (null == sdFile)
{
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.no_sdcard));
return;
}
}
else
{
sdFile = new File(openPath);
if (!sdFile.exists())
{
GugleUtils.showMessage(GugleFileActivity.this, getString(R.string.nofile));
return;
}
}
String basePath = sdFile.getAbsolutePath();
TEMP_BASE = sdFile.getAbsolutePath();
// 初始化配置對象
initSetting(basePath);
folderStack.setSize(25);
folderStack.clear();
pushData(basePath);
setNowFolder(basePath);
if (null == listView)
{
listView = (ListView) findViewById(R.id.fileList);
}
listView.setCacheColorHint(0);
listView.setOnItemClickListener(new OnItem
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android文件管理器demo,支持压缩解压,适合Android初学者学习Android文件存储模块 (249个子文件)
all-wcprops 3KB
all-wcprops 1KB
all-wcprops 582B
all-wcprops 408B
all-wcprops 388B
all-wcprops 381B
all-wcprops 369B
all-wcprops 262B
all-wcprops 254B
all-wcprops 192B
all-wcprops 97B
all-wcprops 91B
all-wcprops 91B
all-wcprops 87B
all-wcprops 85B
all-wcprops 81B
all-wcprops 81B
all-wcprops 80B
all-wcprops 77B
all-wcprops 77B
all-wcprops 77B
resources.ap_ 530KB
GugleFile.apk 555KB
proguard.cfg 1KB
GugleFileActivity.class 23KB
GugleUtils.class 7KB
ZipTool.class 5KB
ManageFileThread.class 4KB
GugleFileActivity$3.class 4KB
GugleFileActivity$19.class 3KB
GugleFileActivity$17.class 3KB
GugleFileActivity$13.class 3KB
GugleFileActivity$12.class 3KB
GugleFileActivity$14.class 2KB
ZipFileThread.class 2KB
R$string.class 2KB
NotePadActivity.class 2KB
GugleFileActivity$11.class 2KB
GugleFileActivity$16.class 2KB
GugleFileActivity$1.class 2KB
GugleFileActivity$2.class 2KB
GugleFileActivity$21.class 2KB
GugleFileActivity$3$1.class 2KB
GugleFileActivity$5.class 1KB
GugleFileActivity$4.class 1KB
GugleFileActivity$23.class 1KB
GugleUtils$2.class 1KB
R$id.class 1KB
R$drawable.class 1KB
GugleFileActivity$9.class 1KB
GugleFileActivity$18.class 1KB
GugleFileActivity$22.class 1KB
GugleFileActivity$6.class 991B
GugleFileActivity$15.class 976B
GugleFileActivity$20.class 955B
GugleFileActivity$10.class 927B
GugleFileActivity$8.class 891B
GugleFileActivity$7.class 891B
GugleUtils$1.class 832B
R.class 538B
R$layout.class 493B
GugleConstants.class 363B
R$attr.class 343B
SureBtnClickEvent.class 220B
.classpath 364B
Thumbs.db 62KB
classes.dex 47KB
entries 4KB
entries 2KB
entries 1KB
entries 777B
entries 704B
entries 672B
entries 571B
entries 470B
entries 416B
entries 380B
entries 297B
entries 274B
entries 251B
entries 237B
entries 227B
entries 225B
entries 225B
entries 221B
entries 219B
entries 214B
entries 211B
GugleFileActivity.java 32KB
GugleUtils.java 8KB
ZipTool.java 7KB
R.java 7KB
ManageFileThread.java 3KB
ZipFileThread.java 2KB
NotePadActivity.java 2KB
SureBtnClickEvent.java 715B
GugleConstants.java 556B
hs_err_pid4416.log 4KB
hblue_bg.png 306KB
hblue_bg.png 246KB
共 249 条
- 1
- 2
- 3
资源评论
skymhzh
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功