<commit_before>package cmput301w15t07.TravelTracker.util;

import java.util.Collection;
import java.util.Comparator;
import java.util.UUID;

import cmput301w15t07.TravelTracker.model.Tag;
import cmput301w15t07.TravelTracker.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ManageTagsListAdapter extends ArrayAdapter<Tag> {
    private static final int LAYOUT_ID = android.R.layout.simple_list_item_1;
    private Collection<Tag> tags;

    public ManageTagsListAdapter(Context context) {
        super(context, LAYOUT_ID);
    }
    
    /**
     * Rebuilds the underlying list of tags the adapter uses to display
     * data.
     * @param tags The list of all items
     * @param userID The claim to filter the list of Items by.
     */
    public void rebuildList(Collection<Tag> tags, UUID userID) {
        this.tags = tags;
        
        // Clear the list
        clear();
        
        // Add items to the adapter
        for(Tag tag : this.tags) {
            if (tag.getUser().equals(userID)) {
                add(tag);
            }
        }
        
        sort(new Comparator<Tag>() {
            @Override
            public int compare(Tag lhs, Tag rhs) {
                return rhs.getTitle().compareTo(lhs.getTitle());
            }
        });
        
        // Notify we changed
        notifyDataSetChanged();
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView;
        if (convertView != null) {
            rowView = convertView;
        }
        else {
            LayoutInflater inflator =(LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            rowView = inflator.inflate(LAYOUT_ID, parent, false);
        }
        
        Tag tagData = getItem(position);
        
        TextView view = (TextView) rowView.findViewById(android.R.id.text1);
        view.setText(tagData.getTitle());
        
        // Sets the the row selected background to be the dark grey the other
        // list views use. Necessary in code rather than in the XML since
        // we're using a layout from android (simple_list_item_1) where we
        // can't affect the layout XML
        rowView.setBackgroundResource(R.layout.background_activated);
        
        return rowView;
    }
}
<commit_msg>Fixed sorting in the wrong order and made the list sort regardless of case of title.<commit_after>package cmput301w15t07.TravelTracker.util;

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.UUID;

import cmput301w15t07.TravelTracker.model.Tag;
import cmput301w15t07.TravelTracker.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ManageTagsListAdapter extends ArrayAdapter<Tag> {
    private static final int LAYOUT_ID = android.R.layout.simple_list_item_1;
    private Collection<Tag> tags;

    public ManageTagsListAdapter(Context context) {
        super(context, LAYOUT_ID);
    }
    
    /**
     * Rebuilds the underlying list of tags the adapter uses to display
     * data.
     * @param tags The list of all items
     * @param userID The claim to filter the list of Items by.
     */
    public void rebuildList(Collection<Tag> tags, UUID userID) {
        this.tags = tags;
        
        // Clear the list
        clear();
        
        // Add items to the adapter
        for(Tag tag : this.tags) {
            if (tag.getUser().equals(userID)) {
                add(tag);
            }
        }
        
        sort(new Comparator<Tag>() {
            @Override
            public int compare(Tag lhs, Tag rhs) {
                /* Use Canada as the static Locale. This likely needs
                 * to be changed if this app left Canada 
                 */
                return lhs.getTitle().toLowerCase(Locale.CANADA)
                        .compareTo(rhs.getTitle().toLowerCase(Locale.CANADA));
            }
        });
        
        // Notify we changed
        notifyDataSetChanged();
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView;
        if (convertView != null) {
            rowView = convertView;
        }
        else {
            LayoutInflater inflator =(LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            rowView = inflator.inflate(LAYOUT_ID, parent, false);
        }
        
        Tag tagData = getItem(position);
        
        TextView view = (TextView) rowView.findViewById(android.R.id.text1);
        view.setText(tagData.getTitle());
        
        /* Sets the the row selected background to be the dark grey the other
         * list views use. Necessary in code rather than in the XML since
         * we're using a layout from android (simple_list_item_1) where we
         * can't affect the layout XML
         */
        rowView.setBackgroundResource(R.layout.background_activated);
        
        return rowView;
    }
}

{'fraction_non_alphanumeric': 0.08347338935574229, 'fraction_numerical': 0.008963585434173669, 'mean_word_length': 2.1193942923704134, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5043775', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1454, 'n_words': 409}