<commit_before>
package org.holoeverywhere.app;

import org.holoeverywhere.R;
import org.holoeverywhere.internal.AlertController;
import org.holoeverywhere.internal.AlertController.AlertDecorViewInstaller;
import org.holoeverywhere.internal.AlertController.AlertParams.OnPrepareListViewListener;
import org.holoeverywhere.widget.ListView;

import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Message;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListAdapter;

public class AlertDialog extends Dialog implements DialogInterface,
        AlertDecorViewInstaller {
    public static class Builder {
        private final AlertController.AlertParams P;

        public Builder(Context context) {
            this(context, AlertDialog.resolveDialogTheme(context, 0));
        }

        public Builder(Context context, int theme) {
            P = new AlertController.AlertParams(new ContextThemeWrapper(
                    context, AlertDialog.resolveDialogTheme(context, theme)));
            P.mTheme = theme;
        }

        public AlertDialog create() {
            final AlertDialog dialog = new AlertDialog(P.mContext, P.mTheme);
            P.apply(dialog.mAlert);
            dialog.setCancelable(P.mCancelable);
            if (P.mCancelable) {
                dialog.setCanceledOnTouchOutside(true);
            }
            if (P.mOnCancelListener != null) {
                dialog.setOnCancelListener(P.mOnCancelListener);
            }
            if (P.mOnKeyListener != null) {
                dialog.setOnKeyListener(P.mOnKeyListener);
            }
            if (P.mOnDismissListener != null) {
                dialog.setOnDismissListener(P.mOnDismissListener);
            }
            return dialog;
        }

        public Context getContext() {
            return P.mContext;
        }

        public Builder setAdapter(final ListAdapter adapter,
                final OnClickListener listener) {
            P.mAdapter = adapter;
            P.mOnClickListener = listener;
            return this;
        }

        public Builder setCancelable(boolean cancelable) {
            P.mCancelable = cancelable;
            return this;
        }

        public Builder setCheckedItem(int checkedItem) {
            P.mCheckedItem = checkedItem;
            return this;
        }

        public Builder setCursor(final Cursor cursor,
                final OnClickListener listener, String labelColumn) {
            P.mCursor = cursor;<commit_msg>Support of custom AlertDialog classes for the AlertDialog.Builder<commit_after>
package org.holoeverywhere.app;

import org.holoeverywhere.R;
import org.holoeverywhere.internal.AlertController;
import org.holoeverywhere.internal.AlertController.AlertDecorViewInstaller;
import org.holoeverywhere.internal.AlertController.AlertParams.OnPrepareListViewListener;
import org.holoeverywhere.widget.ListView;

import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListAdapter;

public class AlertDialog extends Dialog implements DialogInterface,
        AlertDecorViewInstaller {
    public static class Builder {
        private final AlertController.AlertParams P;
        private Class<? extends AlertDialog> clazz;
        private static final Class<?>[] CONSTRUCTOR_SIGNATURE = {
                Context.class, int.class
        };

        public Builder(Context context) {
            this(context, AlertDialog.resolveDialogTheme(context, 0));
        }

        public Builder(Context context, int theme) {
            P = new AlertController.AlertParams(new ContextThemeWrapper(
                    context, AlertDialog.resolveDialogTheme(context, theme)));
            P.mTheme = theme;
        }

        private final String TAG = getClass().getSimpleName();

        public AlertDialog create() {
            AlertDialog dialog = null;
            if (clazz != null) {
                try {
                    dialog = clazz.getConstructor(CONSTRUCTOR_SIGNATURE).newInstance(P.mContext,
                            P.mTheme);
                } catch (Exception e) {
                    Log.e(TAG, "Cannot create AlertDialog instance from clazz " + clazz.getName()
                            + ", use default", e);
                }
            }
            if (dialog == null) {
                dialog = new AlertDialog(P.mContext, P.mTheme);
            }
            P.apply(dialog.mAlert);
            dialog.setCancelable(P.mCancelable);
            if (P.mCancelable) {
                dialog.setCanceledOnTouchOutside(true);
            }
            if (P.mOnCancelListener != null) {
                dialog.setOnCancelListener(P.mOnCancelListener);
            }
            if (P.mOnKeyListener != null) {
                dialog.setOnKeyListener(P.mOnKeyListener);
            }
            if (P.mOnDismissListener != null) {
                dialog.setOnDismissListener(P.mOnDismissListener);
            }
            return dialog;
        }

        public Builder setAlertDialogClass(Class<? extends AlertDialog> clazz) {
            this.clazz = clazz;
            return this;
        }

        public Context getContext() {
            return P.mContext;
        }

        public Builder setAdapter(final ListAdapter adapter,
                final OnClickListener listener) {
            P.mAdapter = adapter;
            P.mOnClickListener = listener;
            return this;
        }

        public Builder setCancelable(boolean cancelable) {
            P.mCancelable = cancelable;
            return this;
        }

        public Builder setCheckedItem(int checkedItem) {
            P.mCheckedItem = checkedItem;
            return this;
        }

        public Builder setCursor(final Cursor cursor,
                final OnClickListener listener, String labelColumn) {
            P.mCursor = cursor;
{'fraction_non_alphanumeric': 0.07874136607828089, 'fraction_numerical': 0.0003069838833461243, 'mean_word_length': 2.219367588932806, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '4818053', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1615, 'n_words': 361}