# adapter-kit
**Repository Path**: chinasoft4_ohos/adapter-kit
## Basic Information
- **Project Name**: adapter-kit
- **Description**: 一组有用的适配器套件
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2021-07-12
- **Last Updated**: 2021-09-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# adapter-kit
#### 项目介绍
- 项目名称:adapter-kit
- 所属系列:openharmony的第三方组件适配移植
- 功能:一组有用的适配器套件,该套件当前包括,即时适配器,简单部分适配器,循环列表适配器.
- 项目移植状态:主功能完成
- 调用差异:有,滑动到第一个或最后一个页面出现圆弧效果为原生自带,openharmony暂无效果
- 开发版本:sdk6,DevEco Studio 2.2 Beta1
- 基线版本:Release 0.5.3
#### 效果演示
#### 安装教程
1.在项目根目录下的build.gradle文件中,
```gradle
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
}
```
2.在entry模块的build.gradle文件中,
```gradle
dependencies {
implementation('com.gitee.chinasoft_ohos:adapter-kit:1.0.0')
}
```
在sdk6,DevEco Studio2.2 beta1下项目可直接运行
如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
#### 使用说明
##### 1.InstantAdapter
为特定布局适配数据,通过注解绑定数据与布局,进行填充数据。
1.设置数据,在设置数据类型上需要展示的数据上添加 InstantText 绑定 需要展示的位置
```
public class Book {
@InstantText(viewId = ResourceTable.Id_bookName)
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
@InstantText(viewId = ResourceTable.Id_bookAuthorName)
public String getBookAuthor() {
return bookAuthor;
}
public void setBookAuthor(String bookAuthor) {
this.bookAuthor = bookAuthor;
}
}
```
2.List主布局
```示例XML
```
3.Item布局中展示view Id应与绑定的数据注解一致
```
```
4.设置适配器
```
ListContainer listContainer = (ListContainer) component.findComponentById(ResourceTable.Id_list);
InstantAdapter bookListAdapter = new InstantAdapter (
getFractionAbility(), ResourceTable.Layout_list_layout, Book.class,
BooksDao.getAllBooks());
listContainer.setItemProvider(bookListAdapter);
```
只需提供item布局和数据bean类和数据,就可一次性将数据设置进list展示。
##### 2.SimpleSectionAdapter
需要把不同类型的数据填充到不同的布局中
第一第二第三步骤与InstantAdapter一致
4.设置适配器
```
//基于InstantAdapter布局自定义
InstantAdapter bookListAdapter = new InstantAdapter(
getFractionAbility(), ResourceTable.Layout_list_layout, Book.class, books);
SimpleSectionAdapter sectionedAdapter =
new SimpleSectionAdapter(getFractionAbility(),
bookListAdapter,
ResourceTable.Layout_section_header,
ResourceTable.Id_section_text,
new Sectionizer() {
@Override
public String getSectionTitleForItem(Book instance) { //为第二种布局填充的数据
return instance.getBookCategory();
}
});
ListContainer listContainer = (ListContainer) component.findComponentById(ResourceTable.Id_list);
listContainer.setItemProvider(sectionedAdapter);
```
##### 3.CircularListAdapter
```
//基于InstantAdapter使用
InstantAdapter bookListAdapter = new InstantAdapter(getFractionAbility(), ResourceTable.Layout_list_layout, Book.class,BooksDao.getAllBooks());
ListContainer bookListView = (ListContainer) component.findComponentById(ResourceTable.Id_list);
bookListView.setItemProvider(new CircularListAdapter(bookListAdapter));
```
#### 测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
#### 版本迭代
- 1.0.0
#### 版权和许可信息
Copyright 2013 Mobs & Geeks
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.