Skip to content

Commit

Permalink
Renamed ItemTypePool to MultiTypePool
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeet committed Aug 11, 2016
1 parent a30df35 commit c8adc87
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public MultiTypeAdapter(@NonNull List<? extends TypeItem> typeItems) {

@Override public int getItemViewType(int position) {
ItemContent content = typeItems.get(position).content;
return ItemTypePool.getContents().indexOf(content.getClass());
return MultiTypePool.getContents().indexOf(content.getClass());
}


Expand All @@ -48,15 +48,15 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int indexViewType) {
if (inflater == null) {
inflater = LayoutInflater.from(parent.getContext());
}
return ItemTypePool.getProviderByIndex(indexViewType).onCreateViewHolder(inflater, parent);
return MultiTypePool.getProviderByIndex(indexViewType).onCreateViewHolder(inflater, parent);
}


@SuppressWarnings("unchecked") @Override
public void onBindViewHolder(ViewHolder holder, int position) {
int type = getItemViewType(position);
TypeItem typeItem = typeItems.get(position);
ItemTypePool.getProviderByIndex(type).onBindViewHolder(holder, typeItem);
MultiTypePool.getProviderByIndex(type).onBindViewHolder(holder, typeItem);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @author drakeet
*/
public final class ItemTypePool {
public final class MultiTypePool {

private static ArrayList<Class<? extends ItemContent>> contents = new ArrayList<>();
private static ArrayList<ItemViewProvider> providers = new ArrayList<>();
Expand Down Expand Up @@ -54,5 +54,4 @@ public synchronized static void register(
@NonNull public static ItemViewProvider getProviderByIndex(int index) {
return providers.get(index);
}

}
8 changes: 4 additions & 4 deletions sample/src/main/java/me/drakeet/multitype/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package me.drakeet.multitype.sample;

import android.app.Application;
import me.drakeet.multitype.ItemTypePool;
import me.drakeet.multitype.MultiTypePool;

/**
* @author drakeet
Expand All @@ -26,8 +26,8 @@ public class App extends Application {

@Override public void onCreate() {
super.onCreate();
ItemTypePool.register(TextItemContent.class, new TextItemViewProvider());
ItemTypePool.register(ImageItemContent.class, new ImageItemViewProvider());
ItemTypePool.register(RichItemContent.class, new RichItemViewProvider());
MultiTypePool.register(TextItemContent.class, new TextItemViewProvider());
MultiTypePool.register(ImageItemContent.class, new ImageItemViewProvider());
MultiTypePool.register(RichItemContent.class, new RichItemViewProvider());
}
}

0 comments on commit c8adc87

Please sign in to comment.