<commit_before>package im.actor.messenger.app.fragment.contacts;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import im.actor.android.view.BindedListAdapter;
import im.actor.messenger.R;
import im.actor.messenger.app.fragment.DisplayListFragment;
import im.actor.messenger.app.fragment.help.HelpActivity;
import im.actor.messenger.app.util.Screen;
import im.actor.messenger.app.view.Fonts;
import im.actor.messenger.app.view.OnItemClickedListener;
import im.actor.messenger.app.view.TintImageView;
import im.actor.model.entity.Contact;
import im.actor.model.log.Log;
import im.actor.model.mvvm.BindedDisplayList;
import im.actor.model.mvvm.ValueChangedListener;
import im.actor.model.mvvm.ValueModel;

import static im.actor.messenger.app.Core.messenger;

/**
 * Created by ex3ndr on 23.09.14.
 */
public abstract class BaseContactFragment extends DisplayListFragment<Contact, ContactHolder> {

    private View emptyView;
    private final boolean useCompactVersion;
    private final boolean userSearch;
    private final boolean useSelection;

    public BaseContactFragment(boolean useCompactVersion, boolean userSearch, boolean useSelection) {
        this.useCompactVersion = useCompactVersion;
        this.userSearch = userSearch;
        this.useSelection = useSelection;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return onCreateContactsView(R.layout.fragment_base_contacts, inflater, container, savedInstanceState);
    }

    protected View onCreateContactsView(int layoutId, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View res = inflate(inflater, container, layoutId, messenger().buildContactDisplayList());

        emptyView = res.findViewById(R.id.emptyCollection);

        View headerPadding = new View(getActivity());
        headerPadding.setBackgroundColor(getResources().getColor(R.color.bg_light));
        headerPadding.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
        addHeaderView(headerPadding);

        if (useCompactVersion) {
            View footer = new View(getActivity());
            footer.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
            addFooterView(footer);
        } else {
//            TextView header = new TextView(getActivity());
//            header.setBackgroundColor(getResources().getColor(R.color.bg_grey));
//            header.setText(R.string.contacts_title);
//            header.setTypeface(Fonts.bold());
//            header.setPadding(Screen.dp(16), 0, 0, 0);
//            header.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
//            header.setTextSize(16);
//            header.setTextColor(getResources().getColor(R.color.text_subheader));
//
//            LinearLayout headerCont = new LinearLayout(getActivity());
//            headerCont.setBackgroundColor(getResources().getColor(R.color.bg_light));
//            headerCont.setOrientation(LinearLayout.VERTICAL);
//            headerCont.addView(header, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(48)));
//            headerCont.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
//            addHeaderView(headerCont);

            addFooterAction(R.drawable.ic_share_white_24dp, "Tell friends about Actor", false, new Runnable() {
                @Override
                public void run() {

                }
            });

            addFooterAction(R.drawable.ic_person_add_white_24dp, "Add friend...", true, new Runnable() {
                @Override
                public void run() {

                }
            });

            FrameLayout footer = new FrameLayout(getActivity());
            footer.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(112)));
            ImageView shadow = new ImageView(getActivity());
            shadow.setImageResource(R.drawable.card_shadow_bottom);
            shadow.setScaleType(ImageView.ScaleType.FIT_XY);
            shadow.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
            footer.addView(shadow);

            addFooterView(footer);
        }

        bind(messenger().getAppState().getIsContactsEmpty(), new ValueChangedListener<Boolean>() {
            @Override<commit_msg>feat(android): Implemented invite/add to contacts list<commit_after>package im.actor.messenger.app.fragment.contacts;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import im.actor.android.view.BindedListAdapter;
import im.actor.messenger.R;
import im.actor.messenger.app.activity.AddContactActivity;
import im.actor.messenger.app.fragment.DisplayListFragment;
import im.actor.messenger.app.fragment.help.HelpActivity;
import im.actor.messenger.app.util.Screen;
import im.actor.messenger.app.view.Fonts;
import im.actor.messenger.app.view.OnItemClickedListener;
import im.actor.messenger.app.view.TintImageView;
import im.actor.model.entity.Contact;
import im.actor.model.log.Log;
import im.actor.model.mvvm.BindedDisplayList;
import im.actor.model.mvvm.ValueChangedListener;
import im.actor.model.mvvm.ValueModel;

import static im.actor.messenger.app.Core.messenger;

/**
 * Created by ex3ndr on 23.09.14.
 */
public abstract class BaseContactFragment extends DisplayListFragment<Contact, ContactHolder> {

    private View emptyView;
    private final boolean useCompactVersion;
    private final boolean userSearch;
    private final boolean useSelection;

    public BaseContactFragment(boolean useCompactVersion, boolean userSearch, boolean useSelection) {
        this.useCompactVersion = useCompactVersion;
        this.userSearch = userSearch;
        this.useSelection = useSelection;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return onCreateContactsView(R.layout.fragment_base_contacts, inflater, container, savedInstanceState);
    }

    protected View onCreateContactsView(int layoutId, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View res = inflate(inflater, container, layoutId, messenger().buildContactDisplayList());

        emptyView = res.findViewById(R.id.emptyCollection);

        View headerPadding = new View(getActivity());
        headerPadding.setBackgroundColor(getResources().getColor(R.color.bg_light));
        headerPadding.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
        addHeaderView(headerPadding);

        if (useCompactVersion) {
            View footer = new View(getActivity());
            footer.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
            addFooterView(footer);
        } else {
//            TextView header = new TextView(getActivity());
//            header.setBackgroundColor(getResources().getColor(R.color.bg_grey));
//            header.setText(R.string.contacts_title);
//            header.setTypeface(Fonts.bold());
//            header.setPadding(Screen.dp(16), 0, 0, 0);
//            header.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
//            header.setTextSize(16);
//            header.setTextColor(getResources().getColor(R.color.text_subheader));
//
//            LinearLayout headerCont = new LinearLayout(getActivity());
//            headerCont.setBackgroundColor(getResources().getColor(R.color.bg_light));
//            headerCont.setOrientation(LinearLayout.VERTICAL);
//            headerCont.addView(header, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(48)));
//            headerCont.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
//            addHeaderView(headerCont);

            addFooterAction(R.drawable.ic_share_white_24dp, "Tell friends about Actor", false, new Runnable() {
                @Override
                public void run() {
                    String inviteMessage = getResources().getString(R.string.invite_message);
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);
                    sendIntent.putExtra(Intent.EXTRA_TEXT, inviteMessage);
                    sendIntent.setType("text/plain");
                    startActivity(sendIntent);
                }
            });

            addFooterAction(R.drawable.ic_person_add_white_24dp, "Add friend...", true, new Runnable() {
                @Override
                public void run() {
                    startActivity(new Intent(getActivity(), AddContactActivity.class));
                }
            });

            FrameLayout footer = new FrameLayout(getActivity());
            footer.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(112)));
            ImageView shadow = new ImageView(getActivity());
            shadow.setImageResource(R.drawable.card_shadow_bottom);
            shadow.setScaleType(ImageView.ScaleType.FIT_XY);
            shadow.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(4)));
            footer.addView(shadow);

            addFooterView(footer);
        }

        bind(messenger().getAppState().getIsContactsEmpty(), new ValueChangedListener<Boolean>() {
            @Override
{'fraction_non_alphanumeric': 0.10485860694628962, 'fraction_numerical': 0.00531410134750427, 'mean_word_length': 3.418867924528302, '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': '6207950', 'n_tokens_mistral': 3017, 'n_tokens_neox': 2805, 'n_words': 476}