private void notifyForOneType(TimelineType timelineType, int numMessages) {
    if (numMessages == 0 || !areNotificationsEnabled(timelineType)) {
      return;
    }

    MyLog.v(this, "n=" + numMessages + "; timelineType=" + timelineType);

    int messageTitleResId;
    String messageText = "";
    switch (timelineType) {
      case MENTIONS:
        messageTitleResId = R.string.notification_title_mentions;
        messageText =
            I18n.formatQuantityMessage(
                myContext.context(),
                R.string.notification_new_mention_format,
                numMessages,
                R.array.notification_mention_patterns,
                R.array.notification_mention_formats);
        break;

      case DIRECT:
        messageTitleResId = R.string.notification_title_messages;
        messageText =
            I18n.formatQuantityMessage(
                myContext.context(),
                R.string.notification_new_message_format,
                numMessages,
                R.array.notification_direct_message_patterns,
                R.array.notification_direct_message_formats);
        break;

      case HOME:
      default:
        messageTitleResId = R.string.notification_new_home_title;
        messageText =
            I18n.formatQuantityMessage(
                myContext.context(),
                R.string.notification_new_tweet_format,
                numMessages,
                R.array.notification_home_patterns,
                R.array.notification_home_formats);
        break;
    }

    notify(timelineType, messageTitleResId, messageText);
  }
  private void notify(TimelineType timelineType, int messageTitleResId, String messageText) {
    String ringtone = MyPreferences.getString(MyPreferences.KEY_RINGTONE_PREFERENCE, null);
    Uri sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);

    Notification.Builder builder =
        new Notification.Builder(myContext.context())
            .setSmallIcon(
                MyPreferences.getBoolean(MyPreferences.KEY_NOTIFICATION_ICON_ALTERNATIVE, false)
                    ? R.drawable.notification_icon_circle
                    : R.drawable.notification_icon)
            .setContentTitle(myContext.context().getText(messageTitleResId))
            .setContentText(messageText)
            .setSound(sound);

    if (mNotificationsVibrate) {
      builder.setVibrate(new long[] {200, 300, 200, 300});
    }
    builder.setLights(Color.GREEN, 500, 1000);

    // Prepare "intent" to launch timeline activities exactly like in
    // org.andstatus.app.TimelineActivity.onOptionsItemSelected
    Intent intent = new Intent(myContext.context(), TimelineActivity.class);
    intent.setData(
        Uri.withAppendedPath(
            MatchedUri.getTimelineUri(
                0, timelineType, myContext.persistentAccounts().size() > 1, 0),
            "rnd/" + android.os.SystemClock.elapsedRealtime()));
    PendingIntent pendingIntent =
        PendingIntent.getActivity(
            myContext.context(),
            timelineType.hashCode(),
            intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);
    myContext.notify(timelineType, builder.build());
  }