mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Perform additional checks to avoid negative lengths
This commit is contained in:
@@ -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,6 +719,7 @@ 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);
|
||||
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 <= ?";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user