parent
d3948d704d
commit
08c03f4af8
@ -0,0 +1,27 @@
|
||||
package com.thankvinci.CloudKey.Utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class FileHandler extends Handler {
|
||||
//定义功能选择的常量 获取MD5和解压
|
||||
final static int FUNCTION_GET_MD5 = 0;
|
||||
final static int FUNCTION_DECOMPRESS = 1;
|
||||
|
||||
private Activity activity;
|
||||
|
||||
public FileHandler(Activity activity){
|
||||
this.activity = activity;
|
||||
}
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what){
|
||||
case FUNCTION_GET_MD5:
|
||||
Toast.makeText(activity,msg.getData().getString("md5"),Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.thankvinci.CloudKey.Utils;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.thankvinci.CloudKey.Files.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileThread implements Runnable{
|
||||
|
||||
final static int FUNCTION_GET_MD5 = 0;
|
||||
final static int FUNCTION_DECOMPRESS = 1;
|
||||
|
||||
private String srcPath,desPath,md5;
|
||||
private Handler handler;
|
||||
|
||||
private int function;
|
||||
|
||||
public FileThread(Handler handler,String srcPath,String desPath,final int FUNCTION){
|
||||
this.handler = handler;
|
||||
this.srcPath = srcPath;
|
||||
this.desPath = desPath;
|
||||
this.function = FUNCTION;
|
||||
}
|
||||
@Override
|
||||
public void run(){
|
||||
Message msg = new Message();
|
||||
Bundle data = new Bundle();
|
||||
switch (function){
|
||||
case FUNCTION_GET_MD5:
|
||||
try {
|
||||
md5 = FileUtils.getFileMD5(srcPath);
|
||||
data.putString("md5",md5);
|
||||
msg.what = FUNCTION_GET_MD5;
|
||||
msg.setData(data);
|
||||
handler.sendMessage(msg);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
case FUNCTION_DECOMPRESS:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.thankvinci.CloudKey.Utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
||||
public class MyUtils {
|
||||
public static void copyToClipboard(Activity activity,String str){
|
||||
ClipboardManager cmb = (ClipboardManager)activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(str);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue