• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IFlexible类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中eu.davidea.flexibleadapter.items.IFlexible的典型用法代码示例。如果您正苦于以下问题:Java IFlexible类的具体用法?Java IFlexible怎么用?Java IFlexible使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IFlexible类属于eu.davidea.flexibleadapter.items包,在下文中一共展示了IFlexible类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onItemClick

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public boolean onItemClick(int position) {
	IFlexible flexibleItem = mAdapter.getItem(position);
	if (flexibleItem instanceof OverallItem) {
		OverallItem overallItem = (OverallItem) flexibleItem;
		MenuItem menuItem = mNavigationView.getMenu().findItem(overallItem.getId());
		onNavigationItemSelected(menuItem);
		return false;
	}

	// Action on elements are allowed if Mode is IDLE, otherwise selection has priority
	if (mAdapter.getMode() != SelectableAdapter.MODE_IDLE && mActionModeHelper != null) {
		boolean activate = mActionModeHelper.onClick(position);
		Log.d(TAG, "Last activated position " + mActionModeHelper.getActivatedPosition());
		return activate;
	} else {
		// Notify the active callbacks or implement a custom action onClick
		if (flexibleItem instanceof SimpleItem || flexibleItem instanceof SubItem) {
			//TODO FOR YOU: call your custom Action on item click
			String title = extractTitleFrom(flexibleItem);
			EditItemDialog.newInstance(title, position).show(getFragmentManager(), EditItemDialog.TAG);
		}
		return false;
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:MainActivity.java


示例2: extractTitleFrom

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private String extractTitleFrom(IFlexible flexibleItem) {
	if (flexibleItem instanceof AbstractItem) {
		AbstractItem exampleItem = (AbstractItem) flexibleItem;
		String title = exampleItem.getTitle();
		if (exampleItem instanceof ExpandableItem) {
			ExpandableItem expandableItem = (ExpandableItem) flexibleItem;
			if (expandableItem.getSubItems() != null) {
				title += "(+" + expandableItem.getSubItems().size() + ")";
			}
		}
		return title;
	} else if (flexibleItem instanceof HeaderItem) {
		HeaderItem headerItem = (HeaderItem) flexibleItem;
		return headerItem.getTitle();
	}
	// We already covered all situations with instanceof
	return "";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:MainActivity.java


示例3: compare

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public int compare(IFlexible lhs, IFlexible rhs) {
	int result = 0;
	if (lhs instanceof StaggeredHeaderItem && rhs instanceof StaggeredHeaderItem) {
		result = ((StaggeredHeaderItem) lhs).getOrder() - ((StaggeredHeaderItem) rhs).getOrder();
	} else if (lhs instanceof StaggeredItem && rhs instanceof StaggeredItem) {
		result = ((StaggeredItem) lhs).getHeader().getOrder() - ((StaggeredItem) rhs).getHeader().getOrder();
		if (result == 0)
			result = ((StaggeredItem) lhs).getId() - ((StaggeredItem) rhs).getId();
	} else if (lhs instanceof StaggeredItem && rhs instanceof StaggeredHeaderItem) {
		result = ((StaggeredItem) lhs).getHeader().getOrder() - ((StaggeredHeaderItem) rhs).getOrder();
	} else if (lhs instanceof StaggeredHeaderItem && rhs instanceof StaggeredItem) {
		result = ((StaggeredHeaderItem) lhs).getOrder() - ((StaggeredItem) rhs).getHeader().getOrder();
	}
	return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DatabaseService.java


示例4: compare

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public int compare(IFlexible v1, IFlexible v2) {
	int result = 0;
	if (v1 instanceof SimpleHeader && v2 instanceof SimpleHeader) {
		result = ((SimpleHeader) v1).title.compareTo(((SimpleHeader) v2).title);

	} else if (v1 instanceof SimpleItem && v2 instanceof SimpleItem) {
		result = ((SimpleItem) v1).getHeader().title.compareTo(((SimpleItem) v2).getHeader().title);
		if (result == 0)
			result = ((SimpleItem) v1).title.compareTo(((SimpleItem) v2).title);

	} else if (v1 instanceof SimpleItem && v2 instanceof SimpleHeader) {
		result = ((SimpleItem) v1).getHeader().title.compareTo(((SimpleHeader) v2).title);
		if (result == 0) result--;

	} else if (v1 instanceof SimpleHeader && v2 instanceof SimpleItem) {
		result = ((SimpleHeader) v1).title.compareTo(((SimpleItem) v2).getHeader().title);
		if (result == 0) result--;
	}
	return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ItemComparatorTest.java


示例5: onItemSwipe

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public void onItemSwipe(int position, int direction) {
    List<Integer> positions = new ArrayList<>(1);
    positions.add(position);
    // Build the message
    IFlexible abstractItem = adapter.getItem(position);
    // Experimenting NEW feature
    if (abstractItem.isSelectable()) {
        adapter.setRestoreSelectionOnUndo(false);
    }

    if (direction == ItemTouchHelper.LEFT) {
        FavouriteJourneysActivity.this.startActivity(setISearchIntent(true, ((FavouriteJourneysItem) presenter.getRecyclerViewList().get(position)).getPreferredJourney().swapStations()));
        overridePendingTransition(R.anim.slide_right_in, R.anim.slide_out_right);
    } else if (direction == ItemTouchHelper.RIGHT) {
        FavouriteJourneysActivity.this.startActivity(setISearchIntent(false, ((FavouriteJourneysItem) presenter.getRecyclerViewList().get(position)).getPreferredJourney()));
        overridePendingTransition(R.anim.slide_left_in, R.anim.slide_out_left);
    }
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:20,代码来源:FavouriteJourneysActivity.java


示例6: extractTitleFrom

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private String extractTitleFrom(IFlexible flexibleItem) {
    if (flexibleItem instanceof AbstractItem) {
        AbstractItem exampleItem = (AbstractItem) flexibleItem;
        String title = exampleItem.getTitle();
        if (exampleItem instanceof ExpandableItem) {
            ExpandableItem expandableItem = (ExpandableItem) flexibleItem;
            if (expandableItem.getSubItems() != null) {
                title += "(+" + expandableItem.getSubItems().size() + ")";
            }
        }
        return title;
    } else if (flexibleItem instanceof HeaderItem) {
        HeaderItem headerItem = (HeaderItem) flexibleItem;
        return headerItem.getTitle();
    }
    // We already covered all situations with instanceof
    return "";
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:19,代码来源:MainActivity.java


示例7: updateNewItems

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
/**
 * This demonstrates that new content of existing items are really rebound and
 * notified with CHANGE Payload in the Adapter list when refreshed.
 */
public void updateNewItems() {
    IHeader header = null;
    for (IFlexible iFlexible : mItems) {
        if (iFlexible instanceof AbstractItem) {
            AbstractItem item = (AbstractItem) iFlexible;
            item.increaseUpdates();
        }
        if (iFlexible instanceof ISectionable) {
            IHeader newHeader = ((ISectionable) iFlexible).getHeader();
            if (newHeader instanceof HeaderItem && !newHeader.equals(header)) {
                header = newHeader;
                HeaderItem headerItem = (HeaderItem) header;
                headerItem.increaseUpdates();
            }
        }
    }
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:22,代码来源:DatabaseService.java


示例8: compare

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public int compare(IFlexible lhs, IFlexible rhs) {
    int result = 0;
    if (lhs instanceof StaggeredHeaderItem && rhs instanceof StaggeredHeaderItem) {
        result = ((StaggeredHeaderItem) lhs).getOrder() - ((StaggeredHeaderItem) rhs).getOrder();
    } else if (lhs instanceof StaggeredItem && rhs instanceof StaggeredItem) {
        result = ((StaggeredItem) lhs).getHeader().getOrder() - ((StaggeredItem) rhs).getHeader().getOrder();
        if (result == 0)
            result = ((StaggeredItem) lhs).getId() - ((StaggeredItem) rhs).getId();
    } else if (lhs instanceof StaggeredItem && rhs instanceof StaggeredHeaderItem) {
        result = ((StaggeredItem) lhs).getHeader().getOrder() - ((StaggeredHeaderItem) rhs).getOrder();
    } else if (lhs instanceof StaggeredHeaderItem && rhs instanceof StaggeredItem) {
        result = ((StaggeredHeaderItem) lhs).getOrder() - ((StaggeredItem) rhs).getHeader().getOrder();
    }
    return result;
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:17,代码来源:DatabaseService.java


示例9: compare

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public int compare(IFlexible v1, IFlexible v2) {
    int result = 0;
    if (v1 instanceof SimpleHeader && v2 instanceof SimpleHeader) {
        result = ((SimpleHeader) v1).title.compareTo(((SimpleHeader) v2).title);

    } else if (v1 instanceof SimpleItem && v2 instanceof SimpleItem) {
        result = ((SimpleItem) v1).getHeader().title.compareTo(((SimpleItem) v2).getHeader().title);
        if (result == 0)
            result = ((SimpleItem) v1).title.compareTo(((SimpleItem) v2).title);

    } else if (v1 instanceof SimpleItem && v2 instanceof SimpleHeader) {
        result = ((SimpleItem) v1).getHeader().title.compareTo(((SimpleHeader) v2).title);
        if (result == 0) result--;

    } else if (v1 instanceof SimpleHeader && v2 instanceof SimpleItem) {
        result = ((SimpleHeader) v1).title.compareTo(((SimpleItem) v2).getHeader().title);
        if (result == 0) result--;
    }
    return result;
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:22,代码来源:ItemComparatorTest.java


示例10: addItemToSection

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
/**
 * Adds a new item in a section when the relative position is <b>unknown</b>.
 * <p>The header can be a {@code IExpandable} type or {@code IHeader} type.</p>
 * The Comparator object must support <u>all</u> the item types this Adapter is displaying or
 * a ClassCastException will be raised.
 *
 * @param sectionable the item to add
 * @param header      the section receiving the new item
 * @param comparator  the criteria to sort the sectionItems used to extract the correct position
 *                    of the new item in the section
 * @return the calculated final position for the new item
 * @see #addItemToSection(ISectionable, IHeader, int)
 * @since 5.0.0-b6
 */
public int addItemToSection(@NonNull ISectionable sectionable, @Nullable IHeader header,
                            @Nullable Comparator<IFlexible> comparator) {
    int index;
    if (header != null && !header.isHidden()) {
        List<ISectionable> sectionItems = getSectionItems(header);
        sectionItems.add(sectionable);
        //Sort the list for new position
        Collections.sort(sectionItems, comparator);
        //Get the new position
        index = sectionItems.indexOf(sectionable);
    } else {
        index = calculatePositionFor(sectionable, comparator);
    }
    return addItemToSection(sectionable, header, index);
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:30,代码来源:FlexibleAdapter.java


示例11: createList

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private List<IFlexible> createList(int size, int headers) {
	HeaderItem header = null;
	List<IFlexible> items = new ArrayList<>();
	int lastHeaderId = 0;
	for (int i = 0; i < size; i++) {
		header = i % Math.round(size / headers) == 0 ?
				DatabaseService.newHeader(++lastHeaderId) : header;
		items.add(DatabaseService.newSimpleItem(i + 1, header));
	}
	return items;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FragmentViewPager.java


示例12: updateNewItems

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
/**
 * This demonstrates that new content of existing items are really rebound and
 * notified with CHANGE Payload in the Adapter list when refreshed.
 */
public void updateNewItems() {
	for (IFlexible iFlexible : mItems) {
		if (iFlexible instanceof AbstractItem) {
			AbstractItem item = (AbstractItem) iFlexible;
			item.increaseUpdates();
		}
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:DatabaseService.java


示例13: getItemViewType

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
/**
 * METHOD A - NEW! Via Model objects. In this case you don't need to implement this method!
 * METHOD B - You override and implement this method as you prefer (don't call super).
 */
@Override
public int getItemViewType(int position) {
	IFlexible item = getItem(position);
	if (item instanceof ScrollableUseCaseItem) return R.layout.recycler_scrollable_usecase_item;
	else if (item instanceof ScrollableLayoutItem) return R.layout.recycler_scrollable_layout_item;
	else return R.layout.recycler_overall_item;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:OverallAdapter.java


示例14: onItemClick

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public boolean onItemClick(int position) {
    IFlexible item = adapter.getItem(position);
    if (!(item instanceof AttendanceItem)) return true;
    presenter.attendanceClicked(((AttendanceItem) item).getAttendance());
    return true;
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:8,代码来源:AttendanceFragment.java


示例15: onItemClick

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
public boolean onItemClick(int position) {
    IFlexible item = adapter.getItem(position);
    if (item instanceof LessonItem) {
        EnrichedLesson lesson = ((LessonItem) item).getLesson();
        presenter.lessonClicked(lesson);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:11,代码来源:TimetableFragment.java


示例16: mapLessonsForWeek

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private Stream<IFlexible> mapLessonsForWeek(SchoolWeek schoolWeek) {
    Stream.Builder<IFlexible> builder = RefStreams.builder();

    Map<LocalDate, List<EnrichedLesson>> days = StreamSupport.stream(schoolWeek.lessons())
            .collect(Collectors.groupingBy(EnrichedLesson::date));
    for (LocalDate date = schoolWeek.weekStart(); date.isBefore(schoolWeek.weekStart().plusWeeks(1)); date = date.plusDays(1)) {
        LessonHeaderItem header = new LessonHeaderItem(date);
        List<EnrichedLesson> schoolDay = days.get(date);
        if (schoolDay == null || schoolDay.isEmpty()) {
            builder.add(new EmptyDayItem(header, date));
        } else {
            ImmutableMap<Integer, EnrichedLesson> lessonMap = Maps.uniqueIndex(schoolDay, BaseLesson::lessonNo);

            int maxLessonNumber = Collections.max(lessonMap.keySet());
            int minLessonNumber = Collections.min(lessonMap.keySet());

            minLessonNumber = Math.min(1, minLessonNumber);

            for (int l = minLessonNumber; l <= maxLessonNumber; l++) {
                EnrichedLesson lesson = lessonMap.get(l);
                if (lesson != null) {
                    builder.add(new LessonItem(header, lesson, getContext()));
                } else {
                    builder.add(new MissingLessonItem(header, l));
                }
            }
        }
    }
    return builder.build();
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:31,代码来源:TimetableFragment.java


示例17: display

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public void display(List<SchoolWeek> schoolWeeks) {
    adapter.clear();
    List<IFlexible> elements = StreamSupport.stream(schoolWeeks)
            .flatMap(this::mapLessonsForWeek)
            .collect(Collectors.toList());

    adapter.addItems(0, elements);

}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:11,代码来源:TimetableFragment.java


示例18: display

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
@Override
public void display(List<FullAnnouncement> announcements) {
    AnnouncementHeaders headers = new AnnouncementHeaders(getContext());
    List<IFlexible> announcementItems = StreamSupport.stream(announcements)
            .map(a -> new AnnouncementItem(a, headers.getHeaderOf(a)))
            .sorted(ordering)
            .collect(toList());

    adapter.clear();
    adapter.setDisplayHeadersAtStartUp(true);
    adapter.addItems(0, announcementItems);
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:13,代码来源:AnnouncementsFragment.java


示例19: onClick

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private boolean onClick(int position) {
    IFlexible item = adapter.getItem(position);
    if (!(item instanceof AnnouncementItem)) return false;

    AnnouncementItem announcementItem = (AnnouncementItem) item;
    presenter.displayDetails(announcementItem);

    return true;
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:10,代码来源:AnnouncementsFragment.java


示例20: createList

import eu.davidea.flexibleadapter.items.IFlexible; //导入依赖的package包/类
private List<IFlexible> createList(int size, int headers) {
    HeaderItem header = null;
    List<IFlexible> items = new ArrayList<>();
    int lastHeaderId = 0;
    for (int i = 0; i < size; i++) {
        header = i % Math.round(size / headers) == 0 ?
                DatabaseService.newHeader(++lastHeaderId) : header;
        items.add(DatabaseService.newSimpleItem(i + 1, header));
    }
    return items;
}
 
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:12,代码来源:FragmentViewPager.java



注:本文中的eu.davidea.flexibleadapter.items.IFlexible类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EConfig类代码示例发布时间:2022-05-23
下一篇:
Java TransactionListener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap