// Path: library/src/main/java/com/onegravity/contactpicker/contact/Contact.java
// public interface Contact extends ContactElement {
// 
//     String getFirstName();
// 
//     String getLastName();
// 
//     /**
//      * ContactsContract.CommonDataKinds.Email.TYPE values:
//      *
//      * - TYPE_CUSTOM
//      * - TYPE_HOME
//      * - TYPE_WORK
//      * - TYPE_OTHER
//      * - TYPE_MOBILE
//      *
//      * @param type the type
//      * @return a String with the Email.
//      */
//     String getEmail(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getEmail(int)
//      * @return the map type to email.
//      */
//     Map<Integer, String> getMapEmail();
// 
//     /**
//      * ContactsContract.CommonDataKinds.Email.ContactsContract.CommonDataKinds.Phone.TYPE values:
//      *
//      * - TYPE_CUSTOM, TYPE_HOME, TYPE_MOBILE, TYPE_WORK, TYPE_FAX_WORK, TYPE_FAX_HOME, TYPE_PAGER
//      * - TYPE_OTHER, TYPE_CALLBACK, TYPE_CAR, TYPE_COMPANY_MAIN, TYPE_ISDN, TYPE_MAIN
//      * - TYPE_OTHER_FAX, TYPE_RADIO, TYPE_TELEX, TYPE_TTY_TDD, TYPE_WORK_MOBILE, TYPE_WORK_PAGER
//      * - TYPE_ASSISTANT, TYPE_MMS
//      *
//      * @param type the type
//      * @return a String with the phone.
//      */
//     String getPhone(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getPhone(int)
//      * @return the map type to phone.
//      */
//     Map<Integer, String> getMapPhone();
// 
//     /**
//      * * ContactsContract.CommonDataKinds.StructuredPostal.TYPE values:
//      *
//      * - TYPE_CUSTOM
//      * - TYPE_HOME
//      * - TYPE_WORK
//      * - TYPE_OTHER
//      *
//      * @param type the type
//      * @return A String with the address
//      */
//     String getAddress(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getAddress(int)
//      * @return the map type to address.
//      */
//     Map<Integer, String> getMapAddress();
// 
//     /**
//      * The contact letter is used in the ContactBadge (if no contact picture can be found).
//      */
//     char getContactLetter();
// 
//     /**
//      * The contact letter according to the sort order is used in the SectionIndexer for the fast
//      * scroll indicator.
//      */
//     char getContactLetter(ContactSortOrder sortOrder);
// 
//     /**
//      * The contact color is used in the ContactBadge (if no contact picture can be found) as
//      * background color.
//      */
//     int getContactColor();
// 
//     /**
//      * Unique key across all contacts that won't change even if the column id changes.
//      */
//     String getLookupKey();
// 
//     Uri getPhotoUri();
// 
//     Set<Long> getGroupIds();
// }


