Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [V3] New ModelAdapter #482

Merged
merged 4 commits into from
Jul 16, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mikepenz.fastadapter;

import android.support.annotation.NonNull;

import com.mikepenz.fastadapter.utils.DefaultIdDistributorImpl;

import java.util.List;

/**
* Created by fabianterhorst on 16.07.17.
*/
public interface IIdDistributor<Identifiable extends IIdentifyable> {

IIdDistributor<? extends IIdentifyable> DEFAULT = new DefaultIdDistributorImpl<>();

List<Identifiable> checkIds(@NonNull List<Identifiable> items);

Identifiable[] checkIds(@NonNull Identifiable... items);

Identifiable checkId(@NonNull Identifiable item);

long nextId(Identifiable item);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mikepenz.fastadapter;

/**
* Created by mikepenz on 30.12.15.
*/
public interface IInterceptor<Element, Item extends IItem> {

IInterceptor<IItem, IItem> DEFAULT = new IInterceptor<IItem, IItem>() {
@Override
public IItem intercept(IItem item) {
return item;
}
};

Item intercept(Element element);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,102 @@
/**
* Created by mikepenz on 30.12.15.
*/
public interface IItemAdapter<Item extends IItem> extends IAdapter<Item> {
public interface IItemAdapter<Model, Item extends IItem> extends IAdapter<Item> {

/**
* set a new list of items and apply it to the existing list (clear - add) for this adapter
*
* @param items
*/
IItemAdapter<Item> set(List<Item> items);
IItemAdapter<Model, Item> set(List<Model> items);

/**
* sets a complete new list of items onto this adapter, using the new list. Calls notifyDataSetChanged
*
* @param items
*/
IItemAdapter<Item> setNewList(List<Item> items);
IItemAdapter<Model, Item> setNewList(List<Model> items);

/**
* add an array of items to the end of the existing items
*
* @param items
*/
IItemAdapter<Item> add(Item... items);
IItemAdapter<Model, Item> add(Model... items);

/**
* add a list of items to the end of the existing items
*
* @param items
*/
IItemAdapter<Item> add(List<Item> items);
IItemAdapter<Model, Item> add(List<Model> items);

/**
* add a list of items to the end of the existing items
*
* @param items
*/
IItemAdapter<Model, Item> addInternal(List<Item> items);

/**
* add an array of items at the given position within the existing items
*
* @param position the global position
* @param items
*/
IItemAdapter<Item> add(int position, Item... items);
IItemAdapter<Model, Item> add(int position, Model... items);

/**
* add a list of items at the given position within the existing items
*
* @param position the global position
* @param items
*/
IItemAdapter<Model, Item> add(int position, List<Model> items);

/**
* add a list of items at the given position within the existing items
*
* @param position the global position
* @param items
*/
IItemAdapter<Item> add(int position, List<Item> items);
IItemAdapter<Model, Item> addInternal(int position, List<Item> items);

/**
* sets an item at the given position, overwriting the previous item
*
* @param position the global position
* @param item
*/
IItemAdapter<Model, Item> set(int position, Model item);

/**
* sets an item at the given position, overwriting the previous item
*
* @param position the global position
* @param item
*/
IItemAdapter<Item> set(int position, Item item);
IItemAdapter<Model, Item> setInternal(int position, Item item);

/**
* removes an item at the given position within the existing icons
*
* @param position the global position
*/
IItemAdapter<Item> remove(int position);
IItemAdapter<Model, Item> remove(int position);

/**
* removes a range of items starting with the given position within the existing icons
*
* @param position the global position
* @param itemCount
*/
IItemAdapter<Item> removeRange(int position, int itemCount);
IItemAdapter<Model, Item> removeRange(int position, int itemCount);

/**
* removes all items of this adapter
*/
IItemAdapter<Item> clear();
IItemAdapter<Model, Item> clear();

/**
* the interface used to filter the list inside the ItemFilter
Expand Down
Loading