Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the path of compressed files in Recycler View #537

Open
appt2 opened this issue Feb 18, 2024 · 6 comments
Open

Get the path of compressed files in Recycler View #537

appt2 opened this issue Feb 18, 2024 · 6 comments

Comments

@appt2
Copy link

appt2 commented Feb 18, 2024

Screenshot_2024-02-18-18-31-03-623_Ninja coder Ghostemane code

package Ninja.coder.Ghostemane.code.adapter;

import Ninja.coder.Ghostemane.code.R;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.widget.ImageView;
import android.view.LayoutInflater;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import net.lingala.zip4j.model.FileHeader;

public class ZipListFileShowAd extends RecyclerView.Adapter<ZipListFileShowAd.VH> {

  protected List<FileHeader> listModel;

  public ZipListFileShowAd(List<FileHeader> listModel) {
    this.listModel = listModel;
  }

  @Override
  public int getItemCount() {
    return listModel.size();
  }

  @Override
  public void onBindViewHolder(VH viewHolder, int pos) {

    View view = viewHolder.itemView;
    RecyclerView.LayoutParams _lp =
        new RecyclerView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    view.setLayoutParams(_lp);
    FileHeader fileM = listModel.get(pos);
    viewHolder.tvTools.setVisibility(View.GONE);
    viewHolder.folderName.setText(fileM.getFileName());
  }

  @Override
  public VH onCreateViewHolder(ViewGroup parnt, int pos) {
    View view =
        LayoutInflater.from(parnt.getContext()).inflate(R.layout.folder_remster, parnt, false);
    RecyclerView.LayoutParams _lp =
        new RecyclerView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    view.setLayoutParams(_lp);
    return new VH(view);
  }

  public class VH extends RecyclerView.ViewHolder {
    protected TextView folderName, tvTools;
    protected LinearLayout roots;
    protected ImageView icon;

    public VH(View view) {
      super(view);
      folderName = view.findViewById(R.id.folderName);
      tvTools = view.findViewById(R.id.tvTools);
      roots = view.findViewById(R.id.roots);
      icon = view.findViewById(R.id.icon);
    }
  }
}

Hello, I use your library to get the list of compressed files, but as you can see in the picture, the path of the files is displayed strangely, what is the solution?

@oleg-cherednik
Copy link

oleg-cherednik commented Mar 15, 2024

Zip files contains file names with paths. The real file name is the substring after the last '/'. Your code treats output entry list incorrectly.

@appt2
Copy link
Author

appt2 commented Mar 15, 2024

Zip files contains file names with paths. The real file name is the substring after the last '/'. Your code treats output entry list incorrectly.

So how can I fix this problem?

@oleg-cherednik
Copy link

oleg-cherednik commented Mar 17, 2024

When fileName ends with / - this is a folder. I.e. zipEntry is not a zip file but a folder.
When fileName does not end with '/' and contain / - it means that this zipEntry is a file with given path (including subfolders).
Just remember, that zip file contains a list of zipEntry. Each zipEntry can be either a file or a folder, i.e. a file with zero length.

@appt2
Copy link
Author

appt2 commented Mar 17, 2024

When fileName ends with / - this is a folder. I.e. zipEntry is not a zip file but a folder. When fileName does not end with '/' and contain / - it means that this zipEntry is a file with given path (including subfolders)

I did not understand, can you give a code example?

@oleg-cherednik
Copy link

When fileName ends with / - this is a folder. I.e. zipEntry is not a zip file but a folder. When fileName does not end with '/' and contain / - it means that this zipEntry is a file with given path (including subfolders)

I did not understand, can you give a code example?

Give me a link to your zip file

@appt2
Copy link
Author

appt2 commented Mar 17, 2024

When fileName ends with / - this is a folder. I.e. zipEntry is not a zip file but a folder. When fileName does not end with '/' and contain / - it means that this zipEntry is a file with given path (including subfolders)

I did not understand, can you give a code example?

Give me a link to your zip file

I don't have a zip file right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants