<commit_before>package com.cmput301.cs.project.activities;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import com.cmput301.cs.project.App;
import com.cmput301.cs.project.R;
import com.cmput301.cs.project.adapters.ExpensesAdapter;
import com.cmput301.cs.project.model.Claim;
import com.cmput301.cs.project.model.ClaimsList;
import com.cmput301.cs.project.model.Expense;

/**
 * An activity that shows a list of all {@link com.cmput301.cs.project.model.Expense Expenses} associated with a {@link com.cmput301.cs.project.model.Claim Claim}. </br>
 * When an {@link com.cmput301.cs.project.model.Expense Expense} is clicked, {@link com.cmput301.cs.project.activities.ExpenseViewActivity ExpenseViewActivity} is called. </br>
 * When the menu item is clicked, {@link com.cmput301.cs.project.activities.EditExpenseActivity EditExpenseActivity} is called to
 * generate a new expense.
 *
 * The claim which the expenses belong MUST be passed as an intent as App.KEY_CLAIM
 * 
 * @author rozsa
 *
 */

public class ExpenseListActivity extends ListActivity {
    private static final int EDIT_EXPENSE = 0;

    private Claim mClaim;

    private ExpensesAdapter mAdapter;

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

        mClaim = getIntent().getParcelableExtra(App.KEY_CLAIM);
        if (mClaim == null) {
            throw new IllegalStateException("Must have claim passed in using KEY_CLAIM");
        }

        mAdapter = new ExpensesAdapter(this, mClaim.peekExpenses());
        setListAdapter(mAdapter);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Expense expenseSelected = mAdapter.getItem(position);

        Intent intent = new Intent(this, ExpenseViewActivity.class);
        intent.putExtra(ExpenseViewActivity.KEY_EXPENSE, expenseSelected);
        startActivity(intent);
    }
<commit_msg>Expense items sort too<commit_after>package com.cmput301.cs.project.activities;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import com.cmput301.cs.project.App;
import com.cmput301.cs.project.R;
import com.cmput301.cs.project.adapters.ExpensesAdapter;
import com.cmput301.cs.project.model.Claim;
import com.cmput301.cs.project.model.ClaimsList;
import com.cmput301.cs.project.model.Expense;

/**
 * An activity that shows a list of all {@link com.cmput301.cs.project.model.Expense Expenses} associated with a {@link com.cmput301.cs.project.model.Claim Claim}. </br>
 * When an {@link com.cmput301.cs.project.model.Expense Expense} is clicked, {@link com.cmput301.cs.project.activities.ExpenseViewActivity ExpenseViewActivity} is called. </br>
 * When the menu item is clicked, {@link com.cmput301.cs.project.activities.EditExpenseActivity EditExpenseActivity} is called to
 * generate a new expense.
 *
 * The claim which the expenses belong MUST be passed as an intent as App.KEY_CLAIM
 * 
 * @author rozsa
 *
 */

public class ExpenseListActivity extends ListActivity {
    private static final int EDIT_EXPENSE = 0;

    private Claim mClaim;

    private ExpensesAdapter mAdapter;

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

        mClaim = getIntent().getParcelableExtra(App.KEY_CLAIM);
        if (mClaim == null) {
            throw new IllegalStateException("Must have claim passed in using KEY_CLAIM");
        }

        mAdapter = new ExpensesAdapter(this, mClaim.peekExpenses());
        setListAdapter(mAdapter);
        mAdapter.sort(Expense.OCCURRED_DESCENDING);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Expense expenseSelected = mAdapter.getItem(position);

        Intent intent = new Intent(this, ExpenseViewActivity.class);
        intent.putExtra(ExpenseViewActivity.KEY_EXPENSE, expenseSelected);
        startActivity(intent);
    }

{'fraction_non_alphanumeric': 0.09599083619702177, 'fraction_numerical': 0.01695303550973654, 'mean_word_length': 4.035755478662053, 'pattern_counts': {'":': 0, '<': 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': '3521868', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1265, 'n_words': 316}