<commit_before>package com.zulip.android.viewholders;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;

import com.zulip.android.activities.RecyclerMessageAdapter;

public class HeaderSpaceItemDecoration extends RecyclerView.ItemDecoration {

    private final int verticalMargin;

    private int toolbarHeight;

    public HeaderSpaceItemDecoration(int verticalMargin, Context context) {
        this.verticalMargin = verticalMargin;
        TypedValue tv = new TypedValue();
        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
            toolbarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
        }
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                               RecyclerView.State state) {

        int position = parent.getChildAdapterPosition(view);

        int viewType = parent.getAdapter().getItemViewType(position);
        if (viewType == RecyclerMessageAdapter.VIEWTYPE_MESSAGE_HEADER && position != 0) {
            outRect.top = verticalMargin;
        } else if (viewType == RecyclerMessageAdapter.VIEWTYPE_HEADER) {
            outRect.top = toolbarHeight;
        }
    }
}<commit_msg>Add margin to the bottommost message<commit_after>package com.zulip.android.viewholders;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;

import com.zulip.android.activities.RecyclerMessageAdapter;

public class HeaderSpaceItemDecoration extends RecyclerView.ItemDecoration {

    private final int verticalMargin;

    private int toolbarHeight;

    public HeaderSpaceItemDecoration(int verticalMargin, Context context) {
        this.verticalMargin = verticalMargin;
        TypedValue tv = new TypedValue();
        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
            toolbarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
        }
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                               RecyclerView.State state) {

        int position = parent.getChildAdapterPosition(view);
        int size = parent.getAdapter().getItemCount();
        int viewType = parent.getAdapter().getItemViewType(position);
        if (viewType == RecyclerMessageAdapter.VIEWTYPE_MESSAGE_HEADER && position != 0) {
            outRect.top = verticalMargin;
        } else if (viewType == RecyclerMessageAdapter.VIEWTYPE_HEADER) {
            outRect.top = toolbarHeight;
        }
        outRect.bottom = (position == size - 2) ? verticalMargin : 0;
    }
}
{'fraction_non_alphanumeric': 0.08844703462461433, 'fraction_numerical': 0.002056907781967775, 'mean_word_length': 3.4212121212121214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3439409', 'n_tokens_mistral': 795, 'n_tokens_neox': 776, 'n_words': 162}