Move getImageSource to UniFile interface, and remove UniRandomAccessFile, it's a suck design

This commit is contained in:
tarsin committed 2023-02-27 17:24:04 +08:00
1 parent c4a3f06b51
commit 24ccf60870
10 files changed
+54 -479

No files matched your search

@@ -19,10 +19,13 @@ package com.hippo.unifile;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.graphics.ImageDecoder;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.hippo.image.Image;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -117,4 +120,20 @@ final class Contracts {
throw new IOException("Can't open InputStream", e);
}
}
@NonNull
static Image.CloseableSource getImageSource(Context context, Uri uri) {
var source = ImageDecoder.createSource(context.getContentResolver(), uri);
return new Image.CloseableSource() {
@NonNull
@Override
public ImageDecoder.Source getSource() {
return source;
}
@Override
public void close() {
}
};
}
}