5 Star 6 Fork 1

CHINASOFT5_OHOS/Ohos-MaterialRefreshLayout

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Ohos-MaterialRefreshLayout

项目介绍

  • 项目名称:Ohos-MaterialRefreshLayout
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:Material风格下拉刷新控件
  • 项目移植状态:主功能完成
  • 调用差异: 1.因Paint不支持动态修改颜色,头部刷新旋转圆环无法变色 2.因系统api缺失,头部刷新旋转圆环无法收缩
  • 开发版本:sdk6,DevEco Studio2.2 Beta1
  • 基线版本:Maven v1.3.0

效果演示

效果演示 效果演示 效果演示 效果演示 效果演示

安装教程

1.在项目根目录下的build.gradle文件中,

allprojects {
    repositories {
        maven {
            url 'https://s01.oss.sonatype.org/content/repositories/releases/'
        }
    }
}

2.在entry模块的build.gradle文件中,

 dependencies {
    implementation('com.gitee.chinasoft_ohos:Ohos-MaterialRefreshLayout:1.0.1')
    ......  
 }

在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下

使用说明

1.在布局文件中加入MaterialRefreshLayout控件,代码实例如下:

   <com.cjj.MaterialRefreshLayout
       ohos:height="match_parent"
       ohos:width="match_parent"
       ohos:alignment="center"
       ohos:orientation="vertical"
       app:isLoadMore="true"
       app:overlay="true"
       app:progress_colors="$strarray:material_colors"
       app:progress_show_circle_backgroud="true"
       app:progress_size_type="normal"
       app:wave_color="#90ffffff"
       app:wave_height_type="normal"
       app:wave_show="true">

       <com.ryan.ohos.extension.nested.component.NestedListContainer
            ohos:id="$+id:listcontainer"
            ohos:height="match_parent"
            ohos:width="match_parent"
            />
   
   </com.cjj.MaterialRefreshLayout>

2.实例化它并设置监听,onrefresh是必须实现的,其他都是方法可选,为了代码可读性而设计......

 materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id...);
 materialRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {
      @Override
      public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {
          //refreshing...
      }

       @Override
       public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
       	  //load more refreshing...
       }
  }

// 结束下拉刷新...
materialRefreshLayout.finishRefresh();

// 结束上拉刷新...
materialRefreshLayout.finishRefreshLoadMore();

3.配置
(1)如果你喜欢官方的刷新效果

在xml中, 设置以下属性

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:overlay="true"
    hap:wave_show="false"
    >

在代码中是这样的:

materialRefreshLayout.setIsOverLay(true);
materialRefreshLayout.setWaveShow(false);

(2)如果你喜欢非侵入刷新

在xml中, 设置以下属性

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:overlay="false"
    hap:wave_show="false"
    >

在代码中是这样的:

materialRefreshLayout.setIsOverLay(false);
materialRefreshLayout.setWaveShow(false);

(3)如果你觉得上面的效果太单调了,加个波浪形状的背景,就像下图所示

在xml中, 设置以下属性

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:overlay="false"
    hap:wave_show="true"
    hap:wave_color="@color/material_green"
    hap:wave_height_type="normal"  (higher)
    >

在java代码中是这样的:

materialRefreshLayout.setWaveColor(0xffffffff);
materialRefreshLayout.setIsOverLay(false);
materialRefreshLayout.setWaveShow(true);

(4)你想要侵入式的刷新,又要有波浪背景,也就是所有效果覆盖在内容之上

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:overlay="true"
    hap:wave_show="true"
    hap:wave_color="#90ffffff"
    hap:progress_colors="@array/material_colors"
    hap:wave_height_type="higher"
    >

在java代码中是这样的:

materialRefreshLayout.setWaveColor(0xf90fffff);
materialRefreshLayout.setIsOverLay(true);
materialRefreshLayout.setWaveShow(true);

(5)其他...

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:overlay="false"
    hap:wave_show="false"
    hap:progress_colors="@array/material_colors"
    hap:wave_height_type="higher"
    hap:progress_show_circle_backgroud="false"
    >

(6)上拉加载更多...

<com.cjj.MaterialRefreshLayout
    xmlns:hap="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    hap:isLoadMore="true"
    >

在java代码中是这样的:

materialRefreshLayout.setLoadMore(true);

(7)自动下拉刷新,自动上拉刷新.

在java代码中是这样的:

materialRefreshLayout.autoRefresh();//drop-down refresh automatically
materialRefreshLayout.autoRefreshLoadMore();// pull up refresh automatically

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 1.0.1
  • 1.0.0
  • 0.0.1-SNAPSHOT

版权和许可信息

    The MIT License (MIT)

	Copyright (c) 2015 android-cjj

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
The MIT License (MIT) Copyright (c) 2015 android-cjj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Material风格下拉刷新控件 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/chinasoft5_ohos/Ohos-MaterialRefreshLayout.git
git@gitee.com:chinasoft5_ohos/Ohos-MaterialRefreshLayout.git
chinasoft5_ohos
Ohos-MaterialRefreshLayout
Ohos-MaterialRefreshLayout
master

搜索帮助