-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
绘制背景报空指针异常 #90
Comments
错误是在绘制背景的时候出现的~ |
我查看了下我们的工程配置,发现没有主动开启硬件加速功能,所以他应该是默认关闭的,请问下,您是怎么测试能出现这个问题呢,能把报错的日志粘贴出来吗,我在测试的时候一直没有出现这个问题~~ |
然后我发现有个问题,首次初始化CountDownView的时候,会调用多次BackgroundCountDown的onMeasure()方法,就会执行多次initTimeBgRect()方法,在该方法中就会创建多个rectf对象,这个地方有没有可能有问题呢 |
首次进入这个页面没有问题,但是第二次进入这个页面就会报这个错,魅族 note6 [message]: Attempt to read from field 'float android.graphics.RectF.left' on a null object reference; |
1.问题描述:执行BackgroundCountDown的onDraw方法canvas.drawRoundRect绘制圆角背景时,报java.lang.NullPointerException: Attempt to read from field 'float android.graphics.RectF.left' on a null object reference
2.由于是线上问题,且没有有效的mapping文件,所以并不能定位复现该问题,问题出现在4.4、5.0、6.0
、7.0等机型上,覆盖面比较广
3.通过阅读源代码,并不能找到手动把mHourBgBorderRectF、mHourBgRectF等变量置为null的逻辑
4.附上布局文件如下:
<xxx.countdownview.CountdownView
android:id="@+id/hc_recommend_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
app:isHideTimeBackground="false"
app:isShowDay="false"
app:isShowHour="true"
app:isShowMillisecond="false"
app:isShowMinute="true"
app:isShowSecond="true"
app:isShowTimeBgDivisionLine="false"
app:suffix=":"
app:suffixHourRightMargin="2dp"
app:suffixMinuteRightMargin="2dp"
app:isTimeTextBold="true"
app:isSuffixTextBold="true"
app:suffixLRMargin="1dp"
app:suffixGravity="center"
app:suffixTextColor="#ffa14d"
app:suffixTextSize="14sp"
app:timeBgColor="#FFa14d"
app:timeTextColor="#FFFFFF"
app:timeBgSize="20dp"
app:timeBgRadius="4dp"
app:timeTextSize="14sp" />
The text was updated successfully, but these errors were encountered: