<commit_before>/* ClaimantClaimListActivity displays list of claims
 * 
 * Copyright 2015 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/


package com.CMPUT301W15T02.teamtoapp;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class ClaimantClaimsListActivity extends Activity {
	
	private SessionController sessionController;
	final Context context = this;
	private ListView lv;
	private ClaimantClaimLVAdapter adapter;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.claimant_claims_list);
		
		sessionController = new SessionController();
		
		adapter = new ClaimantClaimLVAdapter(context, R.layout.claimant_claims_list_rows, sessionController.getClaims());
		lv = (ListView) findViewById(R.id.claimantClaimListView);
		
		// Item in the list is clicked, user taken to expenseListActivity
		lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Claim claim = sessionController.getClaims().get(position);
				sessionController.setClaim(claim);
				Intent intent = new Intent(ClaimantClaimsListActivity.this, ClaimantExpenseListActivity.class);
				startActivity(intent);
			}
		});
		
		lv.setLongClickable(true);
		lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

			@Override
			public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
				AlertDialog.Builder builder = new AlertDialog.Builder(ClaimantClaimsListActivity.this);
				builder.setMessage("Edit or Delete Claim?");
				builder
				.setPositiveButton("Edit", new DialogInterface.OnClickListener () {
					@Override
					public void onClick(DialogInterface dialog, int id) {
						// TODO Go to ClaimEditActivity.java
						Intent intent = new Intent(ClaimantClaimsListActivity.this, ClaimEditActivity.class);
						startActivity(intent);
					}
				})
				.setNegativeButton("Delete", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int id) {
						// Delete selected claim
					}
				});
		
				AlertDialog alertDialog = builder.create();
				alertDialog.show();
				return false;
			}
		});
		
		lv.setAdapter(adapter);<commit_msg>Fixed the long click bug<commit_after>/* ClaimantClaimListActivity displays list of claims
 * 
 * Copyright 2015 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/


package com.CMPUT301W15T02.teamtoapp;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class ClaimantClaimsListActivity extends Activity {
	
	private SessionController sessionController;
	final Context context = this;
	private ListView listView;
	private ClaimantClaimLVAdapter adapter;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.claimant_claims_list);
		
		sessionController = new SessionController();
		adapter = new ClaimantClaimLVAdapter(context, R.layout.claimant_claims_list_rows, sessionController.getClaims());
		
		findViewsByIds();
		setListeners();
		listView.setAdapter(adapter);
	}
	
	private void findViewsByIds() {
		listView = (ListView) findViewById(R.id.claimantClaimListView);
	}
	
	private void setListeners() {
		// Item in the list is clicked, user taken to expenseListActivity
		listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Claim claim = sessionController.getClaims().get(position);
				sessionController.setClaim(claim);
				Intent intent = new Intent(ClaimantClaimsListActivity.this, ClaimantExpenseListActivity.class);
				startActivity(intent);
			}
		});
				
		listView.setLongClickable(true);
		listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
			@Override
			public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
				AlertDialog.Builder builder = new AlertDialog.Builder(ClaimantClaimsListActivity.this);
				builder.setMessage("Edit or Delete Claim?");
				builder
				.setPositiveButton("Edit", new DialogInterface.OnClickListener () {
					@Override
					public void onClick(DialogInterface dialog, int id) {
						Intent intent = new Intent(ClaimantClaimsListActivity.this, ClaimEditActivity.class);
						startActivity(intent);
					}
				})
				.setNegativeButton("Delete", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int id) {
						// Delete selected claim
					}
				});
				
				AlertDialog alertDialog = builder.create();
				alertDialog.show();
				return true;
			}
		});
{'fraction_non_alphanumeric': 0.09046304814474088, 'fraction_numerical': 0.004599816007359705, 'mean_word_length': 4.632987910189983, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '535382', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1710, 'n_words': 509}