<commit_before>package uk.ac.horizon.observer.vc;

import java.util.EmptyStackException;
import java.util.List;

import uk.ac.horizon.observer.model.Places;
import uk.ac.horizon.observer.model.Task;
import uk.ac.horizon.observer.model.TaskBin;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

/**
 * A fragment representing a single Place's tasks. This fragment is either
 * contained in a {@link PlacesActivity} in two-pane mode (on tablets) or a
 * {@link TasksActivity} on handsets.
 */
public class TaskFragment extends ListFragment {
	/**
	 * The fragment argument representing the Place ID that the tasks are for.
	 */
	public static final String ARG_ITEM_ID = "item_id";

	/**
	 * The tasks
	 */
	private List<Task> myTasks = null;

	/**
	 * Mandatory empty constructor for the fragment manager to instantiate the
	 * fragment (e.g. upon screen orientation changes).
	 */
	public TaskFragment() {
	}

	/*
	 * @Override public void onCreate(Bundle savedInstanceState) {
	 * super.onCreate(savedInstanceState);
	 * 
	 * if (getArguments().containsKey(ARG_ITEM_ID)) { // Load the dummy content
	 * specified by the fragment // arguments. In a real-world scenario, use a
	 * Loader // to load content from a content provider. mItem =
	 * DummyContent.ITEM_MAP.get(getArguments().getString( ARG_ITEM_ID)); } }
	 * 
	 * @Override public View onCreateView(LayoutInflater inflater, ViewGroup
	 * container, Bundle savedInstanceState) { View rootView =
	 * inflater.inflate(R.layout.fragment_place_detail, container, false);
	 * 
	 * // Show the dummy content as text in a TextView. if (mItem != null) {
	 * ((TextView) rootView.findViewById(R.id.place_detail))
	 * .setText(mItem.content); }
	 * 
	 * return rootView; }
	 */

	/**
	 * On create set the tasks to the ones for the corresponding Place
	 * @author Jesse
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		myTasks = Places.getTasksforCurrentPlace();	// can be null
	}

	/**
	 * Display a multipe choice selection list of the tasks available for the given Place
	 * @author Jesse
	 */
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
		if(null != myTasks){
			if(myTasks.isEmpty()){
				Toast.makeText(this.getActivity(),
						String.valueOf("No tasks to select for " + Places.getCurrentPlaceName()),
						Toast.LENGTH_LONG).show();			
					}
				
				ArrayAdapter<Task> adapter = new ArrayAdapter<Task>(
					this.getActivity(),
					android.R.layout.simple_list_item_activated_1, myTasks);
			setListAdapter(adapter);
			getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
			
		} 
	}

	/**
	 * Add values of clicked items to the click queue 
	 */
	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Task tmp = myTasks.get(position);
		Task task = new Task(tmp.getName(), Places.getCurrentPlace());
		TaskBin.getInstance().addTask(task);
		//task.addObservation(this.getActivity());
		//Log the insertion of the new row
		//long lastobs = task.addObservation(this.getActivity());
		//Toast.makeText(this.getActivity(), "lastobs: " + lastobs, Toast.LENGTH_SHORT)
		//		.show();
	}
}<commit_msg>Greying out on click... need to start out greyed out. Also can still highlight when greyed out :(<commit_after>package uk.ac.horizon.observer.vc;

import java.util.List;

import uk.ac.horizon.observer.model.Places;
import uk.ac.horizon.observer.model.Task;
import uk.ac.horizon.observer.model.TaskBin;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

/**
 * A fragment representing a single Place's tasks. This fragment is either
 * contained in a {@link PlacesActivity} in two-pane mode (on tablets) or a
 * {@link TasksActivity} on handsets.
 */
public class TaskFragment extends ListFragment {
	/**
	 * The fragment argument representing the Place ID that the tasks are for.
	 */
	public static final String ARG_ITEM_ID = "item_id";

	/**
	 * The tasks
	 */
	private List<Task> myTasks = null;

	/**
	 * Mandatory empty constructor for the fragment manager to instantiate the
	 * fragment (e.g. upon screen orientation changes).
	 */
	public TaskFragment() {
	}

	/*
	 * @Override public void onCreate(Bundle savedInstanceState) {
	 * super.onCreate(savedInstanceState);
	 * 
	 * if (getArguments().containsKey(ARG_ITEM_ID)) { // Load the dummy content
	 * specified by the fragment // arguments. In a real-world scenario, use a
	 * Loader // to load content from a content provider. mItem =
	 * DummyContent.ITEM_MAP.get(getArguments().getString( ARG_ITEM_ID)); } }
	 * 
	 * @Override public View onCreateView(LayoutInflater inflater, ViewGroup
	 * container, Bundle savedInstanceState) { View rootView =
	 * inflater.inflate(R.layout.fragment_place_detail, container, false);
	 * 
	 * // Show the dummy content as text in a TextView. if (mItem != null) {
	 * ((TextView) rootView.findViewById(R.id.place_detail))
	 * .setText(mItem.content); }
	 * 
	 * return rootView; }
	 */

	/**
	 * On create set the tasks to the ones for the corresponding Place
	 * @author Jesse
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		myTasks = Places.getTasksforCurrentPlace();	// can be null
	}

	/**
	 * Display a multipe choice selection list of the tasks available for the given Place
	 * @author Jesse
	 */
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
		if(null != myTasks){
			if(myTasks.isEmpty()){
				Toast.makeText(this.getActivity(),
						String.valueOf("No tasks to select for " + Places.getCurrentPlaceName()),
						Toast.LENGTH_LONG).show();			
			}
			ArrayAdapter<Task> adapter = new ArrayAdapter<Task>(
					this.getActivity(),
					android.R.layout.simple_list_item_activated_1, myTasks);
			setListAdapter(adapter);
			ListView lv = getListView();
			lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
			lv.setOnItemClickListener(new OnItemClickListener() {
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
					getListView().getChildAt(0).setEnabled(false);
		        }
			});
		} 
	}

	/**
	 * Add values of clicked items to the click queue 
	 */
	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Task tmp = myTasks.get(position);
		Task task = new Task(tmp.getName(), Places.getCurrentPlace());
		TaskBin.getInstance().addTask(task);
		//task.addObservation(this.getActivity());
		//Log the insertion of the new row
		//long lastobs = task.addObservation(this.getActivity());
		//Toast.makeText(this.getActivity(), "lastobs: " + lastobs, Toast.LENGTH_SHORT)
		//		.show();
	}
}
{'fraction_non_alphanumeric': 0.115990057995029, 'fraction_numerical': 0.0006904170118751726, 'mean_word_length': 3.984858912594632, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1683856', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2089, 'n_words': 595}