<commit_before>package com.jvw.clip;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

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


public class Manage extends ActionBarActivity {

	private ViewGroup layout;
	private List<DestinationListItem> data = new ArrayList<DestinationListItem>();

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

		layout = (ViewGroup) findViewById(R.id.manage_layout);
	}


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.manage, menu);
		return true;
	}

	private void addItem(String name, String ip, int port) {
		final ViewGroup view = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.manage_item, layout, false);
		((TextView) view.findViewById(R.id.manage_name_textview)).setText(name);
		((TextView) view.findViewById(R.id.manage_ip_port_textview)).setText(ip + ":" + port);
		view.findViewById(R.id.manage_remove_button).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				int position = layout.indexOfChild(view);
				layout.removeViewAt(position);
				data.remove(position);
			}
		});
		data.add(new DestinationListItem(name, ip, port));
		layout.addView(view, 0);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case R.id.manage_add:
				final View v = getLayoutInflater().inflate(R.layout.dialog_add_dest, null);
				final EditText ipEdit = (EditText) v.findViewById(R.id.add_dest_ip_edittext);
				final EditText nameEdit = (EditText) v.findViewById(R.id.add_dest_name_edittext);
				final EditText portEdit = (EditText) v.findViewById(R.id.add_dest_port_edittext);
				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.setTitle("Add ip address");
				builder.setView(v);
				builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {

					}
				});
				builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						String name = nameEdit.getText().toString();
						String ip = ipEdit.getText().toString();
						int port = Integer.parseInt(portEdit.getText().toString());
						addItem(name, ip, port);
					}
				});
				builder.show();
				return true;
			default:
				return super.onOptionsItemSelected(item);
		}
	}

}
<commit_msg>Add catch if user enters nothing in the port editText.<commit_after>package com.jvw.clip;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

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


public class Manage extends ActionBarActivity {

	private ViewGroup layout;
	private List<DestinationListItem> data = new ArrayList<DestinationListItem>();

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

		layout = (ViewGroup) findViewById(R.id.manage_layout);
	}


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.manage, menu);
		return true;
	}

	private void addItem(String name, String ip, int port) {
		final ViewGroup view = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.manage_item, layout, false);
		((TextView) view.findViewById(R.id.manage_name_textview)).setText(name);
		((TextView) view.findViewById(R.id.manage_ip_port_textview)).setText(ip + ":" + port);
		view.findViewById(R.id.manage_remove_button).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				int position = layout.indexOfChild(view);
				layout.removeViewAt(position);
				data.remove(position);
			}
		});
		data.add(new DestinationListItem(name, ip, port));
		layout.addView(view, 0);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case R.id.manage_add:
				final View v = getLayoutInflater().inflate(R.layout.dialog_add_dest, null);
				final EditText ipEdit = (EditText) v.findViewById(R.id.add_dest_ip_edittext);
				final EditText nameEdit = (EditText) v.findViewById(R.id.add_dest_name_edittext);
				final EditText portEdit = (EditText) v.findViewById(R.id.add_dest_port_edittext);
				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.setTitle("Add ip address");
				builder.setView(v);
				builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {

					}
				});
				builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						String name = nameEdit.getText().toString();
						String ip = ipEdit.getText().toString();
						int port = 60607;
						try {
							port = Integer.parseInt(portEdit.getText().toString());
						} catch (NumberFormatException e) {
							e.printStackTrace();
						}
						addItem(name, ip, port);
					}
				});
				builder.show();
				return true;
			default:
				return super.onOptionsItemSelected(item);
		}
	}

}

{'fraction_non_alphanumeric': 0.11695607763023494, 'fraction_numerical': 0.0015321756894790602, 'mean_word_length': 4.6166347992351815, 'pattern_counts': {'":': 2, '<': 7, '<?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': '511084', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1729, 'n_words': 362}