GithubHelp home page GithubHelp logo

scwang90 / smartrefreshhorizontal Goto Github PK

View Code? Open in Web Editor NEW
491.0 8.0 56.0 8.64 MB

横向刷新、水平刷新、RefreshLayout、OverScroll,Horizontal,基于SmartRefreshLayout的水平智能刷新

Home Page: https://segmentfault.com/a/1190000020038792

License: Apache License 2.0

Kotlin 14.58% Java 85.36% Batchfile 0.06%
horizontal refresh android framework

smartrefreshhorizontal's Introduction

Android横向智能刷新框架-SmartRefreshHorizontal

License MinSdk JCenter Author

English | 中文

SmartRefreshHorizontal 作为 SmartRefreshLayout 的扩展库,实现了横向刷新和加载的功能, 虽然是独立的开源库,但是并没有重复做实现, 而是对 SmartRefreshLayout 做了封装和转换,使其支持横向刷新。 所以 SmartRefreshHorizontal 继承了 SmartRefreshLayout 所有的特性,只是方向改成了横向。

特点:

由来

SmartRefreshLayout 的设计灵活多样,扩展性高,我想这应该是它受欢迎的原因之一。 在 issue 区有不少人建议让 SmartRefreshLayout 支持横向刷新。 其实大家都知道横向刷新的库已经有了不少,我给他们的回复是使用其他现有的横向刷新库。 但这在 issue 引发热议,可能是那些横向刷新库的使用、功能、扩展与 SmartRefreshLayout有很大差距。 所以我自己认为要做横向刷新库也需要能够像 SmartRefreshLayout 一样的多功能与易扩展。 如果直接扩展 SmartRefreshLayout 的功能使其直接支持横向,将会增加代码量。 然而当此时它已经足够庞大,并且也有不少人抱怨它太大需要分包细化功能。所以一开始的时候我几乎没有开发横向刷新功能的想法。 因为用到横向刷新的应用场景比竖向刷新少很多,我自己也很少会用到这样的场景。 如果为了实现一个我自己不常用的功能库要花费我太多时间和精力实在划不来,仅仅实现一个简单的横向刷新又没有必要...

原理

终于!有一天我在开发旋转动画过程中,产生了一个奇妙的想法:如果把 SmartRefreshLayout 旋转90度会怎样? 然后开始做试验:把 SmartRefreshLayout 旋转90度,再把 Content 旋转-90度。结果竟然真的可以用!! 这样就不用让我花大量时间精力去做横向刷新代码实现,SmartRefreshLayout 原有的所有功能多可以直接使用, 之前设计的十多个 Header 和 Footer 也可以不用任何修改直接使用!这让我产生了开发横向刷新库的动力。 于是基于这个试验想法就诞生了这个 SmartRefreshHorizontal 库 !

明白了 SmartRefreshHorizontal 与 SmartRefreshLayout 的关系,那么大家在使用本库的使用同时也要依赖 SmartRefreshLayout,并且版本要大于 1.1.0-beta-1 ,否则会出现找不到类的错误。

传送门

Demo

下载 APK-Demo

效果演示

商品详情 ViewPager
数据演示

简单用例

1. 在 build.gradle 中添加依赖

    //2.x
    implementation 'com.scwang.smart:refresh-layout-horizontal:2.0.0'
    implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1'
    implementation 'com.scwang.smart:refresh-header-classics:2.0.1'    //经典刷新头
    implementation 'com.scwang.smart:refresh-header-material:2.0.1'    //谷歌刷新头

    //1.x
    implementation 'com.scwang.smartrefresh:SmartRefreshHorizontal:1.1.2'
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3' //必须依赖 版本 1.1.0 以上

    //androidx
    implementation 'com.scwang.smartrefresh:SmartRefreshHorizontal:1.1.2-x'
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3' //必须依赖 版本 1.1.0 以上

2. 在XML布局文件中添加 SmartRefreshHorizontal

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/refreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never"
        android:orientation="horizontal"
        android:background="#fff" />
</com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal>

3. 在 Activity 或者 Fragment 中添加代码

   RefreshLayout refreshLayout = root.findViewById(R.id.refreshLayout);
   refreshLayout.setRefreshHeader(new MaterialHeader(root.getContext()));
   refreshLayout.setRefreshFooter(new RefreshFooterWrapper(new MaterialHeader(root.getContext())), -1, -2);

混淆

SmartRefreshHorizontal 不需要添加混淆过滤代码,并且已经混淆测试通过,如果你在项目的使用中混淆之后出现问题,请及时通知我。

其他作品

MultiWaveHeader
SmartRefreshLayout
诗和远方

License

Copyright 2019 scwang90

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.

smartrefreshhorizontal's People

Contributors

scwang90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartrefreshhorizontal's Issues

InflateException 如何解决

Caused by: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal
Caused by: java.lang.reflect.InvocationTargetException

readme的文档写错了吧

文档中让引用:com.scwang.smartrefresh.layout.SmartRefreshHorizontal
但实际上是 com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal

横向刷新,viewpager未翻到最后一页就可以拖出刷新控件加载更多

1.使用版本
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-beta-1'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-beta-1'
implementation 'com.scwang.smartrefresh:SmartRefreshHorizontal:1.0.0-beta-1'

2.布局文件
<com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlEnableOverScrollBounce="false">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal>

