Perform additional checks to avoid negative lengths

pull/30/head
Alinson S. Xavier 10 years ago
parent 88455acc76
commit 4def8f0409

@ -267,7 +267,7 @@ public class ListHabitsFragment extends Fragment
{
DisplayMetrics dm = getResources().getDisplayMetrics();
int width = (int) (dm.widthPixels / dm.density);
buttonCount = (int) ((width - 160) / 42.0);
buttonCount = Math.max(0, (int) ((width - 160) / 42.0));
tvNameWidth = (int) ((width - 30 - buttonCount * 42) * dm.density);
loader = new HabitListLoader();
@ -719,7 +719,8 @@ public class ListHabitsFragment extends Fragment
TextView tvCheck = (TextView) llButtons.getChildAt(i);
tvCheck.setTag(R.string.habit_key, habitId);
tvCheck.setTag(R.string.offset_key, i);
updateCheckmark(activeColor, tvCheck, isChecked[i]);
if(isChecked.length > i)
updateCheckmark(activeColor, tvCheck, isChecked[i]);
}
}

@ -269,6 +269,8 @@ public class Habit extends Model
{
updateCheckmarks();
if(fromTimestamp > toTimestamp) return new int[0];
String query = "select value, timestamp from Checkmarks where " +
"habit = ? and timestamp >= ? and timestamp <= ?";

Loading…
Cancel
Save