添加了implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.8.0'这个库用于解压文件

将 FileThread,FileHandler,NetThread,NetHandler四个半成品联系起来获取对应文件在数据库中的密码
数据流向:
主线程(文件路径)-->FileThread(MD5)-->FileHandler(MD5)-->NetThread(pwd)-->NetHandler(pwd)
master
ThankVinci 4 years ago
parent 08c03f4af8
commit 3f421d1d69

@ -36,6 +36,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment:2.2.2' implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2' implementation 'androidx.navigation:navigation-ui:2.2.2'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.15' implementation group: 'commons-codec', name: 'commons-codec', version: '1.15'
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.8.0'
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

@ -5,6 +5,9 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.widget.Toast; import android.widget.Toast;
import com.thankvinci.CloudKey.NetUtils.NetHandler;
import com.thankvinci.CloudKey.NetUtils.NetThread;
public class FileHandler extends Handler { public class FileHandler extends Handler {
//定义功能选择的常量 获取MD5和解压 //定义功能选择的常量 获取MD5和解压
final static int FUNCTION_GET_MD5 = 0; final static int FUNCTION_GET_MD5 = 0;
@ -12,15 +15,23 @@ public class FileHandler extends Handler {
private Activity activity; private Activity activity;
private Handler handler;
public FileHandler(Activity activity){ public FileHandler(Activity activity){
this.activity = activity; this.activity = activity;
} }
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
handler = new NetHandler(activity);
super.handleMessage(msg); super.handleMessage(msg);
switch (msg.what){ switch (msg.what){
case FUNCTION_GET_MD5: case FUNCTION_GET_MD5:
Toast.makeText(activity,msg.getData().getString("md5"),Toast.LENGTH_SHORT).show(); StringBuilder builder = new StringBuilder();
builder.append("http://1.14.144.194:8080/cscp/cscp?para0=query&para1=");
builder.append(msg.getData().getString("md5"));
String url = builder.toString();
Thread nt = new Thread(new NetThread(handler,url));
nt.start();
break; break;
} }
} }

@ -13,14 +13,14 @@ public class FileThread implements Runnable{
final static int FUNCTION_GET_MD5 = 0; final static int FUNCTION_GET_MD5 = 0;
final static int FUNCTION_DECOMPRESS = 1; final static int FUNCTION_DECOMPRESS = 1;
private String srcPath,desPath,md5; private String srcFile,desPath,md5;
private Handler handler; private Handler handler;
private int function; private int function;
public FileThread(Handler handler,String srcPath,String desPath,final int FUNCTION){ public FileThread(Handler handler,String srcFile,String desPath,final int FUNCTION){
this.handler = handler; this.handler = handler;
this.srcPath = srcPath; this.srcFile = srcFile;
this.desPath = desPath; this.desPath = desPath;
this.function = FUNCTION; this.function = FUNCTION;
} }
@ -31,7 +31,7 @@ public class FileThread implements Runnable{
switch (function){ switch (function){
case FUNCTION_GET_MD5: case FUNCTION_GET_MD5:
try { try {
md5 = FileUtils.getFileMD5(srcPath); md5 = FileUtils.getFileMD5(srcFile);
data.putString("md5",md5); data.putString("md5",md5);
msg.what = FUNCTION_GET_MD5; msg.what = FUNCTION_GET_MD5;
msg.setData(data); msg.setData(data);

@ -245,4 +245,14 @@ FileHandler负责将获取到的md5码发到NetThread,然后将得到的密码
**2021/6/12** **2021/6/12**
完成了子线程中获取md5并发到主线程的功能 完成了子线程中获取md5并发送到主线程的功能
**2021/6/12**
添加了implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.8.0'这个库用于解压文件
将 FileThread,FileHandler,NetThread,NetHandler四个半成品联系起来获取对应文件在数据库中的密码
数据流向:
主线程(文件路径)-->FileThread(MD5)-->FileHandler(MD5)-->NetThread(pwd)-->NetHandler(pwd)
Loading…
Cancel
Save