<commit_before>package com.example.android.effectivenavigation;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class CheckListActivity extends Activity {

    List<String> checkList = new ArrayList<String>();
    String mText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_check_list);

	Button mCheckListButton = (Button) findViewById(R.id.check_list_next);

	mCheckListButton.setOnClickListener(new OnClickListener() {
	    @Override
	    public void onClick(View view) {
		Intent intent = new Intent(view.getContext(), GuestsActivity.class);
		//attemptLogin();
		startActivity(intent);

	    }
	});

	ListView checkListView =  (ListView)findViewById(R.id.checkList);
	ArrayAdapter<String> checkListAdapter = new ArrayAdapter<String>(this,R.layout.check_list_view, checkList);
	checkListAdapter.notifyDataSetChanged();

	checkListView.setOnItemLongClickListener(new OnItemLongClickListener() {


	    @Override
	    public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
		    int arg2, long arg3) {
		// TODO Auto-generated method stub
		return false;
	    }
	});

	checkListView.setAdapter(checkListAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.check_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();
	if (id == R.id.action_settings) {
	    return true;
	}
	else if (id == R.id.action_add_todo)
	{
	    showDialog();

	}
	return super.onOptionsItemSelected(item);
    }



    private void showDialog() {
	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	builder.setTitle("Add TODO");

	// Set up the input
	final EditText input = new EditText(this);
	// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
	input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_MULTI_LINE );
	builder.setView(input);

	// Set up the buttons
	builder.setPositiveButton("Add", new DialogInterface.OnClickListener() { 
	    @Override
	    public void onClick(DialogInterface dialog, int which) {

		checkList.add(input.getText().toString());
		

	    }
	});
	builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
	    @Override
	    public void onClick(DialogInterface dialog, int which) {
		dialog.cancel();
	    }
	});

	builder.show();
    }
}
<commit_msg>fix delete<commit_after>package com.example.android.effectivenavigation;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class CheckListActivity extends Activity {

    private final List<String> checkList = new ArrayList<String>();

    private int selected = 0; 

    private final ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {

	// Called when the action mode is created; startActionMode() was called
	@Override
	public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	    // Inflate a menu resource providing context menu items
	    MenuInflater inflater = mode.getMenuInflater();
	    inflater.inflate(R.menu.check_element, menu);
	    return true;
	}

	// Called each time the action mode is shown. Always called after onCreateActionMode, but
	// may be called multiple times if the mode is invalidated.
	@Override
	public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
	    return false; // Return false if nothing is done
	}

	// Called when the user selects a contextual menu item
	@Override
	public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
	    switch (item.getItemId()) {
	    case R.id.action_edit_todo:
		showDialog(ItemOption.EDIT,titleEdit,positiveEdit);
		mode.finish(); // Action picked, so close the CAB
		return true;
	    case R.id.action_remove_todo:
		removeTODO(selected);
		mode.finish(); // Action picked, so close the CAB
		return true;
	    default:
		return false;
	    }
	}

	private void removeTODO(int selected) {

	    checkListAdapter.remove(checkList.get(selected));

	}



	// Called when the user exits the action mode
	@Override
	public void onDestroyActionMode(ActionMode mode) {
	    mActionMode = null;
	}
    };

    protected Object mActionMode;

    private ArrayAdapter<String> checkListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_check_list);

	Button mCheckListButton = (Button) findViewById(R.id.check_list_next);

	mCheckListButton.setOnClickListener(new OnClickListener() {
	    @Override
	    public void onClick(View view) {
		Intent intent = new Intent(view.getContext(), GuestsActivity.class);
		//attemptLogin();
		startActivity(intent);

	    }
	});

	ListView checkListView =  (ListView)findViewById(R.id.checkList);
	checkListAdapter = new ArrayAdapter<String>(this,R.layout.check_list_view, checkList);
	checkListAdapter.notifyDataSetChanged();


	checkListView.setOnItemLongClickListener(new OnItemLongClickListener() {


	    @Override
	    public boolean onItemLongClick(AdapterView<?> adapter, View view,
		    int index, long arg3) {

		if (mActionMode != null) {
		    return false;
		}

		selected = index;

		// Start the CAB using the ActionMode.Callback defined above
		mActionMode = CheckListActivity.this.startActionMode(mActionModeCallback);
		view.setSelected(true);

		return false;
	    }
	});

	checkListView.setAdapter(checkListAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.check_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();
	if (id == R.id.action_settings) {
	    return true;
	}
	else if (id == R.id.action_add_todo)
	{
	    showDialog(ItemOption.ADD,titleAdd,positiveAdd );

	}
	return super.onOptionsItemSelected(item);
    }

    private enum ItemOption {
	ADD,EDIT,
    }

    //ADD POPUP INFO
    private final String titleAdd = "Add TODO";
    private final String positiveAdd = "Add";

    //EDIT POPUP INFO
    String titleEdit = "Edit TODO";
    String positiveEdit = "Save";

    private void showDialog(final ItemOption type, String title, String positive) {
	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	builder.setTitle(title);

	// Set up the input
	final EditText input = new EditText(this);
	// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
	input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_MULTI_LINE );
	builder.setView(input);

	// Set up the buttons
	builder.setPositiveButton(positive, new DialogInterface.OnClickListener() { 
	    @Override
	    public void onClick(DialogInterface dialog, int which) {

		if (type == ItemOption.ADD)
		    checkList.add(input.getText().toString());
		else if (type == ItemOption.EDIT){

		    ((ArrayList<String>)checkList).set(selected,input.getText().toString());
		}
	    } 
	});
	builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
	    @Override
	    public void onClick(DialogInterface dialog, int which) {
		dialog.cancel();
	    }
	});

	builder.show();
    }

}

{'fraction_non_alphanumeric': 0.09689193673266232, 'fraction_numerical': 0.000663643402278509, 'mean_word_length': 4.2784588441331, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '532932', 'n_tokens_mistral': 2752, 'n_tokens_neox': 2544, 'n_words': 694}