Example #1
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    try {
      super.onUpdate(context, appWidgetManager, appWidgetIds);

      if (preIceCreamSandwich()) {
        // Start in service to prevent Application Not Responding timeout
        updateWidgets(context);
      } else {
        ComponentName thisWidget = new ComponentName(context, TasksWidget.class);
        int[] ids = appWidgetManager.getAppWidgetIds(thisWidget);
        for (int id : ids) {
          appWidgetManager.updateAppWidget(id, widgetHelper.createScrollableWidget(context, id));
        }
      }
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
  }
Example #2
0
  @Override
  public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    switch (intent.getAction()) {
      case COMPLETE_TASK:
        broadcaster.toggleCompletedState(intent.getLongExtra(TaskEditFragment.TOKEN_ID, 0));
        break;
      case EDIT_TASK:
        if (context.getResources().getBoolean(R.bool.two_pane_layout)) {
          intent.setClass(context, TaskListActivity.class);
        } else {
          intent.setClass(context, TaskEditActivity.class);
        }
        intent.setFlags(WidgetHelper.flags);
        intent.putExtra(TaskEditFragment.OVERRIDE_FINISH_ANIM, false);
        context.startActivity(intent);

        break;
      case BROADCAST_EVENT_REFRESH:
        updateWidgets(context);
        break;
    }
  }