SmartRefreshLayout
Цель SmartRefreshLayout — создать мощный, стабильный и зрелый фреймворк для обновления данных с прокруткой вниз и интегрировать все виды интересных, разнообразных, практичных и красивых хедеров и футеров.
SmartRefreshControl: Link
FeedList | |
---|---|
![]() |
![]() |
Repast | Profile |
---|---|
![]() |
![]() |
Стиль | Delivery | DropBox |
---|---|---|
Демо | ![]() |
![]() |
Дизайн | Refresh-your-delivery | DropBox-Refresh |
Два вышеуказанных хедера реализованы мной. Следующие хедры собраны и оптимизированы из отличных хедеров на github.
Стиль | BezierRadar | BezierCircle |
---|---|---|
Демонстрация | ![]() |
![]() |
Отсюда | TwinklingRefreshLayout | Pull Down To Refresh |
Стиль | FlyRefresh | Classics |
---|---|---|
Демонстрация | ![]() |
![]() |
Отсюда | FlyRefresh | ClassicsHeader |
Стиль | Phoenix | Taurus |
---|---|---|
Демонстрация | ![]() |
![]() |
Отсюда | Yalantis/Phoenix | Yalantis/Taurus |
|Стиль|BattleCity|HitBlock|
|:---:|:---:|:---:| |Demo||
|
|From|FunGame/BattleCity|FunGame/HitBlock
Style | WaveSwipe | Material |
---|---|---|
Demo | ![]() |
![]() |
From | WaveSwipeRefreshLayout | MaterialHeader |
Style | StoreHouse | WaterDrop |
---|---|---|
Demo | ![]() |
![]() |
From | Ultra-Pull-To-Refresh | WaterDrop |
See so many cool headers, is not it feel great? At this point you may be worried that so many headers together, but usually only use one, is not to introduce a lot of useless code and resources? Please rest assured that I have divided it into eight packages, when used to reference their own it!
V 2.x changed the package name relative to 1.x, such as com.scwang.smartrefresh
to com.scwang.smart.refresh
.
It is suggested that in the new project, if the old project is upgraded,
the package name should be replaced, which is more troublesome.
But the main change is to subcontract SmartRefreshLayout to reduce unnecessary dependencies and avoid code redundancy.
However, there is no subcontracting to SmartRefreshHeader.
There are more than ten headers in it.
It is recommended that you copy the source code into the project whenever you need to use it.
// Note: There will be no default Header and Footer after subcontracting. It needs to be added manually!
// To search lastest version by https://search.maven.org/search?q=g:io.github.scwang90
implementation 'io.github.scwang90:refresh-layout-kernel:2.0.6' //core
implementation 'io.github.scwang90:refresh-header-classics:2.0.6' //ClassicsHeader
implementation 'io.github.scwang90:refresh-header-radar:2.0.6' //BezierRadarHeader
implementation 'io.github.scwang90:refresh-header-falsify:2.0.6' //FalsifyHeader
implementation 'io.github.scwang90:refresh-header-material:2.0.6' //MaterialHeader
implementation 'io.github.scwang90:refresh-header-two-level:2.0.6' //TwoLevelHeader
implementation 'io.github.scwang90:refresh-footer-ball:2.0.6' //BallPulseFooter
implementation 'io.github.scwang90:refresh-footer-classics:2.0.6' //ClassicsFooter
<!-- // The package name of `io.github.scwang90:refresh` is retained, but not subcontracted. -->
<!-- implementation 'io.github.scwang90:refresh:SmartRefreshHeader:2.0.5' //Headers -->
<!-- implementation 'io.github.scwang90:refresh:SmartRefreshFooter:2.0.5' //Footers -->
<!-- implementation 'io.github.scwang90:refresh:SmartRefreshLayout:2.0.5' //core、 default Header and Footer -->
If you use AndroidX, add it to gradle.properties
android.useAndroidX=true android.enableJetifier=true
#### 2.Add SmartRefreshLayout in the layout xml.
```xml
<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smart.refresh.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" **3. Кодинг в активити или фрагменте**
```java
RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new ClassicsHeader(this));
refreshLayout.setRefreshFooter(new ClassicsFooter(this));
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
refreshlayout.finishRefresh(2000/*,false*/);//передаём false, чтобы указать на неудачное обновление
}
});
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(RefreshLayout refreshlayout) {
refreshlayout.finishLoadMore(2000/*,false*/); //передаём false, чтобы указать на неудачную загрузку
}
});
1. Глобальные настройки
public class App extends Application {
public void onCreate() {
super.onCreate();
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
return new ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate);
}
});
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
return new ClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate);
}
});
}
}
Примечание: этот метод имеет самый низкий приоритет.
2. Указание в XML-файле макета
<com.scwang.smart.refresh.layout.SmartRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#444444"
app:srlPrimaryColor="#444444"
app:srlAccentColor="@android:color/white"
app:srlEnablePreviewInEditMode="true">
<!--srlAccentColor и srlPrimaryColor изменят цвета темы Header и Footer-->
<!--srlEnablePreviewInEditMode откроет и закроет функцию предварительного просмотра-->
<com.scwang.smart.refresh.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/dimenPaddingCommon"
android:background="@android:color/white"
android:text="@string/description_define_in_xml"/>
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
Примечание: у этого метода средний приоритет. При использовании этого метода в Android Studio будет эффект предварительного просмотра.
3. Указание в Java-коде
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new MaterialHeader(this).setShowBezierWave(true));
refreshLayout.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.Scale));
``` Чашка кофе.
[](https://www.paypal.me/scwang90)
Если в сообщении о пожертвовании указать имя, оно будет записано в список
[Список пожертвований](art/md_donationlist.md)
#### Блогролл
[github/Loror](https://github.com/Loror)
[github/faith-hb/WidgetCase](https://github.com/faith-hb/WidgetCase)
[github/Bamboy120315/Freedom](https://github.com/Bamboy120315/Freedom)
[github/TommyLemon/APIJSON](https://github.com/TommyLemon/APIJSON)
[github/dengyuhan](https://github.com/dengyuhan)
[github/zrp2017](https://github.com/zrp2017)
[github/fly803/BaseProject](https://github.com/fly803/BaseProject)
[github/razerdp](https://github.com/razerdp)
[github/SuperChenC/s-mvp](https://github.com/SuperChenC/s-mvp)
[github/KingJA/LoadSir](https://github.com/KingJA/LoadSir)
[github/jianshijiuyou](https://github.com/jianshijiuyou)
[github/zxy198717](https://github.com/zxy198717)
[github/addappcn](https://github.com/addappcn)
[github/RainliFu](https://github.com/RainliFu)
[github/sugarya](https://github.com/sugarya)
[github/stormzhang](https://github.com/stormzhang)
## Обсудить
Свяжитесь со мной: scwang90@hotmail.com
## Спасибо
[SwipeRefreshLayout](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html)
[Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh)
[TwinklingRefreshLayout](https://github.com/lcodecorex/TwinklingRefreshLayout)
[BeautifulRefreshLayout](https://github.com/android-cjj/BeautifulRefreshLayout)
## Другие работы
[MultiWaveHeader](https://github.com/scwang90/MultiWaveHeader)
[SmartRefreshHorizontal](https://github.com/scwang90/SmartRefreshHorizontal)
Лицензия
-------
Copyright 2017 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.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )