Fix crash when tapping HistoryChart

pull/316/head
Alinson S. Xavier 8 years ago
parent 3857eaf5e9
commit 9fe446b424

@ -32,7 +32,8 @@ import org.isoron.uhabits.utils.*;
import java.text.*;
import java.util.*;
import static org.isoron.uhabits.models.Checkmark.*;
import static org.isoron.uhabits.models.Checkmark.CHECKED_EXPLICITLY;
import static org.isoron.uhabits.models.Checkmark.UNCHECKED;
public class HistoryChart extends ScrollableChart
{
@ -112,10 +113,21 @@ public class HistoryChart extends ScrollableChart
if (!isEditable) return false;
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
float x, y;
try
{
int pointerId = e.getPointerId(0);
float x = e.getX(pointerId);
float y = e.getY(pointerId);
x = e.getX(pointerId);
y = e.getY(pointerId);
}
catch (RuntimeException ex)
{
// Android often throws IllegalArgumentException here. Apparently,
// the pointer id may become invalid shortly after calling
// e.getPointerId.
return false;
}
final Long timestamp = positionToTimestamp(x, y);
if (timestamp == null) return false;

Loading…
Cancel
Save