import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.onegravity.contactpicker.R;
import com.onegravity.contactpicker.contact.Contact;
import java.util.Collection;
/*
 * Copyright (C) 2015-2017 Emanuel Moecklin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.onegravity.contactpicker.group;




public class GroupViewHolder extends RecyclerView.ViewHolder {

    private View mRoot;
    private CheckBox mSelect;
    private TextView mName;
    private TextView mDescription;

    GroupViewHolder(View root) {
        super(root);

        mRoot = root;
        mSelect = (CheckBox) root.findViewById(R.id.select);
        mName = (TextView) root.findViewById(R.id.name);
        mDescription = (TextView) root.findViewById(R.id.description);
    }

    void bind(final Group group) {
        mRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSelect.toggle();
            }
        });

        // main text / title
        mName.setText(group.getDisplayName());

        // description
        Collection<Contact> contacts = group.getContacts();
        Resources res = mRoot.getContext().getResources();
        String desc = res.getQuantityString(R.plurals.cp_group_description, contacts.size(), contacts.size());
        mDescription.setText(desc);

        // check box
        mSelect.setOnCheckedChangeListener(null);
        mSelect.setChecked( group.isChecked() );
        mSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
// Path: library/src/main/java/com/onegravity/contactpicker/contact/Contact.java
// public interface Contact extends ContactElement {
// 
//     String getFirstName();
// 
//     String getLastName();
// 
//     /**
//      * ContactsContract.CommonDataKinds.Email.TYPE values:
//      *
//      * - TYPE_CUSTOM
//      * - TYPE_HOME
//      * - TYPE_WORK
//      * - TYPE_OTHER
//      * - TYPE_MOBILE
//      *
//      * @param type the type
//      * @return a String with the Email.
//      */
//     String getEmail(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getEmail(int)
//      * @return the map type to email.
//      */
//     Map<Integer, String> getMapEmail();
// 
//     /**
//      * ContactsContract.CommonDataKinds.Email.ContactsContract.CommonDataKinds.Phone.TYPE values:
//      *
//      * - TYPE_CUSTOM, TYPE_HOME, TYPE_MOBILE, TYPE_WORK, TYPE_FAX_WORK, TYPE_FAX_HOME, TYPE_PAGER
//      * - TYPE_OTHER, TYPE_CALLBACK, TYPE_CAR, TYPE_COMPANY_MAIN, TYPE_ISDN, TYPE_MAIN
//      * - TYPE_OTHER_FAX, TYPE_RADIO, TYPE_TELEX, TYPE_TTY_TDD, TYPE_WORK_MOBILE, TYPE_WORK_PAGER
//      * - TYPE_ASSISTANT, TYPE_MMS
//      *
//      * @param type the type
//      * @return a String with the phone.
//      */
//     String getPhone(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getPhone(int)
//      * @return the map type to phone.
//      */
//     Map<Integer, String> getMapPhone();
// 
//     /**
//      * * ContactsContract.CommonDataKinds.StructuredPostal.TYPE values:
//      *
//      * - TYPE_CUSTOM
//      * - TYPE_HOME
//      * - TYPE_WORK
//      * - TYPE_OTHER
//      *
//      * @param type the type
//      * @return A String with the address
//      */
//     String getAddress(int type);
// 
//     /**
//      * @see com.onegravity.contactpicker.contact.Contact#getAddress(int)
//      * @return the map type to address.
//      */
//     Map<Integer, String> getMapAddress();
// 
//     /**
//      * The contact letter is used in the ContactBadge (if no contact picture can be found).
//      */
//     char getContactLetter();
// 
//     /**
//      * The contact letter according to the sort order is used in the SectionIndexer for the fast
//      * scroll indicator.
//      */
//     char getContactLetter(ContactSortOrder sortOrder);
// 
//     /**
//      * The contact color is used in the ContactBadge (if no contact picture can be found) as
//      * background color.
//      */
//     int getContactColor();
// 
//     /**
//      * Unique key across all contacts that won't change even if the column id changes.
//      */
//     String getLookupKey();
// 
//     Uri getPhotoUri();
// 
//     Set<Long> getGroupIds();
// }


// Path: library/src/main/java/com/onegravity/contactpicker/group/GroupViewHolder.java
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.onegravity.contactpicker.R;
import com.onegravity.contactpicker.contact.Contact;
import java.util.Collection;

/*
 * Copyright (C) 2015-2017 Emanuel Moecklin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.onegravity.contactpicker.group;




public class GroupViewHolder extends RecyclerView.ViewHolder {

    private View mRoot;
    private CheckBox mSelect;
    private TextView mName;
    private TextView mDescription;

    GroupViewHolder(View root) {
        super(root);

        mRoot = root;
        mSelect = (CheckBox) root.findViewById(R.id.select);
        mName = (TextView) root.findViewById(R.id.name);
        mDescription = (TextView) root.findViewById(R.id.description);
    }

    void bind(final Group group) {
        mRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSelect.toggle();
            }
        });

        // main text / title
        mName.setText(group.getDisplayName());

        // description
        Collection<Contact> contacts = group.getContacts();
        Resources res = mRoot.getContext().getResources();
        String desc = res.getQuantityString(R.plurals.cp_group_description, contacts.size(), contacts.size());
        mDescription.setText(desc);

        // check box
        mSelect.setOnCheckedChangeListener(null);
        mSelect.setChecked( group.isChecked() );
        mSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override