// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
//     static final long serialVersionUID = 4653212L;
// 
//     @SerializedName("displayName")
//     private final String displayName;
// 
//     @SerializedName("id")
//     private final String id;
// 
//     @SerializedName("identifier")
//     private final List<Identifier> identifier;
// 
//     @SerializedName("onTourUntil")
//     private final String onTourUntil;
// 
//     @SerializedName("uri")
//     private final String uri;
// 
//     public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
//             String uri) {
//         this.displayName = displayName;
//         this.id = id;
//         this.identifier = identifier;
//         this.onTourUntil = onTourUntil;
//         this.uri = uri;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public List<Identifier> getIdentifier() {
//         return identifier;
//     }
// 
//     public String getOnTourUntil() {
//         return onTourUntil;
//     }
// 
//     public String getUri() {
//         return uri;
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
//     public static final int TYPE = 48984;
// 
//     SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
//             PublishSubject.<Artist> create());
// 
//     @Override
//     public int getItemViewType() {
//         return TYPE;
//     }
// 
//     @Override
//     public boolean isForViewType(@NonNull List<Artist> items, int position) {
//         return (0 != position || items.size() != 0);
//     }
// 
//     @NonNull
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
//         return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
//                 R.layout.element_artist, parent, false));
//     }
// 
//     @Override
//     public void onBindViewHolder(@NonNull List<Artist> items, int position,
//             @NonNull RecyclerView.ViewHolder holder) {
//         ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
//         final Artist artist = items.get(position);
//         artistViewHolder.name.setText(artist.getDisplayName());
//         artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 artistClicks.onNext(artist);
//             }
//         });
//     }
// 
//     public Observable<Artist> getArtistClicks() {
//         return artistClicks.asObservable();
//     }
// 
//     static class ArtistViewHolder extends RecyclerView.ViewHolder {
//         @Bind(R.id.artist_name_txv)
//         TextView name;
// 
//         public ArtistViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
//     private static final int TYPE = 1916;
// 
//     @Override
//     public int getItemViewType() {
//         return TYPE;
//     }
// 
//     @Override
//     public boolean isForViewType(@NonNull List<T> items, int i) {
//         return i == 0 && items.size() == 0;
//     }
// 
//     @NonNull
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
//         return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
//                 R.layout.element_empty, viewGroup, false));
//     }
// 
//     @Override
//     public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
//             @NonNull RecyclerView.ViewHolder viewHolder) {
//         EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
//     }
// 
//     private class EmptyViewHolder extends RecyclerView.ViewHolder {
//         public EmptyViewHolder(View view) {
//             super(view);
//         }
//     }
// }


import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate;
    public int getItemViewType(int position) {
        return delegatesManager.getItemViewType(elementsMap, position);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return delegatesManager.onCreateViewHolder(parent, viewType);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        delegatesManager.onBindViewHolder(elementsMap, position, holder);
    }

    @Override
    public int getItemCount() {
        return elementsMap.size() == 0 ? 1 : elementsMap.size();
    }

    public Action1<List<Artist>> swapElements() {
        return new Action1<List<Artist>>() {
            @Override
            public void call(List<Artist> newElements) {
                elementsMap.clear();
                elementsMap.addAll(newElements);
                notifyDataSetChanged();
            }
        };
    }

// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
//     static final long serialVersionUID = 4653212L;
// 
//     @SerializedName("displayName")
//     private final String displayName;
// 
//     @SerializedName("id")
//     private final String id;
// 
//     @SerializedName("identifier")
//     private final List<Identifier> identifier;
// 
//     @SerializedName("onTourUntil")
//     private final String onTourUntil;
// 
//     @SerializedName("uri")
//     private final String uri;
// 
//     public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
//             String uri) {
//         this.displayName = displayName;
//         this.id = id;
//         this.identifier = identifier;
//         this.onTourUntil = onTourUntil;
//         this.uri = uri;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public List<Identifier> getIdentifier() {
//         return identifier;
//     }
// 
//     public String getOnTourUntil() {
//         return onTourUntil;
//     }
// 
//     public String getUri() {
//         return uri;
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
//     public static final int TYPE = 48984;
// 
//     SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
//             PublishSubject.<Artist> create());
// 
//     @Override
//     public int getItemViewType() {
//         return TYPE;
//     }
// 
//     @Override
//     public boolean isForViewType(@NonNull List<Artist> items, int position) {
//         return (0 != position || items.size() != 0);
//     }
// 
//     @NonNull
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
//         return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
//                 R.layout.element_artist, parent, false));
//     }
// 
//     @Override
//     public void onBindViewHolder(@NonNull List<Artist> items, int position,
//             @NonNull RecyclerView.ViewHolder holder) {
//         ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
//         final Artist artist = items.get(position);
//         artistViewHolder.name.setText(artist.getDisplayName());
//         artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 artistClicks.onNext(artist);
//             }
//         });
//     }
// 
//     public Observable<Artist> getArtistClicks() {
//         return artistClicks.asObservable();
//     }
// 
//     static class ArtistViewHolder extends RecyclerView.ViewHolder {
//         @Bind(R.id.artist_name_txv)
//         TextView name;
// 
//         public ArtistViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
//     private static final int TYPE = 1916;
// 
//     @Override
//     public int getItemViewType() {
//         return TYPE;
//     }
// 
//     @Override
//     public boolean isForViewType(@NonNull List<T> items, int i) {
//         return i == 0 && items.size() == 0;
//     }
// 
//     @NonNull
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
//         return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
//                 R.layout.element_empty, viewGroup, false));
//     }
// 
//     @Override
//     public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
//             @NonNull RecyclerView.ViewHolder viewHolder) {
//         EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
//     }
// 
//     private class EmptyViewHolder extends RecyclerView.ViewHolder {
//         public EmptyViewHolder(View view) {
//             super(view);
//         }
//     }
// }


// Path: app/src/main/java/com/pacoworks/dereference/ui/adapters/ArtistListAdapter.java
import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate;

    public int getItemViewType(int position) {
        return delegatesManager.getItemViewType(elementsMap, position);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return delegatesManager.onCreateViewHolder(parent, viewType);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        delegatesManager.onBindViewHolder(elementsMap, position, holder);
    }

    @Override
    public int getItemCount() {
        return elementsMap.size() == 0 ? 1 : elementsMap.size();
    }

    public Action1<List<Artist>> swapElements() {
        return new Action1<List<Artist>>() {
            @Override
            public void call(List<Artist> newElements) {
                elementsMap.clear();
                elementsMap.addAll(newElements);
                notifyDataSetChanged();
            }
        };
    }

    public Observable<Artist> getArtistClicks() {