@Override
  public boolean onContextItemSelected(final MenuItem item) {
    final AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
      case R.id.menu_uninstall:
        startActivityForResult(
            new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + model.getPackage(info.id))),
            (int) (2000 + info.id));

        break;

      case R.id.menu_activate:
        model.togglePlugin(info.id);

        adapter.notifyDataSetChanged();

        break;

      case R.id.menu_report:
        final Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.putExtra(
            Intent.EXTRA_SUBJECT, "Announcify - Problem using " + model.getName(info.id));
        sendIntent.putExtra(Intent.EXTRA_TEXT, "");
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
        sendIntent.setType("message/rfc822");
        startActivity(sendIntent);

        break;
    }

    return true;
  }
  @Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode > 2000) {
      try {
        getPackageManager().getPackageGids(model.getPackage(requestCode - 2000));
      } catch (final NameNotFoundException e) {
        model.remove(requestCode - 2000);
      }
    }
  }
  @Override
  public void bindView(final View view, final Context context, final Cursor cursor) {
    final long id = cursor.getLong(idIndex);
    view.setTag(id);

    view.findViewById(R.id.separator).setVisibility(View.VISIBLE);
    view.findViewById(R.id.settings).setVisibility(View.VISIBLE);
    view.findViewById(R.id.check).setVisibility(View.VISIBLE);
    view.findViewById(R.id.plugin).setVisibility(View.VISIBLE);
    if (view.findViewById(R.id.admob) != null) {
      View mobfox = view.findViewById(R.id.admob);
      mobfox.setVisibility(View.GONE);
      mobfox = null;
    }
    view.findViewById(R.id.plugin_info).setVisibility(View.VISIBLE);

    ((TextView) view.findViewById(R.id.plugin)).setText(model.getName(id));

    final ImageView check = (ImageView) view.findViewById(R.id.check);
    check.setTag(id);
    check.setImageDrawable(
        context
            .getResources()
            .getDrawable(
                model.getActive(id)
                    ? R.drawable.btn_check_buttonless_on
                    : R.drawable.btn_check_buttonless_off));
    check.setOnClickListener(
        new OnClickListener() {

          public void onClick(final View v) {
            model.togglePlugin((Long) v.getTag());

            check.setImageDrawable(
                context
                    .getResources()
                    .getDrawable(
                        model.getActive(id)
                            ? R.drawable.btn_check_buttonless_on
                            : R.drawable.btn_check_buttonless_off));
          }
        });

    // view.setOnClickListener(new OnClickListener() {
    //
    // public void onClick(final View v) {
    // context.startActivity(new Intent(model.getAction((Long)
    // v.getTag())));
    // }
    // });
  }
  /**
   * Called if item in option menu is selected.
   *
   * @param item The chosen menu item
   * @return boolean true/false
   */
  @Override
  public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_toggle:
        final boolean activate = !model.getActive(model.getId("Announcify++"));

        final Cursor cursor = model.getAll();
        cursor.moveToFirst();

        final int idIndex = cursor.getColumnIndex(BaseColumns._ID);
        do {
          model.setActive(cursor.getLong(idIndex), activate);
        } while (cursor.moveToNext());
        cursor.close();

        adapter.notifyDataSetChanged();
        break;

      case R.id.menu_rate:
        startActivity(
            new Intent(
                Intent.ACTION_VIEW,
                Uri.parse(
                    "https://play.google.com/store/apps/details?id=org.mailboxer.saymyname")));
        break;

      case R.id.menu_share:
        startActivity(ActivityUtils.getShareIntent(this));
        break;

      case R.id.menu_help:
        startActivity(
            new Intent(Intent.ACTION_VIEW, Uri.parse("https://announcify.uservoice.com/")));
        break;

      case R.id.menu_translate:
        startActivity(
            new Intent(Intent.ACTION_VIEW, Uri.parse("http://crowdin.net/project/announcify")));
        break;

      case R.id.menu_about:
        startActivity(
            new Intent(
                Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/113909915559103636406")));
        break;
    }

    return true;
  }
  @Override
  public void onCreateContextMenu(
      final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(model.getName(info.id));

    getMenuInflater().inflate(R.menu.context_main, menu);
  }
  private void refreshList() {
    try {
      createPackageContext("org.mailboxer.saymyname.donate", 0);
    } catch (Exception e) {
      // TODO: add ads
    }

    cursor = model.getAll(PluginModel.KEY_PLUGIN_NAME);

    observer = new AnnouncifyObserver(new Handler());
    getContentResolver()
        .registerContentObserver(
            Uri.withAppendedPath(AnnouncifyProvider.PROVIDER_URI, PluginModel.TABLE_NAME),
            false,
            observer);

    adapter = new StickyListBaseAdapter(this, model, cursor);
    getListView().setAdapter(adapter);
  }