# FlexibleAdapter **Repository Path**: hihopeorg/FlexibleAdapter ## Basic Information - **Project Name**: FlexibleAdapter - **Description**: lexibleAdapter是一个灵活的ListContainer适配器,可以帮助开发人员简化ListContainer的使用。它很容易使用,并且是可配置的 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-03-24 - **Last Updated**: 2021-11-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FlexibleAdapter **本项目是基于开源项目FlexibleAdapter进行ohos化的移植和开发的,可以通过项目标签以及github地址( https://github.com/davideas/FlexibleAdapter )追踪到原项目版本** ## 项目介绍 - 项目名称:FlexibleAdapter - 所属系列:ohos的第三方组件适配移植 - 功能:FlexibleAdapter是一个灵活的ListContainer适配器,可以帮助开发人员简化ListContainer的使用。它很容易使用,并且是可配置的。 - 项目移植状态:完成 - 调用差异:无 - 项目作者和维护人:hihope - 联系方式:hihope@hoperun.com - 原项目Doc地址:https://github.com/davideas/FlexibleAdapter - 原项目基线版本:v5.1.0, sha1:10933e8501a15f6fc9c6ecdfafc4bb8732a58e34 - 编程语言:Java - 外部库依赖:无 ## 效果展示 ![p1](picture/FlexibleAdapter.gif) ## 安装教程 方法一: 1. 编译har包flexible_adapter.har和flexible_adapter_ui.har。 2. 启动 DevEco Studio,将har包导入工程目录“entry->libs”下。 3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。 ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) } ``` 4. 在导入的har包上点击右键,选择“Add as Library”对包进行引用,选择需要引用的模块,并点击“OK”即引用成功。 方法二: 1. 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址 ``` repositories { maven { url 'http://106.15.92.248:8081/repository/Releases/' } } ``` 2. 在应用模块的build.gradle的dependencies闭包中,添加如下代码: ``` dependencies { implementation 'eu.davidea.flexible.ohos:FlexibleAdapter:1.0.1' implementation 'eu.davidea.flexible.ohos:FlexibleAdapterUI:1.0.1' } ``` ## 使用说明 1. 继承'AbstractItem'来创建自定义列表Item,也可以使用'IExpandable'、'IHeader'、'ISectionable'、'IFilterable'、 'IHolder'等接口来创建更加强大的Item。 附带Sample中定义的items位于eu.davidea.samples.items包下,不同的组合关系如下表: | Item type to display | Item interfaces to implement | | ---------------- | ---------------------------- | | Simple adapter item | IFlexible (AbstractFlexibleItem) | | Expandable item | IFlexible + IExpandable (AbstractExpandableItem) | | SubItem for expandable| IFlexible (AbstractFlexibleItem) | | Header item (with sticky functionality) | IFlexible + IHeader (AbstractHeaderItem) | | Expandable header item (with sticky functionality) | IFlexible + IExpandable + IHeader (AbstractExpandableHeaderItem) | | Section simple item for header | IFlexible + ISectionable (AbstractSectionableItem) | | Section SubItem for expandable header | IFlexible + ISectionable (AbstractSectionableItem) | | Section expandable item for header | IFlexible + ISectionable + IExpandable (AbstractExpandableItem + ISectionable) | | Add filter functionality to any previous item | ... + IFilterable | | Add Model holder functionality to any previous item | ... + IHolder | 2. 定义ListContainer和FlexibleAdapter,并设置FlexibleAdapter相关属性: ```java ListContainer listContainer = (ListContainer)findComponentById(ResourceTable.Id_list_container); FlexibleAdapter adapter = new FlexibleAdapter<>(items, this, false); adapter.setAnimateChangesWithDiffUtil(false) .setAnimateToLimit(1000) // When true, filtering on big list is very slow! .setNotifyMoveOfFilteredItems(false) .setNotifyChangeOfUnfilteredItems(true) .setAnimationInitialDelay(100L); listContainer.setItemProvider(adapter); ``` ## 版本迭代 - v1.0.1 ## 版权和许可信息 #### FlexibleAdapter & Extensions Copyright 2015-2018 Davide Steduto, Davidea Solutions Sprl Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #### FastScroller Copyright 2016-2017 AndroidDeveloperLB, Davide Steduto & Arpinca Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.