<commit_before>package org.duckdns.raven.ttscallresponder.preparedTextList;

import org.duckdns.raven.ttscallresponder.R;
import org.duckdns.raven.ttscallresponder.domain.PersistentPreparedResponseList;
import org.duckdns.raven.ttscallresponder.domain.PreparedResponse;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;

public class ActivityPreparedResponseList extends Activity implements DialogInterface.OnClickListener {

	private final static String TAG = "ActivityPreparedResponseList";

	public static final String INTENT_KEY_EDIT_PREPARED_RESPONSE = "preparedResponseToEdit";

	private PersistentPreparedResponseList persistentList = null;
	private PreparedResponseListAdapter adapter = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.i(ActivityPreparedResponseList.TAG, "Enter on Create");

		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_prepared_response_list);

		this.overridePendingTransition(R.animator.anim_slide_in_from_right, R.animator.anim_slide_out_to_left);

		ListView prepareResponsesListView = (ListView) this.findViewById(R.id.list_prepared_responses);
		this.persistentList = PersistentPreparedResponseList.getSingleton(this.getFilesDir());
		this.adapter = new PreparedResponseListAdapter(this, this.persistentList.getPreparedAnswerList());
		prepareResponsesListView.setAdapter(this.adapter);
	}

	@Override
	protected void onPause() {
		super.onPause();

		this.overridePendingTransition(R.animator.anim_slide_in_from_left, R.animator.anim_slide_out_to_right);
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);

		PreparedResponse preparedResponse = intent
				.getParcelableExtra(ActivityPreparedResponseEditor.INTENT_KEY_PREPARED_RESPONSE);
		if (preparedResponse != null) {
			Log.d(ActivityPreparedResponseList.TAG, "Got something");
			this.persistentList.add(preparedResponse);
		}
		preparedResponse = null;
		this.adapter.notifyDataSetChanged();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		this.getMenuInflater().inflate(R.menu.prepared_response_list, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();

		switch (id) {
		case R.id.action_done:
			this.persistentList.savePreparedAnswerList();
		case android.R.id.home:
			this.onBackPressed();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	public void onAddClick(View view) {
		Intent openPreparedResponseEditor = new Intent(this, ActivityPreparedResponseEditor.class);
		openPreparedResponseEditor.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		this.startActivity(openPreparedResponseEditor);
	}

	public void onDeleteClick(View view) {
		Log.i(ActivityPreparedResponseList.TAG, "Delete called");
		this.persistentList.removeSelected();
		this.adapter.notifyDataSetChanged();
	}

	public void onPreparedResponseClick(View view) {
		Intent openPreparedResponseEditor = new Intent(this, ActivityPreparedResponseEditor.class);
		openPreparedResponseEditor.putExtra(ActivityPreparedResponseList.INTENT_KEY_EDIT_PREPARED_RESPONSE,
				(Parcelable) view.getTag());
		this.startActivity(openPreparedResponseEditor);
	}

	@Override
	public void onBackPressed() {
		if (this.persistentList.hasChanged()) {
			AlertDialog.Builder alert = new AlertDialog.Builder(this);
			alert.setTitle("Unsaved changes");
			alert.setMessage("You made changes to the list, which are not yet saved. \n\n What would you like to do?");

			alert.setPositiveButton("Save", this);
			alert.setNeutralButton("Cancel", this);
			alert.setNegativeButton("Discard", this);
			alert.show();
		} else
			super.onBackPressed();
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		switch (which) {
		case DialogInterface.BUTTON_NEUTRAL:
			return;
		case DialogInterface.BUTTON_POSITIVE:
			this.persistentList.savePreparedAnswerList();
			break;
		default:
			this.persistentList.discardChanges();
		}
		super.onBackPressed();
	}
}<commit_msg>[PreparedResponseList] Removed implementation of DialogInterface.OnClickListener and moved functionality inside an anonym class.<commit_after>package org.duckdns.raven.ttscallresponder.preparedTextList;

import org.duckdns.raven.ttscallresponder.R;
import org.duckdns.raven.ttscallresponder.domain.PersistentPreparedResponseList;
import org.duckdns.raven.ttscallresponder.domain.PreparedResponse;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;

public class ActivityPreparedResponseList extends Activity {

	private final static String TAG = "ActivityPreparedResponseList";

	public static final String INTENT_KEY_EDIT_PREPARED_RESPONSE = "preparedResponseToEdit";

	private PersistentPreparedResponseList persistentList = null;
	private PreparedResponseListAdapter adapter = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.i(ActivityPreparedResponseList.TAG, "Enter on Create");

		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_prepared_response_list);

		this.overridePendingTransition(R.animator.anim_slide_in_from_right, R.animator.anim_slide_out_to_left);

		ListView prepareResponsesListView = (ListView) this.findViewById(R.id.list_prepared_responses);
		this.persistentList = PersistentPreparedResponseList.getSingleton(this.getFilesDir());
		this.adapter = new PreparedResponseListAdapter(this, this.persistentList.getPreparedAnswerList());
		prepareResponsesListView.setAdapter(this.adapter);
	}

	@Override
	protected void onPause() {
		super.onPause();

		this.overridePendingTransition(R.animator.anim_slide_in_from_left, R.animator.anim_slide_out_to_right);
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);

		PreparedResponse preparedResponse = intent
				.getParcelableExtra(ActivityPreparedResponseEditor.INTENT_KEY_PREPARED_RESPONSE);
		if (preparedResponse != null) {
			Log.d(ActivityPreparedResponseList.TAG, "Got something");
			this.persistentList.add(preparedResponse);
		}
		preparedResponse = null;
		this.adapter.notifyDataSetChanged();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		this.getMenuInflater().inflate(R.menu.prepared_response_list, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();

		switch (id) {
		case R.id.action_done:
			this.persistentList.savePreparedAnswerList();
		case android.R.id.home:
			this.onBackPressed();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	public void onAddClick(View view) {
		Intent openPreparedResponseEditor = new Intent(this, ActivityPreparedResponseEditor.class);
		openPreparedResponseEditor.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		this.startActivity(openPreparedResponseEditor);
	}

	public void onDeleteClick(View view) {
		Log.i(ActivityPreparedResponseList.TAG, "Delete called");
		this.persistentList.removeSelected();
		this.adapter.notifyDataSetChanged();
	}

	public void onPreparedResponseClick(View view) {
		Intent openPreparedResponseEditor = new Intent(this, ActivityPreparedResponseEditor.class);
		openPreparedResponseEditor.putExtra(ActivityPreparedResponseList.INTENT_KEY_EDIT_PREPARED_RESPONSE,
				(Parcelable) view.getTag());
		this.startActivity(openPreparedResponseEditor);
	}

	@Override
	public void onBackPressed() {
		if (this.persistentList.hasChanged()) {
			AlertDialog.Builder alert = new AlertDialog.Builder(this);
			alert.setTitle("Unsaved changes");
			alert.setMessage("You made changes to the list, which are not yet saved. \n\n What would you like to do?");

			DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which) {
					switch (which) {
					case DialogInterface.BUTTON_NEUTRAL:
						return;
					case DialogInterface.BUTTON_POSITIVE:
						ActivityPreparedResponseList.this.persistentList.savePreparedAnswerList();
						break;
					default:
						ActivityPreparedResponseList.this.persistentList.discardChanges();
					}
					ActivityPreparedResponseList.this.onBackPressed();
				}

			};
			alert.setPositiveButton("Save", listener);
			alert.setNeutralButton("Cancel", listener);
			alert.setNegativeButton("Discard", listener);
			alert.show();
		} else
			super.onBackPressed();
	}
}
{'fraction_non_alphanumeric': 0.09150464919695689, 'fraction_numerical': 0.0, 'mean_word_length': 5.775232641374374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3527923', 'n_tokens_mistral': 3111, 'n_tokens_neox': 2789, 'n_words': 553}