Ignore exception when habit is not found

pull/276/head
Alinson S. Xavier 9 years ago
parent 65cc99dbf7
commit 0d6ad26505

@ -23,6 +23,7 @@ import android.content.*;
import android.preference.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import javax.inject.*;
@ -48,7 +49,7 @@ public class WidgetPreferences
public long getHabitIdFromWidgetId(int widgetId)
{
Long habitId = prefs.getLong(getHabitIdKey(widgetId), -1);
if (habitId < 0) throw new RuntimeException("widget not found");
if (habitId < 0) throw new HabitNotFoundException();
return habitId;
}

@ -25,6 +25,8 @@ import android.os.*;
import android.support.annotation.*;
import android.widget.*;
import com.activeandroid.util.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import org.isoron.uhabits.preferences.*;
@ -75,10 +77,17 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
updateDependencies(context);
for (int id : ids)
{
try
{
BaseWidget widget = getWidgetFromId(context, id);
widget.delete();
}
catch (HabitNotFoundException e)
{
Log.e("BaseWidgetProvider", e);
}
}
}
@Override

Loading…
Cancel
Save