|
|
@ -1,9 +1,6 @@
|
|
|
|
package com.thankvinci.CloudKey.Files;
|
|
|
|
package com.thankvinci.CloudKey.Files;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
@ -12,14 +9,12 @@ import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
|
|
|
|
|
|
|
import androidx.navigation.Navigation;
|
|
|
|
import androidx.navigation.Navigation;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
|
|
|
|
|
|
import com.thankvinci.CloudKey.Fragment.FileManageFragment;
|
|
|
|
import com.thankvinci.CloudKey.Fragment.FileManageFragment;
|
|
|
|
import com.thankvinci.CloudKey.R;
|
|
|
|
import com.thankvinci.CloudKey.R;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class FileAdapter extends RecyclerView.Adapter<FileAdapter.ViewHolder> {
|
|
|
|
public class FileAdapter extends RecyclerView.Adapter<FileAdapter.ViewHolder> {
|
|
|
@ -40,16 +35,6 @@ public class FileAdapter extends RecyclerView.Adapter<FileAdapter.ViewHolder> {
|
|
|
|
name = file.findViewById(R.id.file_name);
|
|
|
|
name = file.findViewById(R.id.file_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static FileAdapter getInstance(List<FileItem> fileList,Fragment fragment){
|
|
|
|
|
|
|
|
if(adapter != null){
|
|
|
|
|
|
|
|
return adapter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter = new FileAdapter(fileList,fragment);
|
|
|
|
|
|
|
|
return adapter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFileList(List<FileItem> fileList){
|
|
|
|
|
|
|
|
this.fileList = fileList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public FileAdapter(List<FileItem> fileList,Fragment fragment){
|
|
|
|
public FileAdapter(List<FileItem> fileList,Fragment fragment){
|
|
|
|
this.fileList = fileList;
|
|
|
|
this.fileList = fileList;
|
|
|
|
this.fragment = fragment;
|
|
|
|
this.fragment = fragment;
|
|
|
@ -65,14 +50,16 @@ public class FileAdapter extends RecyclerView.Adapter<FileAdapter.ViewHolder> {
|
|
|
|
public void onClick(View v){
|
|
|
|
public void onClick(View v){
|
|
|
|
int position = holder.getAdapterPosition();
|
|
|
|
int position = holder.getAdapterPosition();
|
|
|
|
FileItem fitem = fileList.get(position);
|
|
|
|
FileItem fitem = fileList.get(position);
|
|
|
|
Toast.makeText(v.getContext(),fitem.getName(),Toast.LENGTH_SHORT).show();
|
|
|
|
//Toast.makeText(v.getContext(),fitem.getName(),Toast.LENGTH_SHORT).show();
|
|
|
|
if(fitem.isDir()){
|
|
|
|
if(fitem.isDir()){
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
builder.append(((FileManageFragment)fragment).getDir());
|
|
|
|
builder.append(((FileManageFragment)fragment).getDir());
|
|
|
|
|
|
|
|
|
|
|
|
builder.append("/");
|
|
|
|
builder.append("/");
|
|
|
|
builder.append(fitem.getName());
|
|
|
|
builder.append(fitem.getName());
|
|
|
|
data.putString("dir",builder.toString());
|
|
|
|
data.putString("dir",builder.toString());
|
|
|
|
data.putBoolean("isRoot",false);
|
|
|
|
data.putBoolean("isRoot",false);
|
|
|
|
|
|
|
|
Toast.makeText(v.getContext(),data.getString("dir"),Toast.LENGTH_SHORT).show();
|
|
|
|
Navigation.findNavController(v).navigate(R.id.action_openDir,data);
|
|
|
|
Navigation.findNavController(v).navigate(R.id.action_openDir,data);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
Toast.makeText(v.getContext(),"没有打开除文件夹和压缩包以外的功能",Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(v.getContext(),"没有打开除文件夹和压缩包以外的功能",Toast.LENGTH_SHORT).show();
|
|
|
|