diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java index 4cf3ed5e6..8699d194f 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -322,6 +322,9 @@ public class LiveTextRender { tv.setText(bean.getMedalNmae()); tv.setTypeface(Typeface.DEFAULT_BOLD); Bitmap bitmap = convertViewToBitmap(view); + if (bitmap == null) { + return null; + } Drawable drawable = new BitmapDrawable(bitmap); return drawable; } @@ -330,10 +333,15 @@ public class LiveTextRender { view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredWidth() / 3); // 153 72 - view.buildDrawingCache(); - Bitmap bitmap = view.getDrawingCache(); + try { + view.buildDrawingCache(); + Bitmap bitmap = view.getDrawingCache(); - return bitmap; + return bitmap; + } catch (Exception e) { + e.printStackTrace(); + } + return null; } public void render(final Context context, final TextView textView, final LiveChatBean bean) {