<commit_before>package com.xtremelabs.robolectric.shadows;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.view.View;
import android.widget.Button;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;

import java.lang.reflect.Constructor;

import static com.xtremelabs.robolectric.Robolectric.shadowOf;

@SuppressWarnings( { "UnusedDeclaration" })
@Implements(AlertDialog.class)
public class ShadowAlertDialog extends ShadowDialog {
    private CharSequence[] items;
    private String message;
    private DialogInterface.OnClickListener clickListener;
    private AlertDialog realDialog;
    private boolean isMultiItem;
    private boolean isSingleItem;
    private DialogInterface.OnMultiChoiceClickListener multiChoiceClickListener;
    private boolean[] checkedItems;
    private int checkedItemIndex;
    private Button positiveButton;
    private Button negativeButton;
    private Button neutralButton;
    private boolean isCancelable;

    /**
     * Non-Android accessor.
     *
     * @return the most recently created {@code AlertDialog}, or null if none has been created during this test run
     */
    public static ShadowAlertDialog getLatestAlertDialog() {
        return Robolectric.getShadowApplication().getLatestAlertDialog();
    }

    @Override
    @Implementation
    public View findViewById(int viewId) {
        return null;
    }

    /**
     * Resets the tracking of the most recently created {@code AlertDialog}
     */
    public static void reset() {
        Robolectric.getShadowApplication().setLatestAlertDialog(null);
    }

    /**
     * Simulates a click on the {@code Dialog} item indicated by {@code index}. Handles both multi- and single-choice dialogs, tracks which items are currently
     * checked and calls listeners appropriately.
     *
     * @param index
     *            the index of the item to click on
     */
    public void clickOnItem(int index) {
        if (isMultiItem) {
            checkedItems[index] = !checkedItems[index];
            multiChoiceClickListener.onClick(realDialog, index, checkedItems[index]);
        } else {
            if (isSingleItem) {
                checkedItemIndex = index;
            }
            clickListener.onClick(realDialog, index);
        }
    }

    @Implementation
    public Button getButton(int whichButton) {
        switch (whichButton) {
        case AlertDialog.BUTTON_POSITIVE:
            return positiveButton;
        case AlertDialog.BUTTON_NEGATIVE:
            return negativeButton;
        case AlertDialog.BUTTON_NEUTRAL:
            return neutralButton;
        }
        throw new RuntimeException("Only positive, negative, or neutral button choices are recognized");
    }

    /**
     * Non-Android accessor.
     *
     * @return the items that are available to be clicked on
     */
    public CharSequence[] getItems() {
        return items;
    }
    
//    /**
//     * Non-Android accessor.
//     *
//     * @return the title of the dialog
//     */
//    public String getTitle() {
//        return title;
//    }

    /**
     * Non-Android accessor.
     *
     * @return the message displayed in the dialog
     */
    public String getMessage() {
        return message;
    }
<commit_msg>removed some commented code<commit_after>package com.xtremelabs.robolectric.shadows;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.view.View;
import android.widget.Button;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;

import java.lang.reflect.Constructor;

import static com.xtremelabs.robolectric.Robolectric.shadowOf;

@SuppressWarnings( { "UnusedDeclaration" })
@Implements(AlertDialog.class)
public class ShadowAlertDialog extends ShadowDialog {
    private CharSequence[] items;
    private String message;
    private DialogInterface.OnClickListener clickListener;
    private AlertDialog realDialog;
    private boolean isMultiItem;
    private boolean isSingleItem;
    private DialogInterface.OnMultiChoiceClickListener multiChoiceClickListener;
    private boolean[] checkedItems;
    private int checkedItemIndex;
    private Button positiveButton;
    private Button negativeButton;
    private Button neutralButton;
    private boolean isCancelable;

    /**
     * Non-Android accessor.
     *
     * @return the most recently created {@code AlertDialog}, or null if none has been created during this test run
     */
    public static ShadowAlertDialog getLatestAlertDialog() {
        return Robolectric.getShadowApplication().getLatestAlertDialog();
    }

    @Override
    @Implementation
    public View findViewById(int viewId) {
        return null;
    }

    /**
     * Resets the tracking of the most recently created {@code AlertDialog}
     */
    public static void reset() {
        Robolectric.getShadowApplication().setLatestAlertDialog(null);
    }

    /**
     * Simulates a click on the {@code Dialog} item indicated by {@code index}. Handles both multi- and single-choice dialogs, tracks which items are currently
     * checked and calls listeners appropriately.
     *
     * @param index
     *            the index of the item to click on
     */
    public void clickOnItem(int index) {
        if (isMultiItem) {
            checkedItems[index] = !checkedItems[index];
            multiChoiceClickListener.onClick(realDialog, index, checkedItems[index]);
        } else {
            if (isSingleItem) {
                checkedItemIndex = index;
            }
            clickListener.onClick(realDialog, index);
        }
    }

    @Implementation
    public Button getButton(int whichButton) {
        switch (whichButton) {
        case AlertDialog.BUTTON_POSITIVE:
            return positiveButton;
        case AlertDialog.BUTTON_NEGATIVE:
            return negativeButton;
        case AlertDialog.BUTTON_NEUTRAL:
            return neutralButton;
        }
        throw new RuntimeException("Only positive, negative, or neutral button choices are recognized");
    }

    /**
     * Non-Android accessor.
     *
     * @return the items that are available to be clicked on
     */
    public CharSequence[] getItems() {
        return items;
    }
    
    /**
     * Non-Android accessor.
     *
     * @return the message displayed in the dialog
     */
    public String getMessage() {
        return message;
    }

{'fraction_non_alphanumeric': 0.07851658699116326, 'fraction_numerical': 0.0, 'mean_word_length': 2.859139183901621, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '260002', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1772, 'n_words': 496}