Glideライブラリ(v4.2.0 with compile SDK 26)とchristbanes Photoviewライブラリを使って奇妙なことに直面しています。ロードしたり、いくつかの画像(サイズ< 300 Kb)を表示したり、すべての画像ではなく、Photoviewライブラリでズームジェスチャを実行することができます。イメージはlocation/storage/emulated/0/hhp_images /に存在しますが、Glideはまだいくつかのイメージをロードし、他の人にはこのエラーを表示します。グライド読み込み中に画像が一部しか読み込まれません
W/Glide: Load failed for file:///storage/emulated/0/hhp_images/cylhd_chang.jpg with size [1080x1704]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, LOCAL
Cause (1 of 1): class java.io.FileNotFoundException: /storage/emulated/0/hhp_images/cylhd_chang.jpg (No such file or directory)
Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
Cause (1 of 1): class java.io.FileNotFoundException: No such file or directory
I/Glide: Root cause (1 of 2)
java.io.FileNotFoundException: /storage/emulated/0/hhp_images/cylhd_chang.jpg (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:99)
at android.content.ContentResolver.openInputStream(ContentResolver.java:700)
at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResourceFromUri(StreamLocalUriFetcher.java:87)
at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:62)
at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:17)
at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:41)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:293)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:263)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:386)
I/Glide: Root cause (2 of 2)
java.io.FileNotFoundException: No such file or directory
at android.os.Parcel.openFileDescriptor(Native Method)
at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:283)
at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:200)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:977)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:905)
at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:22)
at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:14)
at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:41)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:293)
at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:388)
at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailed(SourceGenerator.java:118)
at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:46)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:293)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:263)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:386)
W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
画像のサイズはロードすることができない、すなわち中小企業の場合に、それは150キロバイトまたはいくつかの300キロバイトである変数です。だから私はこれが大きなサイズのためではないと思う。しかし、私は問題を把握することができません。
これはPopupWindowに滑空し、読み込み画像を呼び出しているクラスのコードです - 私が代わりてPhotoViewの通常のImageViewの200dp * 200dpで画像をロードしようとしたが、それでも同じエラーを得た
public class PhotoFullPopupWindow extends PopupWindow {
View view;
Context mContext;
PhotoView photoView;
ProgressBar loading;
ViewGroup parent;
private static PhotoFullPopupWindow instance = null;
public PhotoFullPopupWindow(Context ctx, int layout, View v, String imageUrl, Bitmap bitmap) {
super(((LayoutInflater) ctx.getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.popup_photo_full, null)
, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
if (Build.VERSION.SDK_INT >= 21) {
setElevation(5.0f);
}
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.mContext = ctx;
this.view = getContentView();
ImageButton closeButton = (ImageButton) this.view.findViewById(R.id.ib_close);
setOutsideTouchable(true);
setFocusable(true);
// Set a click listener for the popup window close button
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Dismiss the popup window
dismiss();
}
});
//---------Begin customising this popup--------------------
photoView = (PhotoView) view.findViewById(R.id.image);
// loading = (ProgressBar) view.findViewById(R.id.loading);
photoView.setMaximumScale(6);
parent = (ViewGroup) photoView.getParent();
// ImageUtils.setZoomable(imageView);
//----------------------------
if (bitmap != null) {
// loading.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= 16) {
parent.setBackground(new BitmapDrawable(mContext.getResources(), Constants.fastblur(Bitmap.createScaledBitmap(bitmap, 50, 50, true))));//));
} else {
onPalette(Palette.from(bitmap).generate());
}
photoView.setImageBitmap(bitmap);
} else {
// loading.setIndeterminate(true);
// loading.setVisibility(View.VISIBLE);
GlideApp.with(ctx) .asBitmap()
.load(Uri.fromFile(new File(imageUrl)))
// .override(600, 200)
.error(R.drawable.sample_image)
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
// loading.setIndeterminate(false);
// loading.setBackgroundColor(Color.LTGRAY);
Toast.makeText(mContext, "Error: Unable to open image", Toast.LENGTH_SHORT).show();
// dismiss();
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
if (Build.VERSION.SDK_INT >= 16) {
// parent.setBackground(new BitmapDrawable(mContext.getResources(), Constants.fastblur(Bitmap.createScaledBitmap(resource, 50, 50, true))));//));
parent.setBackgroundColor(Color.BLACK);
} else {
onPalette(Palette.from(resource).generate());
}
photoView.setImageBitmap(resource);
// loading.setVisibility(View.GONE);
return false;
}
})
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(photoView);
showAtLocation(v, Gravity.CENTER, 0, 0);
}
//------------------------------
}
public void onPalette(Palette palette) {
if (null != palette) {
ViewGroup parent = (ViewGroup) photoView.getParent().getParent();
parent.setBackgroundColor(palette.getDarkVibrantColor(Color.GRAY));
}
}
}
。
SOLVED - 実際にはコードに問題はありませんでした。 Moto G4 Plusに問題がありました。私が他のエミュレータでアプリを走らせたとき、それはうまくいった。
を試すことができます。この
または
のように行うことができ、いくつかの画像はonclickの表示なっているが、一部ではありません。だから私はいくつかの画像が表示されている場合は、外部のストレージを読み取るためのアクセス権が存在しなければならない場合は、彼らはまた、ロードに失敗すると思う。ではない?このコードを追加しましたが、同じエラーが発生しました – Somebody