我有一個這樣的代碼:應用崩潰調用BitmapDrawable.draw(帆布帆布)時
@Override
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
drawGradient(canvas, parent);
drawStages(canvas, parent);
}
private void drawStages(final Canvas canvas, RecyclerView parent) {
final int parentLeft = parent.getPaddingLeft();
final int parentRight = parentLeft + mLeftPadding + mIconSize + mRightPadding;
int childCount = parent.getChildCount();
for (int i = 0; i < childCount - 1; i++) {
View child = parent.getChildAt(i);
LineupLayoutManager.LayoutParams params =
(LineupLayoutManager.LayoutParams) child.getLayoutParams();
final int parentTop = child.getTop() + params.topMargin;
final int parentBottom = child.getBottom() + params.bottomMargin;
int height = parentBottom - parentTop;
final int paddingVertical = Math.round((height - mIconSize)/2);
try {
String link = findPlaceById(params.getPlaceId(),mStageList).getImg();
Picasso.with(context).load(link).resize(150,150).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
final Drawable drawable = new BitmapDrawable();
drawable.setBounds(parentLeft + mLeftPadding, parentTop + paddingVertical,
parentRight - mRightPadding, parentBottom - paddingVertical);
Canvas canvas1 = new Canvas(bitmap);
drawable.draw(canvas1);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
} catch (IndexOutOfBoundsException e) {
Log.e(LOG_TAG, Log.getStackTraceString(e));
}
}
}
整個代碼是從RecyclerView.ItemDecoration 擴展類的問題是內部,當我執行它,應用崩潰與此錯誤:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x58 in tid 17542
我也試圖把bitmap.draw到runOnUIThread()但沒有成功。
了一些研究之後,我發現,畢加索以某種方式與畫布干擾。這意味着如果我把這些東西放在畢加索方法之外,一切正常。
發佈您的完整logcat輸出。 – csmckelvey
事情是沒有logcat輸出,我會在這裏發佈它。只有你看到的錯誤 – Traabefi
[Android致命信號11(SIGSEGV)在0x636f7d89(代碼= 1)可能有重複。它如何能夠被跟蹤了嗎?](http://stackoverflow.com/questions/17840521/android-fatal-signal-11-sigsegv-at-0x636f7d89-code-1-how-can-it-be-tracked) – csmckelvey