// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
// 
//     private String name;
//     private String email;
//     private String phone;
//     private Uri imageUri;
// 
//     public ContactModel(String name, String phone) {
//         this.name = name;
//         this.phone = phone;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPhone() {
//         return phone;
//     }
// 
//     public void setPhone(String phone) {
//         this.phone = phone;
//     }
// 
//     public Uri getImageUri() {
//         return imageUri;
//     }
// 
//     public void setImageUri(Uri imageUri) {
//         this.imageUri = imageUri;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder builder = new StringBuilder("Contact --> ");
//         builder.append(name).append(" - ").append(email).append(" - ").append(phone);
//         return builder.toString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(this.name);
//         dest.writeString(this.email);
//         dest.writeString(this.phone);
//         dest.writeParcelable(this.imageUri, 0);
//     }
// 
//     private ContactModel(Parcel in) {
//         this.name = in.readString();
//         this.email = in.readString();
//         this.phone = in.readString();
//         this.imageUri = in.readParcelable(Uri.class.getClassLoader());
//     }
// 
//     public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
//         public ContactModel createFromParcel(Parcel source) {
//             return new ContactModel(source);
//         }
// 
//         public ContactModel[] newArray(int size) {
//             return new ContactModel[size];
//         }
//     };
// }
// 
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
// 
//     public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
//         Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
//     }
// 
// }


import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils;
/**
 * Copyright (C) 2015 Cesar Valiente (cesar.valiente@gmail.com)
 *
 * 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;




/**
 * Created by Cesar on 06/09/15.
 */
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {

    private Context context;
    private List<ContactModel> contactsList;

    public Adapter(Context context, List<ContactModel> contactsList) {
        this.context = context;
        this.contactsList = contactsList;
    }

    @Override
    public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_cardview, parent, false);
        return new ContactViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ContactViewHolder holder, int position) {
        ContactModel contact = contactsList.get(position);
        holder.name.setText(contact.getName());
        holder.email.setText(contact.getEmail());
        holder.phone.setText(contact.getPhone());
        int width = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_width);
        int height = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_height);
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
// 
//     private String name;
//     private String email;
//     private String phone;
//     private Uri imageUri;
// 
//     public ContactModel(String name, String phone) {
//         this.name = name;
//         this.phone = phone;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPhone() {
//         return phone;
//     }
// 
//     public void setPhone(String phone) {
//         this.phone = phone;
//     }
// 
//     public Uri getImageUri() {
//         return imageUri;
//     }
// 
//     public void setImageUri(Uri imageUri) {
//         this.imageUri = imageUri;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder builder = new StringBuilder("Contact --> ");
//         builder.append(name).append(" - ").append(email).append(" - ").append(phone);
//         return builder.toString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(this.name);
//         dest.writeString(this.email);
//         dest.writeString(this.phone);
//         dest.writeParcelable(this.imageUri, 0);
//     }
// 
//     private ContactModel(Parcel in) {
//         this.name = in.readString();
//         this.email = in.readString();
//         this.phone = in.readString();
//         this.imageUri = in.readParcelable(Uri.class.getClassLoader());
//     }
// 
//     public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
//         public ContactModel createFromParcel(Parcel source) {
//             return new ContactModel(source);
//         }
// 
//         public ContactModel[] newArray(int size) {
//             return new ContactModel[size];
//         }
//     };
// }
// 
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
// 
//     public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
//         Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
//     }
// 
// }


// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/recyclerview/Adapter.java
import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils;

/**
 * Copyright (C) 2015 Cesar Valiente (cesar.valiente@gmail.com)
 *
 * 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;




/**
 * Created by Cesar on 06/09/15.
 */
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {

    private Context context;
    private List<ContactModel> contactsList;

    public Adapter(Context context, List<ContactModel> contactsList) {
        this.context = context;
        this.contactsList = contactsList;
    }

    @Override
    public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_cardview, parent, false);
        return new ContactViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ContactViewHolder holder, int position) {
        ContactModel contact = contactsList.get(position);
        holder.name.setText(contact.getName());
        holder.email.setText(contact.getEmail());
        holder.phone.setText(contact.getPhone());
        int width = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_width);
        int height = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_height);
        ImageUtils.loadImage(context, contact.getImageUri(), holder.photo, width, height);