<commit_before>package org.xtendroid.utils

import android.R
import android.app.AlertDialog
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.os.Handler
import android.support.v4.app.Fragment
import android.support.v4.app.NotificationCompat
import android.widget.Toast

/**
 * UI-based utilities for common UI tasks like toast, confirm, notification
 */
class AlertUtils {
   
   /**
    * Allow runOnUiThread from any context
    */
   def public static runOnUiThread(Context context, ()=>void uiCode) {
      val handler = new Handler(context.mainLooper)
      handler.post(uiCode)
   }

   /**
    * Allow runOnUiThread from any Fragment
    */
   def public static runOnUiThread(Fragment frag, ()=>void uiCode) {
      val handler = new Handler(frag.activity.mainLooper)
      handler.post(uiCode)
   }

   /**
    * Display a notification in the system bar
    */
   def public 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()
      );
   }

   /**
    * Cancel a previously-displayed notification
    */   
   def public static cancelNotification(Context context, int notifId) {
      var nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager<commit_msg>:Xtendroid will build in a single pass now. The culprit is the sugar syntax.<commit_after>package org.xtendroid.utils

import android.R
import android.app.AlertDialog
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.os.Handler
import android.support.v4.app.Fragment
import android.support.v4.app.NotificationCompat
import android.widget.Toast

/**
 * UI-based utilities for common UI tasks like toast, confirm, notification
 */
class AlertUtils {
   
   /**
    * Allow runOnUiThread from any context
    */
   def public static runOnUiThread(Context context, ()=>void uiCode) {
      val handler = new Handler(context.mainLooper)
      handler.post(uiCode)
   }

   /**
    * Allow runOnUiThread from any Fragment
    */
   def public static runOnUiThread(Fragment fragment, ()=>void uiCode) {
      val handler = new Handler(fragment.getActivity.getMainLooper)
      handler.post(uiCode)
   }

   /**
    * Display a notification in the system bar
    */
   def public 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()
      );
   }

   /**
    * Cancel a previously-displayed notification
    */   
   def public static cancelNotification(Context context, int notifId) {
      var nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
{'fraction_non_alphanumeric': 0.08465466272507391, 'fraction_numerical': 0.0010749798441279225, 'mean_word_length': 3.5279805352798053, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5146415', 'n_tokens_mistral': 1021, 'n_tokens_neox': 997, 'n_words': 254}