私はビューに画像をロードしようとしています。ときどき動作しますが、時には動作しないことがあります。私はAPIレベル19のエミュレータでテストしています。新しいターゲット内の障害ブロックは決して呼び出されません。私はprepareLoad
、その後のいずれかを参照してください。ピカソで画像を読み込んでいても、常に表示されるとは限りません。
onBitmapLoaded
が呼び出され、画像は- 画像が
はなぜこれが起こってしまうことが表示されません表示されますか?
これはエミュレータで発生しています。物理デバイスでは、Q & Aが100%の故障率を報告しています。他のデバイスでは断続的な障害発生率があります。何が起きてる?
public void setBackground() {
final LinearLayout mainLayout = (LinearLayout) findViewById(R.id.main_layout);
final Context context = this;
final String imagePath = getStore().backgroundImageURI;
if (getStore().backgroundImageNumber > 0) {
mainLayout.setBackground(context.getResources().getDrawable(getStore().backgroundImageNumber));
return;
}
if (imagePath == null) {
mainLayout.setBackground(context.getResources().getDrawable(R.drawable.sk_collection_bg_default));
return;
}
Picasso.with(this).load(imagePath).into(new Target(){
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
Log.v("Biscuit-width", String.valueOf(bitmap.getWidth()));
Log.v("Biscuit-height", String.valueOf(bitmap.getHeight()));
mainLayout.setBackground(new BitmapDrawable(context.getResources(), bitmap));
}
@Override
public void onBitmapFailed(final Drawable errorDrawable)
{
Log.d("BISCUIT", "FAILED" + errorDrawable.toString());
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
Log.d("TAG", "Prepare Load");
}
});
}
記録されている例外は表示されません – quantumpotato