<commit_before>package net.vikingsen.gridadapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by <NAME>
 *
 */
public abstract class GroupListAdapter<T> extends BaseAdapter {

    private final Context context;
    private final int[] itemsPerGroup;
    private final int[] sumItems;
    private final int totalItemsForGroups;
    private final int numTypes;
    private final int itemsInFristGroup;

    private List<T> data;
    private boolean allowPartialGroups = false;

    public GroupListAdapter(Context context, int[] itemsPerGroup, int itemsInFirstGroup) {
        this.context = context;

        this.itemsPerGroup = itemsPerGroup;
        int n = itemsPerGroup.length;
        this.sumItems = new int[n];
        int s = 0;
        for (int i = 0; i < n; i++) { // NOSONAR Sum loop not copy
            this.sumItems[i] = s;
            s += itemsPerGroup[i];
        }
        this.totalItemsForGroups = s;
        this.numTypes = n;
        this.itemsInFristGroup = itemsInFirstGroup;
    }

    public abstract View newView(Context context, ViewGroup parent, int type, int itemsInGroup);

    public abstract void bindView(View view, Context context, List<T> groupItems, int type, int itemsInGroup, int firstPosition);

    public abstract long getGroupItemId(int groupPosition, T t);

    @Override
    public int getCount() {
        int listCount = data != null ? data.size() - itemsInFristGroup : 0;
        if (listCount <= 0 || (listCount < itemsInFristGroup && !allowPartialGroups)) {
            return 0;
        }
        int count = 0;
        if (itemsInFristGroup > 0) {
            count++;
        }
        return count + getNumberOfGroups(listCount);
    }

    private int getNumberOfGroups(int n) {<commit_msg>Fixed Issue with first group.<commit_after>package net.vikingsen.gridadapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by <NAME>
 *
 */
public abstract class GroupListAdapter<T> extends BaseAdapter {

    private final Context context;
    private final int[] itemsPerGroup;
    private final int[] sumItems;
    private final int totalItemsForGroups;
    private final int numTypes;
    private final int itemsInFristGroup;

    private List<T> data;
    private boolean allowPartialGroups = false;

    public GroupListAdapter(Context context, int[] itemsPerGroup, int itemsInFirstGroup) {
        this.context = context;

        this.itemsPerGroup = itemsPerGroup;
        int n = itemsPerGroup.length;
        this.sumItems = new int[n];
        int s = 0;
        for (int i = 0; i < n; i++) { // NOSONAR Sum loop not copy
            this.sumItems[i] = s;
            s += itemsPerGroup[i];
        }
        this.totalItemsForGroups = s;
        this.numTypes = n;
        this.itemsInFristGroup = itemsInFirstGroup;
    }

    public abstract View newView(Context context, ViewGroup parent, int type, int itemsInGroup);

    public abstract void bindView(View view, Context context, List<T> groupItems, int type, int itemsInGroup, int firstPosition);

    public abstract long getGroupItemId(int groupPosition, T t);

    @Override
    public int getCount() {
        int listCount = data != null ? data.size(): 0;
        if (listCount <= 0 || (listCount < itemsInFristGroup && !allowPartialGroups)) {
            return 0;
        }
        listCount -= itemsInFirstGroup;
        int count = 0;
        if (itemsInFristGroup > 0) {
            count++;
        }
        return count + getNumberOfGroups(listCount);
    }

    private int getNumberOfGroups(int n) {
{'fraction_non_alphanumeric': 0.09100557176970019, 'fraction_numerical': 0.0037145131334571503, 'mean_word_length': 2.7624750499001998, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '1919638', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1053, 'n_words': 325}