alamkanak / Android-Week-View

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Apache License 2.0
3.42k stars 1.23k forks source link

Division by zero error #283

Closed entropitor closed 8 years ago

entropitor commented 8 years ago

I sometimes get a division by zero error at https://github.com/alamkanak/Android-Week-View/blob/develop/library/src/main/java/com/alamkanak/weekview/WeekView.java#L895

java.lang.ArithmeticException: divide by zero at com.alamkanak.weekview.WeekView.a(WeekView.java:895)

@alamkanak @marunjar Any ideas on how to solve this? (It seems similair to https://stackoverflow.com/questions/5084647/staticlayout-getellipsiscount-returning-0-when-i-know-its-ellipsizing)

marunjar commented 8 years ago

Doesn't sound like it's easily reproducable, but would be good to know what causes this lineCount. Do you have any additional infos about the params for static layout? e.g. an odd availableWidth or an empty bob?

We could catch this exception an log these params for debug builds for additional infos. Or simply check getLineCount for zero and skip drawing.

entropitor commented 8 years ago

Nope, we don't have any info yet. But when I read the stackoverflow, it seems like it's rather a synchronisation issue than a specific string that is causing the problem. Not drawing is a possible solution, but I'm not sure if it will draw anything then after a while.

@lolobosse @alamkanak you guys any idea?

entropitor commented 8 years ago

Only occurs on Samsung SM-G800F so probably bug in their code.