Search in sources :

Example 1 with TreeFile

use of com.yydcdut.noteplugin.bean.TreeFile in project PhotoNoter by yydcdut.

the class FilePhotoAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(FilePhotoViewHolder holder, int position) {
    TreeFile treeFile = mCurrentNode.getChildren().get(position);
    if (treeFile.getChildren() == null) {
        //文件
        holder.mFileLayout.setVisibility(View.VISIBLE);
        holder.mDirNameTextView.setVisibility(View.GONE);
        holder.mFileNameTextView.setText(treeFile.getFileName());
        holder.mFileInfoTextView.setText(treeFile.getFileName());
    } else {
        //目录
        holder.mFileLayout.setVisibility(View.GONE);
        holder.mDirNameTextView.setVisibility(View.VISIBLE);
        holder.mDirNameTextView.setText(treeFile.getFileName());
    }
}
Also used : TreeFile(com.yydcdut.noteplugin.bean.TreeFile)

Example 2 with TreeFile

use of com.yydcdut.noteplugin.bean.TreeFile in project PhotoNoter by yydcdut.

the class FilePhotoFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    TreeFile root = PhotoModel.getInstance().findByPath();
    if (root != null) {
        mRecyclerView.setAdapter(new FilePhotoAdapter(root));
    } else {
        YLog.i("yuyidong", "root == null");
    }
}
Also used : TreeFile(com.yydcdut.noteplugin.bean.TreeFile) FilePhotoAdapter(com.yydcdut.noteplugin.adapter.FilePhotoAdapter)

Example 3 with TreeFile

use of com.yydcdut.noteplugin.bean.TreeFile in project PhotoNoter by yydcdut.

the class PhotoModel method findByPath.

public TreeFile findByPath() {
    if (!hasSDCard()) {
        return null;
    }
    TreeFile rootTreeFile = new FilePhoto(0, Environment.getExternalStorageDirectory().getAbsolutePath(), null);
    String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    ergodicFiles(rootTreeFile, new File(sdPath));
    return rootTreeFile;
}
Also used : FilePhoto(com.yydcdut.noteplugin.bean.FilePhoto) TreeFile(com.yydcdut.noteplugin.bean.TreeFile) File(java.io.File) TreeFile(com.yydcdut.noteplugin.bean.TreeFile)

Example 4 with TreeFile

use of com.yydcdut.noteplugin.bean.TreeFile in project PhotoNoter by yydcdut.

the class PhotoModel method ergodicFiles.

private void ergodicFiles(TreeFile root, File rootFile) {
    if (rootFile.isDirectory()) {
        for (File file : rootFile.listFiles()) {
            if (file.isDirectory()) {
                TreeFile child = new FilePhoto(root.getLevel() + 1, file.getName(), root);
                root.addChild(child);
                ergodicFiles(child, file);
            } else {
                TreeFile child = new FilePhoto(root.getLevel() + 1, file.getName(), root);
                root.addChild(child);
                if (isPhoto(file)) {
                    root.addCoverPhoto(file.getName());
                }
            }
        }
    } else {
    }
}
Also used : FilePhoto(com.yydcdut.noteplugin.bean.FilePhoto) TreeFile(com.yydcdut.noteplugin.bean.TreeFile) File(java.io.File) TreeFile(com.yydcdut.noteplugin.bean.TreeFile)

Aggregations

TreeFile (com.yydcdut.noteplugin.bean.TreeFile)4 FilePhoto (com.yydcdut.noteplugin.bean.FilePhoto)2 File (java.io.File)2 FilePhotoAdapter (com.yydcdut.noteplugin.adapter.FilePhotoAdapter)1