本文整理汇总了Java中com.mikepenz.fastadapter.FastAdapter类的典型用法代码示例。如果您正苦于以下问题:Java FastAdapter类的具体用法?Java FastAdapter怎么用?Java FastAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FastAdapter类属于com.mikepenz.fastadapter包,在下文中一共展示了FastAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleStates
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* internal method which correctly set the selected state and expandable state on the newly added items
*
* @param fastAdapter the fastAdapter which manages everything
* @param startPosition the position of the first item to handle
* @param endPosition the position of the last item to handle
*/
public static <Item extends IItem> void handleStates(FastAdapter<Item> fastAdapter, int startPosition, int endPosition) {
for (int i = endPosition; i >= startPosition; i--) {
Item updateItem = fastAdapter.getItem(i);
if (updateItem != null) {
if (updateItem.isSelected()) {
fastAdapter.getSelections().add(i);
} else if (fastAdapter.getSelections().contains(i)) {
fastAdapter.getSelections().remove(i);
}
if (updateItem instanceof IExpandable) {
if (((IExpandable) updateItem).isExpanded() && fastAdapter.getExpanded().indexOfKey(i) < 0) {
fastAdapter.expand(i);
}
}
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:AdapterUtil.java
示例2: notifyCommit
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
private void notifyCommit() {
if (mHistory != null) {
if (mHistory.action == ACTION_REMOVE) {
SortedSet<Integer> positions = new TreeSet<>(new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
return lhs.compareTo(rhs);
}
});
for (FastAdapter.RelativeInfo<Item> relativeInfo : mHistory.items) {
positions.add(relativeInfo.position);
}
mUndoListener.commitRemove(positions, mHistory.items);
mHistory = null;
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:UndoHelper.java
示例3: onCreateView
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
context = super.getActivity();
View ourView = inflater.inflate(R.layout.fragment_bookmarks, container, false);
noBookmarksLayout = (LinearLayout) ourView.findViewById(R.id.no_bookmarks_layout);
bookmarksList = (RecyclerView) ourView.findViewById(R.id.bookmarks_list);
fastAdapter = new FastAdapter();
itemFastAdapter = new ItemAdapter<>();
fastAdapter.withSelectOnLongClick(false);
fastAdapter.withSelectable(false);
fastAdapter.withOnLongClickListener(this);
bookmarksList.setLayoutManager(new LinearLayoutManager(context));
bookmarksList.setAdapter(itemFastAdapter.wrap(fastAdapter));
return ourView;
}
开发者ID:EladKeyshawn,项目名称:HackList,代码行数:23,代码来源:FragmentBookmarks.java
示例4: getAllItems
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* Gets all items (including sub items) from the FastAdapter
*
* @param fastAdapter the FastAdapter
* @return a list of all items including the whole subItem hirachy
*/
public static <Item extends IItem> List<Item> getAllItems(FastAdapter<Item> fastAdapter) {
int size = fastAdapter.getItemCount();
List<Item> items = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
Item item = fastAdapter.getItem(i);
items.add(item);
addAllSubItems(item, items);
}
return items;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:AdapterUtil.java
示例5: onClick
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public void onClick(View v, int position, FastAdapter<ImageItem> fastAdapter, ImageItem item) {
item.withStarred(!item.mStarred);
//we animate the heart
item.animateHeart(((ViewGroup) v).getChildAt(0), ((ViewGroup) v).getChildAt(1), item.mStarred);
//we display the info about the click
Toast.makeText(v.getContext(), item.mImageUrl + " - " + item.mStarred, Toast.LENGTH_SHORT).show();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ImageItem.java
示例6: onClick
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public void onClick(View v, int position, FastAdapter<RadioButtonSampleItem> fastAdapter, RadioButtonSampleItem item) {
if (!item.isSelected()) {
Set<Integer> selections = fastAdapter.getSelections();
if (!selections.isEmpty()) {
int selectedPosition = selections.iterator().next();
fastAdapter.deselect();
fastAdapter.notifyItemChanged(selectedPosition);
}
fastAdapter.select(position);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RadioButtonSampleItem.java
示例7: doChange
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
private void doChange() {
if (mHistory != null) {
if (mHistory.action == ACTION_REMOVE) {
for (int i = mHistory.items.size() - 1; i >= 0; i--) {
FastAdapter.RelativeInfo<Item> relativeInfo = mHistory.items.get(i);
if (relativeInfo.adapter instanceof IItemAdapter) {
((IItemAdapter) relativeInfo.adapter).remove(relativeInfo.position);
}
}
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:UndoHelper.java
示例8: getSelectedItems
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* returns a set of selected items, regardless of their visibility
*
* @param adapter the adapter instance
* @return a set of all selected items and subitems
*/
public static Set<IItem> getSelectedItems(FastAdapter adapter) {
Set<IItem> selections = new HashSet<>();
int length = adapter.getItemCount();
List<IItem> items = new ArrayList<>();
for (int i = 0; i < length; i++) {
items.add(adapter.getItem(i));
}
updateSelectedItemsWithCollapsed(selections, items);
return selections;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SubItemUtil.java
示例9: selectAllSubItems
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* select or unselect all sub itmes underneath an expandable item
*
* @param adapter the adapter instance
* @param header the header who's children should be selected or deselected
* @param select the new selected state of the sub items
* @param notifyParent true, if the parent should be notified about the changes of its children selection state
* @param payload payload for the notifying function
*/
public static <T extends IItem & IExpandable> void selectAllSubItems(final FastAdapter adapter, T header, boolean select, boolean notifyParent, Object payload) {
int subItems = header.getSubItems().size();
int position = adapter.getPosition(header);
if (header.isExpanded()) {
for (int i = 0; i < subItems; i++) {
if (((IItem)header.getSubItems().get(i)).isSelectable()) {
if (select) {
adapter.select(position + i + 1);
} else {
adapter.deselect(position + i + 1);
}
}
if (header.getSubItems().get(i) instanceof IExpandable)
selectAllSubItems(adapter, header, select, notifyParent, payload);
}
} else {
for (int i = 0; i < subItems; i++) {
if (((IItem)header.getSubItems().get(i)).isSelectable()) {
((IItem) header.getSubItems().get(i)).withSetSelected(select);
}
if (header.getSubItems().get(i) instanceof IExpandable)
selectAllSubItems(adapter, header, select, notifyParent, payload);
}
}
// we must notify the view only!
if (notifyParent && position >= 0) {
adapter.notifyItemChanged(position, payload);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:SubItemUtil.java
示例10: notifyItemsChanged
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* notifies items (incl. sub items if they are currently extended)
*
* @param adapter the adapter
* @param identifiers set of identifiers that should be notified
* @param restoreExpandedState true, if expanded headers should stay expanded
*/
public static <Item extends IItem & IExpandable> void notifyItemsChanged(final FastAdapter adapter, Set<Long> identifiers, boolean restoreExpandedState) {
int i;
IItem item;
for (i = 0; i < adapter.getItemCount(); i++) {
item = adapter.getItem(i);
if (item instanceof IExpandable) {
notifyItemsChanged(adapter, (Item) item, identifiers, true, restoreExpandedState);
} else if (identifiers.contains(item.getIdentifier())) {
adapter.notifyAdapterItemChanged(i);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:SubItemUtil.java
示例11: onEventOccurred
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
protected final void onEventOccurred(View view, RecyclerView.ViewHolder viewHolder, FastAdapter<T> fastAdapter)
{
//we get the adapterPosition from the viewHolder
int pos = fastAdapter.getHolderAdapterPosition(viewHolder);
//make sure the click was done on a valid item
if (pos != RecyclerView.NO_POSITION) {
//we update our item with the changed property
onEvent(view, pos, fastAdapter, fastAdapter.getItem(pos), viewHolder);
}
}
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:11,代码来源:BaseCustomEventHook.java
示例12: createRecyclerView
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
private RecyclerView createRecyclerView(FastAdapter adapter, int gravity, int paddingHorizontal) {
RecyclerView actionRecyclerView = new RecyclerView(getContext());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
actionRecyclerView.setClipToPadding(false);
actionRecyclerView.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
actionRecyclerView.setLayoutManager(linearLayoutManager);
actionRecyclerView.setAdapter(adapter);
actionRecyclerView.setOverScrollMode(OVER_SCROLL_ALWAYS);
LayoutParams actionRecyclerViewLP = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
actionRecyclerViewLP.gravity = gravity;
addView(actionRecyclerView, actionRecyclerViewLP);
return actionRecyclerView;
}
开发者ID:OpenLauncherTeam,项目名称:openlauncher,代码行数:15,代码来源:DesktopOptionView.java
示例13: getAdapter
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* get the adapter (null safe)
*
* @return the FastAdapter used with this drawer
*/
protected FastAdapter<IDrawerItem> getAdapter() {
if (mAdapter == null) {
mAdapter = new FastAdapter<>();
mAdapter.withSelectable(true);
mAdapter.withAllowDeselection(false);
mAdapter.setHasStableIds(mHasStableIds);
mAdapter.withPositionBasedStateManagement(mPositionBasedStateManagement);
//we wrap our main Adapter with the item hosting adapter
mHeaderAdapter.wrap(mItemAdapter.wrap(mFooterAdapter.wrap(mAdapter)));
}
return mAdapter;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:19,代码来源:DrawerBuilder.java
示例14: bindView
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder, List payloads) {
super.bindView(viewHolder, payloads);
viewHolder.tag.setImageTintList(ColorStateList.valueOf(palette.getPrimary()));
withOnItemClickListener(new FastAdapter.OnClickListener<TagItem>() {
@Override
public boolean onClick(View v, IAdapter<TagItem> adapter, TagItem item, int position) {
App.BUS.post(new TagClicked(palette.getName()));
return true;
}
});
}
开发者ID:liamspradlin,项目名称:Phoebe,代码行数:14,代码来源:TagItem.java
示例15: bindView
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder, List payloads) {
super.bindView(viewHolder, payloads);
viewHolder.title.setText(getAbout().getTitle());
withOnItemClickListener(new FastAdapter.OnClickListener<AboutItem>() {
@Override
public boolean onClick(View v, IAdapter<AboutItem> adapter, AboutItem item, int position) {
App.BUS.post(new AboutUrlClicked(getAbout()));
return true;
}
});
}
开发者ID:liamspradlin,项目名称:Phoebe,代码行数:15,代码来源:AboutItem.java
示例16: onClick
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
public void onClick(View view, int i, FastAdapter<AbstractItem> fastAdapter, AbstractItem item) {
IExpandable it = (IExpandable) item;
if (it.isExpanded()) {
fastAdapter.collapse(i);
ViewCompat.animate(view).rotation(0);
} else {
fastAdapter.expand(i);
ViewCompat.animate(view).rotation(180);
}
}
开发者ID:citiususc,项目名称:calendula,代码行数:12,代码来源:AllergenGroupItem.java
示例17: ClickListenerHelper
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* @param fastAdapter the fastAdapter which manages these items
* @param eventHooks the event hooks we want to use for this item
*/
public ClickListenerHelper(FastAdapter<Item> fastAdapter, List<EventHook<Item>> eventHooks) {
this.mFastAdapter = fastAdapter;
this.eventHooks = eventHooks;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ClickListenerHelper.java
示例18: getOnPreItemClickListener
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* @return the on PRE item click listener
*/
public FastAdapter.OnClickListener<Item> getOnPreItemClickListener() {
return mOnItemPreClickListener;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:AbstractItem.java
示例19: getOnItemClickListener
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
/**
* @return the OnItemClickListener
*/
public FastAdapter.OnClickListener<Item> getOnItemClickListener() {
return mOnItemClickListener;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:AbstractItem.java
示例20: onCreate
import com.mikepenz.fastadapter.FastAdapter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.sample_generic_item);
//style our ui
new MaterializeBuilder().withActivity(this).build();
//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter();
fastAdapter.withSelectable(true);
//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
//init our gridLayoutManager and configure RV
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(new Function<IconModel, GenericIconItem>() {
@Override
public GenericIconItem apply(IconModel iconModel) {
return new GenericIconItem(iconModel);
}
});
final FastScrollIndicatorAdapter<GenericIconItem> fastScrollIndicatorAdapter = new FastScrollIndicatorAdapter<>();
rv.setAdapter(fastScrollIndicatorAdapter.wrap(itemAdapter.wrap(fastAdapter)));
DragScrollBar materialScrollBar = new DragScrollBar(this, rv, true);
materialScrollBar.setHandleColour(ContextCompat.getColor(this, R.color.colorAccent));
materialScrollBar.setHandleOffColour(ContextCompat.getColor(this, R.color.colorAccent));
materialScrollBar.addIndicator(new CustomIndicator(this), true);
rv.setLayoutManager(gridLayoutManager);
rv.setItemAnimator(new SlideDownAlphaAnimator());
//order fonts by their name
List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
Collections.sort(mFonts, new Comparator<ITypeface>() {
@Override
public int compare(final ITypeface object1, final ITypeface object2) {
return object1.getFontName().compareTo(object2.getFontName());
}
});
//add all icons of all registered Fonts to the list
ArrayList<IconModel> models = new ArrayList<>();
for (ITypeface font : mFonts) {
for (String icon : font.getIcons()) {
models.add(new IconModel(font.getIcon(icon)));
}
}
//fill with some sample data
itemAdapter.addModel(models);
//restore selections (this has to be done after the items were added
fastAdapter.withSavedInstanceState(savedInstanceState);
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:71,代码来源:GenericItemActivity.java
注:本文中的com.mikepenz.fastadapter.FastAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论