@Override
  public RemoteViews getViewAt(final int position) {
    if (position >= this.tasks.size()) {
      return null;
    }
    final Task task = this.tasks.get(position);
    // Get The Task
    final boolean isMinimalistic = WidgetHelper.isMinimalistic(this.mContext, this.widgetId);
    RemoteViews rv =
        new RemoteViews(
            this.mContext.getPackageName(),
            isMinimalistic ? R.layout.widget_row_minimal : R.layout.widget_row);

    // Set the Contents of the Row
    rv =
        WidgetHelper.configureItem(
            rv, task, this.mContext, this.list.getId(), isMinimalistic, this.widgetId);

    // Set the Click–Intent
    // We need to do so, because we can not start the Activity directly from
    // the Service

    final Bundle extras = new Bundle();
    extras.putInt(MainWidgetProvider.EXTRA_TASKID, (int) task.getId());
    final Intent fillInIntent = new Intent(MainWidgetProvider.CLICK_TASK);
    fillInIntent.putExtras(extras);
    rv.setOnClickFillInIntent(R.id.tasks_row, fillInIntent);
    return rv;
  }
 private void updateList() {
   this.list = WidgetHelper.getList(this.mContext, this.widgetId);
   this.tasks = this.list.tasks(WidgetHelper.showDone(this.mContext, this.widgetId));
 }
  public static RemoteViews configureItem(
      RemoteViews rv, Task task, Context context, int listId, boolean isMinimal, int widgetId) {
    Intent openIntent = new Intent(context, MainActivity.class);
    openIntent.setAction(MainActivity.SHOW_TASK);
    openIntent.putExtra(MainActivity.EXTRA_ID, task.getId());
    openIntent.setData(Uri.parse(openIntent.toUri(Intent.URI_INTENT_SCHEME)));
    PendingIntent pOpenIntent = PendingIntent.getActivity(context, 0, openIntent, 0);

    rv.setOnClickPendingIntent(R.id.tasks_row, pOpenIntent);
    rv.setOnClickPendingIntent(R.id.tasks_row_name, pOpenIntent);
    if (isMinimal) {
      if (task.getDue() != null) {
        rv.setTextViewText(R.id.tasks_row_due, DateTimeHelper.formatDate(context, task.getDue()));
      } else {
        rv.setViewVisibility(R.id.tasks_row_due, View.GONE);
      }
      rv.setInt(
          R.id.tasks_row_priority,
          "setBackgroundColor",
          TaskHelper.getPrioColor(task.getPriority(), context));
    }
    rv.setTextColor(R.id.tasks_row_name, WidgetHelper.getFontColor(context, widgetId));
    rv.setTextColor(R.id.tasks_row_due, WidgetHelper.getFontColor(context, widgetId));
    rv.setTextViewText(R.id.tasks_row_name, task.getName());
    if (task.isDone()) {
      rv.setTextColor(R.id.tasks_row_name, context.getResources().getColor(R.color.Grey));
    } else {
      /*
       * Is this meaningful? I mean the widget is transparent…
       * rv.setTextColor( R.id.tasks_row_name, context.getResources()
       * .getColor( preferences.getBoolean("darkWidget", false) ?
       * R.color.White : R.color.Black));
       */
    }
    if (!isMinimal) {

      rv.setTextViewText(R.id.tasks_row_priority, task.getPriority() + "");
      rv.setTextColor(R.id.tasks_row_priority, context.getResources().getColor(R.color.Black));
      GradientDrawable drawable =
          (GradientDrawable) context.getResources().getDrawable(R.drawable.priority_rectangle);
      drawable.setColor(TaskHelper.getPrioColor(task.getPriority(), context));
      Bitmap bitmap = Bitmap.createBitmap(40, 40, Config.ARGB_8888);
      Canvas canvas = new Canvas(bitmap);
      drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
      drawable.draw(canvas);
      rv.setImageViewBitmap(R.id.label_bg, bitmap);

      if (listId <= 0) {
        rv.setViewVisibility(R.id.tasks_row_list_name, View.VISIBLE);
        rv.setTextViewText(R.id.tasks_row_list_name, task.getList().getName());
      } else {
        rv.setViewVisibility(R.id.tasks_row_list_name, View.GONE);
      }
      if (task.getContent().length() != 0
          || task.getSubtaskCount() > 0
          || task.getFiles().size() > 0) {
        rv.setViewVisibility(R.id.tasks_row_has_content, View.VISIBLE);
      } else {
        rv.setViewVisibility(R.id.tasks_row_has_content, View.GONE);
      }

      if (task.getDue() != null) {
        rv.setViewVisibility(R.id.tasks_row_due, View.VISIBLE);

        rv.setTextViewText(R.id.tasks_row_due, DateTimeHelper.formatDate(context, task.getDue()));
        if (!isMinimal) {
          rv.setTextColor(
              R.id.tasks_row_due,
              context
                  .getResources()
                  .getColor(TaskHelper.getTaskDueColor(task.getDue(), task.isDone())));
        }
      } else {
        rv.setViewVisibility(R.id.tasks_row_due, View.GONE);
      }
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      rv.setTextColor(
          R.id.tasks_row_name,
          context
              .getResources()
              .getColor(WidgetHelper.isDark(context, widgetId) ? R.color.White : R.color.Black));
    }
    return rv;
  }