mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Ignore exception when habit is not found
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.*;
|
|||||||
import android.preference.*;
|
import android.preference.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
|
import org.isoron.uhabits.models.*;
|
||||||
|
|
||||||
import javax.inject.*;
|
import javax.inject.*;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ public class WidgetPreferences
|
|||||||
public long getHabitIdFromWidgetId(int widgetId)
|
public long getHabitIdFromWidgetId(int widgetId)
|
||||||
{
|
{
|
||||||
Long habitId = prefs.getLong(getHabitIdKey(widgetId), -1);
|
Long habitId = prefs.getLong(getHabitIdKey(widgetId), -1);
|
||||||
if (habitId < 0) throw new RuntimeException("widget not found");
|
if (habitId < 0) throw new HabitNotFoundException();
|
||||||
|
|
||||||
return habitId;
|
return habitId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import android.os.*;
|
|||||||
import android.support.annotation.*;
|
import android.support.annotation.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
|
import com.activeandroid.util.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.models.*;
|
import org.isoron.uhabits.models.*;
|
||||||
import org.isoron.uhabits.preferences.*;
|
import org.isoron.uhabits.preferences.*;
|
||||||
@@ -76,8 +78,15 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
|
|||||||
|
|
||||||
for (int id : ids)
|
for (int id : ids)
|
||||||
{
|
{
|
||||||
BaseWidget widget = getWidgetFromId(context, id);
|
try
|
||||||
widget.delete();
|
{
|
||||||
|
BaseWidget widget = getWidgetFromId(context, id);
|
||||||
|
widget.delete();
|
||||||
|
}
|
||||||
|
catch (HabitNotFoundException e)
|
||||||
|
{
|
||||||
|
Log.e("BaseWidgetProvider", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user