fix potential ANR when scheduling task notifications

This commit is contained in:
Phillip Thelen 2017-08-07 12:30:16 +02:00
parent e99ff76f67
commit a4ea581a71
2 changed files with 5 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica"
android:versionCode="1925"
android:versionCode="1926"
android:versionName="1.1.6"
android:screenOrientation="portrait"
android:installLocation="auto" >

View file

@ -531,15 +531,17 @@ public class Task extends RealmObject implements Parcelable {
newTime.setTime(today.getTime());
} else if (FREQUENCY_WEEKLY.equals(this.getFrequency())) {
int nextActiveDayOfTheWeek = newTime.get(Calendar.DAY_OF_WEEK);
while ((!this.getRepeat().getForDay(nextActiveDayOfTheWeek) || newTime.before(today) || newTime.equals(today)) && nextActiveDayOfTheWeek < 7) {
int daysChecked = 0;
while ((!this.getRepeat().getForDay(nextActiveDayOfTheWeek) || newTime.before(today) || newTime.equals(today)) && daysChecked <= 7) {
if (nextActiveDayOfTheWeek == 6) {
nextActiveDayOfTheWeek = 0;
} else {
nextActiveDayOfTheWeek += 1;
}
daysChecked += 1;
newTime.add(Calendar.DATE, 1);
}
if (nextActiveDayOfTheWeek > 7) {
if (daysChecked > 7) {
return null;
}
} else {