<commit_before>package com.tobykurien.xtendroid.utils

import android.R
import android.app.AlertDialog
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.support.v4.app.Fragment
import android.support.v4.app.NotificationCompat
import android.widget.Toast
import org.eclipse.xtext.xbase.lib.Functions.Function0

class AlertUtils {

   def static showNotification(Context context, int notifId, int iconResId, int title, String message, PendingIntent intent) {
      var mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE)
            as NotificationManager;

      var mBuilder = new NotificationCompat.Builder(context)
         .setSmallIcon(iconResId)
         .setContentTitle(context.getString(title))
         .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
         .setContentText(message);

      mBuilder.setContentIntent(intent);
      mNotificationManager.notify(notifId, 
         mBuilder.build()
      );
   }
   
   def static cancelNotification(Context context, int notifId) {
      var nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
      nm.cancel(notifId)
   }
   
   def static toast(Context context, String message) {
      Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
   }
   
   def static toast(Fragment fragment, String message) {
      toast(fragment.activity, message)
   }
   
   def static confirm(Context context, String message, Function0<Void> confirmed) {
      new AlertDialog.Builder(context)
         .setMessage(message)
         .setPositiveButton(R.string.ok, [a,b| confirmed.apply ])
         .create.show
   }
   
   def static confirm(Fragment fragment, String message, Function0<Void> confirmed) {
      confirm(fragment.activity, message, confirmed)
   }   
}<commit_msg>added cancel button to confirm dialog<commit_after>package com.tobykurien.xtendroid.utils

import android.R
import android.app.AlertDialog
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.support.v4.app.Fragment
import android.support.v4.app.NotificationCompat
import android.widget.Toast
import org.eclipse.xtext.xbase.lib.Functions.Function0

class AlertUtils {

   def static showNotification(Context context, int notifId, int iconResId, int title, String message, PendingIntent intent) {
      var mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE)
            as NotificationManager;

      var mBuilder = new NotificationCompat.Builder(context)
         .setSmallIcon(iconResId)
         .setContentTitle(context.getString(title))
         .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
         .setContentText(message);

      mBuilder.setContentIntent(intent);
      mNotificationManager.notify(notifId, 
         mBuilder.build()
      );
   }
   
   def static cancelNotification(Context context, int notifId) {
      var nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
      nm.cancel(notifId)
   }
   
   def static toast(Context context, String message) {
      Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
   }
   
   def static toast(Fragment fragment, String message) {
      toast(fragment.activity, message)
   }
   
   def static confirm(Context context, String message, Function0<Void> confirmed) {
      new AlertDialog.Builder(context)
         .setMessage(message)
         .setPositiveButton(R.string.ok, [a,b| confirmed.apply ])
         .setNegativeButton(R.string.cancel, [a,b| a.dismiss ])
         .create.show
   }
   
   def static confirm(Fragment fragment, String message, Function0<Void> confirmed) {
      confirm(fragment.activity, message, confirmed)
   }   
}
{'fraction_non_alphanumeric': 0.08728504429390307, 'fraction_numerical': 0.0026055237102657635, 'mean_word_length': 3.687423687423687, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1455997', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1055, 'n_words': 224}