3.java
加载更多,使用MaterialHeader,代码如下
MaterialHeader footer = new MaterialHeader(this);
RefreshLayout.setRefreshFooter(new RefreshFooterWrapper(footer));

4.出现问题详细说明
滑动区域在中上部的时候,是ViewPager的翻页,但是区域在底部时变成了加载更多

在与BRVAH 混合使用问题

使用BRVAH 显示emptyview 一次显示一次不显示,来回循环,使用SmartRefreshLayout 没有这个问题,请问这是什么原因啊

厉害了

这是可以左滑刷新右滑加载,大佬666 啊

有坑啊,依赖方式自动导入的 代码有异常

通过gradle方式自动带入的代码,SmartRefreshHorizontal 没有实现RefreshLayout 接口中带三个参数的 finishRefresh(int delayed, boolean success, Boolean noMoreData); 方法,导致inflate xml 报错

只能把代码下载下来导入,实现这个方法才能正常使用。作者改下吧,因为对SmartRefreshLayout的信任跑来用这个的,没想到有坑啊

viewpager 横向不能拖动

implementation 'com.scwang.smart:refresh-layout-horizontal:2.0.0'
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1'

测试设备
小米8 Android10
OPPO Reno Android10

viewpager 一拖动就回弹了,划不过去,demo里和项目中都遇到了

SmartRefreshHorizontal布局问题

SmartRefreshHorizontal布局之后,宽度设置的是match_parent,但是实际上只占了一部分宽度,另一部分就空置了,

好像是包名对不上吧

报错:java.lang.IllegalAccessError: Method 'void com.scwang.smartrefresh.layout.SmartRefreshLayout.onFinishInflate()' is inaccessible to class 'com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal

为啥要修改全局的header和footer

大哥,转方向就转方向,咋还把全局的刷新头和加载头样式都改了。别的地方正常用SmartRefreshLayout没设置footer的,都默认被改了,还用static!!!查了两天了。。。
image

header或foot显示问题。

请问作者,那个左滑的提示,左滑刷新不觉得看着很别扭嘛,Textview旋转了,那看的时候也得横着看,能不能textview不旋转,里面的字竖着显示呢,就像这样:




footer无法显示

com.yarolegovich.discretescrollview 我这边使用这个三方库做为显示的reclyerView使用。外层嵌套 SmartRefreshHorizontal 做左滑加载更多。

测试时使用:
refreshHorizontal.setRefreshHeader(new MaterialHeader(context));
refreshHorizontal.setRefreshFooter(new RefreshFooterWrapper(new MaterialHeader(context)), -1, -2);
进行配置头部和尾部。
结果右滑到低可以显示头部,但是左滑到底无法显示尾部。主动调用
refreshHorizontal.autoLoadMore();
可以显示尾部的加载更多
请问需要如何修改,才能手动左滑屏幕到底,并显示和触发加载更多

给的APK-Demo 商品详情有bug

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.scwang.smartrefresh.horizontal.demo, PID: 26281 java.lang.IllegalStateException: banner must not be null at com.scwang.smartrefresh.horizontal.demo.b.l.e(Unknown Source:15) at com.scwang.smartrefresh.horizontal.demo.b.l.a(Unknown Source:9) at android.support.v4.app.w.a(Unknown Source:608) at android.support.v4.app.w.h(Unknown Source:38) at android.support.v4.app.w.a(Unknown Source:46) at android.support.v4.app.c.b(Unknown Source:165) at android.support.v4.app.w.a(Unknown Source:38) at android.support.v4.app.w.b(Unknown Source:114) at android.support.v4.app.w.c(Unknown Source:88) at android.support.v4.app.w.o(Unknown Source:21) at android.support.v4.app.w.e(Unknown Source:9) at android.support.v4.app.w.e(Unknown Source:6) at android.support.v4.app.n.a(Unknown Source:4) at android.support.v4.app.l.onStart(Unknown Source:15) at android.support.v7.app.m.onStart(Unknown Source:0) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1447) at android.app.Activity.performStart(Activity.java:8108) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3919) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:235) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:215) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:187) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:105) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8347) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

手机型号 : 华为 p30pro
android版本 : 10
EMUI版本 : 10.1.0

内部创建的SmartRefreshImpl复制了错误的状态

如果SmartRefreshHorizontal初始状态为GONE的情况下,impl也直接GONE,且id是直接复制的,然后在运行时修改Horizontal为Visible时,impl依然是GONE,需要实现setVisible方法的重写,以同步状态

2.0.1版本的横向滑动测算footer的位置不对

2.0.1版本的横向滑动,会导致footer在列表中间显示,而不是列表的末尾,我对比了一下,代码上的问题。

可能是2.0.1版本
//2020-10-13 如果,真的直接颠倒,height width 的测量值,会导致,布局外的同级控件位置发生偏移,必须纠正 测量值
super.setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
这段代码导致的。

回归到2.0.0版本,没有这段代码,就是好用的。

加载更多滚动recyclerview加载更多动画不能隐藏

apk-demo里面的加载更多过程中滚动recyclerview加载更多动画会隐藏 实际上加载更多滚动recyclerview加载更多动画固定不动
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-beta-1' (会隐藏动画)
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0'(不会隐藏)

请问这个问题如何解决

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.