# TwinklingRefreshLayout **Repository Path**: chinasoft4_ohos/TwinklingRefreshLayout ## Basic Information - **Project Name**: TwinklingRefreshLayout - **Description**: TwinklingRefreshLayout延伸了SwipeRefreshLayout的思想,不在列表控件上动刀,而是使用一个ViewGroup来包含列表控件,以保持其较低的耦合性和较高的通用性。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-07-26 - **Last Updated**: 2021-12-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TwinklingRefreshLayout #### 项目介绍 - 项目名称:TwinklingRefreshLayout - 所属系列:openharmony的第三方组件适配移植 - 功能:TwinklingRefreshLayout延伸了SwipeRefreshLayout的思想,不在列表控件上动刀,而是使用一个ViewGroup来包含列表控件,以保持其较低的耦合性和较高的通用性。 - 项目移植状态:主功能完成 - 调用差异:1,Webview上做刷新操作无法实现,Webview会覆盖其它组件2,ListContenter通过设置toucher监听改变滑动屏幕的刷新样式,Touch监听事件开启再取消后无效。 3,列表滚动监听,列表滚动刷新太快会导致执行操作处理不及时。4,底部拉动 加载更多,滚动数据 和滑动屏幕无法区分,只能通过检查最后一个来做加载操作 - 开发版本:sdk6,DevEco Studio2.2 Beta1 - 基线版本:Releases v1.07 #### 效果演示 #### 安装教程 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:TwinklingRefreshLayout:1.0.0') ...... } ``` 在sdk6,DevEco Studio2.2 Beta1 下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 Demo中调用library组件库,操作展示组件功能。 1、布局文件中引用界面效果: ```xml ``` 列表展示功能主要再 XRecyclerView类中。 其中 density属性 是列表的头部和尾部样式类型。 自定义类 ArrowRefreshHeader 是头部刷新效果: ```java public void headView(Context context){ LayoutScatter scatter = LayoutScatter.getInstance(context); mContainer = (DirectionalLayout) scatter.parse(ResourceTable.Layout_listview_header, null, false); listview_header_text = (DirectionalLayout) mContainer.findComponentById(ResourceTable.Id_listview_header_text); // 功能3 箭头和提示刷新 cricle_refresh = (DirectionalLayout) mContainer.findComponentById(ResourceTable.Id_cricle_refresh); // 功能1 圆圈刷新 mHeaderRefreshTimeContainer = (DirectionalLayout) mContainer.findComponentById(ResourceTable.Id_header_refresh_time_container); DirectionalLayout.LayoutConfig lp = new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT); lp.setMargins(0, 0, 0, 0); this.setPadding(0, 0, 0, 0); this.setLayoutConfig(lp); addComponent(mContainer, new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT, 0)); setAlignment(TextAlignment.BOTTOM); frameAnimationElement = new FrameAnimationElement(context, ResourceTable.Graphic_anim_loading_view); componentContainer = (DirectionalLayout) findComponentById(ResourceTable.Id_frame_container); mArrowImageView = (Image) mContainer.findComponentById(ResourceTable.Id_listview_header_arrow); mStatusTextView = (Text) mContainer.findComponentById(ResourceTable.Id_refresh_status_textview); mHeaderTimeView = (Text) mContainer.findComponentById(ResourceTable.Id_last_refresh_time); head_top = (DirectionalLayout) mContainer.findComponentById(ResourceTable.Id_head_top); if (XRecyclerView.stateInfo == 3) { // 功能3的刷新 listview_header_text.setVisibility(VISIBLE); mArrowImageView.setVisibility(VISIBLE); cricle_refresh.setVisibility(HIDE); } else if(XRecyclerView.stateInfo == 1) { cricle_refresh.setVisibility(VISIBLE); listview_header_text.setVisibility(HIDE); } else if(XRecyclerView.stateInfo == 5) { cricle_refresh.setVisibility(HIDE); listview_header_text.setVisibility(HIDE); head_top.setVisibility(VISIBLE); } //init the progress view mProgressBar = (SimpleViewSwitcher) mContainer.findComponentById(ResourceTable.Id_listview_header_progressbar); progressView = new AVLoadingIndicatorView(context); progressView.setIndicatorColor(0xffB5B5B5); progressView.setIndicatorId(ProgressStyle.BallSpinFadeLoader); if (mProgressBar != null) { mProgressBar.setView(progressView); progressView.applyAnimation(); } estimateSize(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT); mMeasuredHeight = getEstimatedHeight(); loadingView = (LoadingView) mContainer.findComponentById(ResourceTable.Id_progress_bar_loading); loadingView.setBindStateChangedListener(loadingView); loadingView.setPaintcolor(0xff000000); loadingView.setSize(45); loadingView.stopAnimation(); } ``` 自定义类 LoadingMoreFooter 是尾部加载更多效果: ```java private void initView(Context context, AttrSet attrSet, String styleName){ setAlignment(CENTER); setOrientation(HORIZONTAL); setComponentSize(LayoutConfig.MATCH_PARENT, DeviceUtils.dp2px(getContext(),5)); progressCon = new SimpleViewSwitcher(context); progressCon.setWidth(DeviceUtils.dp2px(getContext(),40)); progressCon.setHeight(DeviceUtils.dp2px(getContext(),40)); addComponent(progressCon); if (XRecyclerView.stateInfo == 3) { addHeadFoot(); } else if(XRecyclerView.stateInfo == 1 || XRecyclerView.stateInfo == 5){ addText(); } } ``` 2、自定义刷新和加载跟多效果属性 ```java mRecyclerView.setPullRefreshEnabled(false); // 设置刷新的开启状态,默认开启 mRecyclerView.setLoadingMoreEnabled(false); // 设置加载更多的状态,默认是开启 mRecyclerView.setLongClickable(false); // 设置长按 mRecyclerView.setReboundEffect(true); //设置上下滚动效果 photoAdapter.setNumColumns(2); //设置列表的列数 ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 当前版本demo部分功能暂不支持模拟器运行 #### 版本迭代 - 1.0.0 #### 版权和许可信息 ``` Copyright 2016 lcodecorex 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. ```