From 98940d7554bedc47d9bc8a4f7e37a562669c610b Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 14 Dec 2022 13:57:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=81=8A=E5=A4=A9=E5=AE=A4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B2=89=E4=B8=9D=E5=BE=BD=E7=AB=A0=EF=BC=8C?= =?UTF-8?q?bitmap=E8=A2=AB=E5=9B=9E=E6=94=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/live/utils/LiveTextRender.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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) {