Skip to content

Commit

Permalink
Improve performance when using SAF (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
FooIbar authored May 5, 2024
1 parent ff0e92e commit a9de196
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions library/src/main/java/com/hippo/unifile/TreeDocumentFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public Uri getUri() {

@Override
public String getName() {
if (mName != null) {
return mName;
if (mName == null) {
mName = DocumentsContractApi19.getName(mContext, mUri);
}
return DocumentsContractApi19.getName(mContext, mUri);
return mName;
}

@Override
Expand Down Expand Up @@ -211,8 +211,7 @@ public UniFile[] listFiles(FilenameFilter filter) {
final NamedUri[] uris = DocumentsContractApi21.listFilesNamed(mContext, mUri);
final ArrayList<UniFile> results = new ArrayList<>();
for (NamedUri uri : uris) {
String name = DocumentsContractApi19.getName(mContext, uri.uri);
if (name != null && filter.accept(this, name)) {
if (uri.name != null && filter.accept(this, uri.name)) {
results.add(new TreeDocumentFile(this, mContext, uri.uri, uri.name));
}
}
Expand Down

0 comments on commit a9de196

Please sign in to comment.