9 Star 13 Fork 3

HarmonyOS-TPC / XRecyclerView

加入 Gitee
与超过 800 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

该三方开源库从github fork过来,主要将底层安卓接口调用的实现修改成鸿蒙接口的实现,将三方库鸿蒙化,供开发鸿蒙应用的开发者使用

fork地址:https://github.com/XRecyclerView/XRecyclerView

fork版本号/日期: 1.6.0 release/ on Sep 20, 2019

Gradle Dependency

implementation "io.openharmony.tpc.thirdlib:XRecyclerView:1.0.3"

just like a standard RecyclerView

LayoutConfig lp = new LayoutConfig(LayoutConfig.MATCH_PARENT,LayoutConfig.MATCH_CONTENT);
mRecyclerView.setLayoutConfig(lp);
mRecyclerView.setOrientation(VERTICAL);
mRecyclerView.setItemProvider(mAdapter);

pull to refresh and load more

the pull to refresh and load more featrue is enabled by default. we provide a callback to trigger the refresh and LoadMore event.

 mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
    @Override
    public void onRefresh() {
       //refresh data here
    }

    @Override
    public void onLoadMore() {
       // load more data here
    }
});
mRecyclerView
    .getDefaultRefreshHeaderView() // get default refresh header view
    .setRefreshTimeVisible(true);  // make refresh time visible,false means hiding

```java
// any time,when you finish your ability or fragment,call this below
if(mRecyclerView != null){
    mRecyclerView.destroy(); // this will totally release XR's memory
    mRecyclerView = null;
}

you can use XR in the sticky scroll model now,like the code below,the demo ability is 'LinearStickyScrollAbility'

  final Component topView = findComponentById(ResourceTable.Id_abt_linear_sticky_scroll_topview);
  final Component tabView = findComponentById(ResourceTable.Id_abt_linear_sticky_scroll_tabview);
  final Component content = findComponentById(ResourceTable.Id_abt_linear_sticky_scroll_content);
  final StickyScrollLinearLayout sLayout = (StickyScrollLinearLayout)findComponentById(
                ResourceTable.Id_abt_linear_sticky_scroll);
        sLayout.setLayoutRefreshedListener(new Component.LayoutRefreshedListener() {
            @Override
            public void onRefreshed(Component component) {
                sLayout.setInitInterface(new StickyScrollLinearLayout.StickyScrollInitInterface() {
                    @Override
                    public Component setTopView() {
                        return topView;
                    }

                    @Override
                    public Component setTabView() {
                        return tabView;
                    }

                    @Override
                    public Component setContentView() {
                        return content;
                    }
                });
            }
        });

and of course you have to tell our RecyclerView when the refreshing or loading more work is done. you can use

mRecyclerView.loadMoreComplete();

to control when the item number of the screen is list.size-2,we call the onLoadMore

mRecyclerView.setLimitNumberToCallLoadMore(2); // default is 1

to notify that the loading more work is done. and

 mRecyclerView.refreshComplete();

```java
mRecyclerView.refresh();

custom refresh and loading more style

pull refresh and loading more style is highly customizable.

you can call

mRecyclerView.setRefreshProgressStyle(int style);

and

mRecyclerView.setLaodingMoreProgressStyle(int style);

to set the RefreshProgressStyle and LaodingMoreProgressStyle respectively.

for example

mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLaodingMoreProgressStyle(ProgressStyle.SquareSpin);

all the effect can be get in the ProgressStyle class

public class ProgressStyle {
    public static final int SysProgress=-1;
    public static final int BallPulse=0;
    public static final int BallGridPulse=1;
    public static final int BallClipRotate=2;
    public static final int BallClipRotatePulse=3;
    public static final int SquareSpin=4;
    public static final int BallClipRotateMultiple=5;
    public static final int BallPulseRise=6;
    public static final int BallRotate=7;
    public static final int CubeTransition=8;
    public static final int BallZigZag=9;
    public static final int BallZigZagDeflect=10;
    public static final int BallTrianglePath=11;
    public static final int BallScale=12;
    public static final int LineScale=13;
    public static final int LineScaleParty=14;
    public static final int BallScaleMultiple=15;
    public static final int BallPulseSync=16;
    public static final int BallBeat=17;
    public static final int LineScalePulseOut=18;
    public static final int LineScalePulseOutRapid=19;
    public static final int BallScaleRipple=20;
    public static final int BallScaleRippleMultiple=21;
    public static final int BallSpinFadeLoader=22;
    public static final int LineSpinFadeLoader=23;
    public static final int TriangleSkewSpin=24;
    public static final int Pacman=25;
    public static final int BallGridBeat=26;
    public static final int SemiCircleSpin=27;
}

refresh arrow icon

we provide a default arrow icon: but if you don't like it,you can replace it with any other icon you want. just call

mRecyclerView.setArrowImageView(ResourceTable.Media_iconfont_downgrey);

disable refresh and load more featrue

if you don't want the refresh and load more featrue(in that case,you probably dont'n need the lib neither),you can call

mRecyclerView.setPullRefreshEnabled(false);

and

mRecyclerView.setPullRefreshEnabled(true);

in which false means disabled ,true means enabled. ##Header you can add header to XRecyclerView,just call addHeaderView().

 LayoutScatter scatter = LayoutScatter.getInstance(mContext);
 Component header = scatter.parse(ResourceTable.Layout_recyclerview_header, null, false);
 mRecyclerView.addHeaderView(header);

if you like ,you can add two header

LayoutScatter scatter = LayoutScatter.getInstance(mContext);
Component header = scatter.parse(ResourceTable.Layout_recyclerview_header, null, false);
Component header1 = scatter.parse(ResourceTable.Layout_recyclerview_header1, null, false);
mRecyclerView.addHeaderView(header);
mRecyclerView.addHeaderView(header1);

License

Copyright 2015 jianghejie

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.

简介

XRecyclerView 的鸿蒙移植版本 展开 收起
Java
取消

发行版

暂无发行版

XRecyclerView

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/HarmonyOS-tpc/XRecyclerView.git
git@gitee.com:HarmonyOS-tpc/XRecyclerView.git
HarmonyOS-tpc
XRecyclerView
XRecyclerView
master

搜索帮助