Skip to content

Commit 53d146a

Browse files
authored
Merge pull request #2815 from AllenCoder/androidx
Merge remote-tracking branch 'remotes/remote/master' into androidx
2 parents 691b56e + 5d4379e commit 53d146a

File tree

59 files changed

+1375
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1375
-267
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
build:
44
working_directory: ~/code
55
docker:
6-
- image: circleci/android:api-26-alpha
6+
- image: circleci/android:api-28-alpha
77
environment:
88
JVM_OPTS: -Xmx3200m
99
steps:

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Thank you for contributing to BaseRecyclerViewAdapterHelper. Before pressing the "Create Pull Request" button, please consider the following points:
2+
3+
- [1] Please give a description about what and why you are contributing, even if it's trivial.
4+
5+
- [2] Please include the issue list number(s) or other PR numbers in the description if you are contributing in response to those.
6+
7+
- [3] Please include a reasonable set of demo tests if you contribute new code or change an existing one. please make sure you have demo for working correctly.

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
language: android
2+
dist: trusty
23
jdk: oraclejdk8
34
sudo: false
45

56
android:
67
components:
78
- tools
89
- platform-tools
9-
- build-tools-27.0.2
10-
- android-27
10+
- build-tools-28.0.3
11+
- android-28
1112
- extra-android-m2repository
1213
- extra-android-support
1314
before_install:
1415
- chmod +x gradlew
1516
- mkdir "$ANDROID_HOME/licenses" || true
1617
# Hack to accept Android licenses
17-
- yes | sdkmanager "platforms;android-27"
18+
- yes | sdkmanager "platforms;android-28"
1819

1920
script:
2021
- ./gradlew assembleRelease

README-cn.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Activity
163163
Toast.makeText(RecyclerClickItemActivity.this, "" + Integer.toString(position), Toast.LENGTH_SHORT).show();
164164
}
165165
});
166-
```
166+
```
167167

168168

169169
# 如何使用它添加动画?
@@ -413,6 +413,85 @@ protected K createBaseViewHolder(View view) {
413413

414414
```
415415

416+
# DiffUtil
417+
先继承`BaseQuickDiffCallback<T>`并实现:
418+
```java
419+
public class DiffDemoCallback extends BaseQuickDiffCallback<DiffUtilDemoEntity> {
420+
421+
public DiffDemoCallback(@Nullable List<DiffUtilDemoEntity> newList) {
422+
super(newList);
423+
}
424+
425+
/**
426+
* 判断是否是同一个item
427+
*
428+
* @param oldItem New data
429+
* @param newItem old Data
430+
* @return
431+
*/
432+
@Override
433+
protected boolean areItemsTheSame(DiffUtilDemoEntity oldItem, DiffUtilDemoEntity newItem) {
434+
……
435+
}
436+
437+
/**
438+
* 当是同一个item时,再判断内容是否发生改变
439+
*
440+
* @param oldItem New data
441+
* @param newItem old Data
442+
* @return
443+
*/
444+
@Override
445+
protected boolean areContentsTheSame(DiffUtilDemoEntity oldItem, DiffUtilDemoEntity newItem) {
446+
……
447+
}
448+
449+
/**
450+
* 可选实现
451+
* 如果需要精确修改某一个view中的内容,请实现此方法。
452+
* 如果不实现此方法,或者返回null,将会直接刷新整个item。
453+
*
454+
* @param oldItem Old data
455+
* @param newItem New data
456+
* @return Payload info. if return null, the entire item will be refreshed.
457+
*/
458+
@Override
459+
protected Object getChangePayload(DiffUtilDemoEntity oldItem, DiffUtilDemoEntity newItem) {
460+
……
461+
}
462+
}
463+
```
464+
465+
`BaseQuickAdapter`中实现`convertPayloads()`方法,用于局部更新:
466+
```java
467+
/**
468+
*
469+
* 当有 payload info 时,只会执行此方法
470+
*
471+
* @param helper A fully initialized helper.
472+
* @param item The item that needs to be displayed.
473+
* @param payloads payload info.
474+
*/
475+
@Override
476+
protected void convertPayloads(BaseViewHolder helper, DiffUtilDemoEntity item, @NonNull List<Object> payloads) {
477+
for (Object p : payloads) {
478+
……
479+
}
480+
}
481+
```
482+
483+
更新整个数据集时,使用如下方法:
484+
```java
485+
DiffDemoCallback callback = new DiffDemoCallback(getNewList());
486+
mAdapter.setNewDiffData(callback);
487+
```
488+
489+
更新单个item时,使用如下方法:
490+
```java
491+
mAdapter.notifyItemChanged(0, "payload info");
492+
```
493+
494+
416495
>**持续更新!,所以推荐Star项目**
417496

418497
# 感谢

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ kotlin demo :[BRVAH_kotlin](https://github.com/AllenCoder/BRVAH_kotlin)
2929
-keepclassmembers class **$** extends com.chad.library.adapter.base.BaseViewHolder {
3030
<init>(...);
3131
}
32+
-keepattributes InnerClasses
3233
```
3334

3435
# Extension library

app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55

66
defaultConfig {
77
applicationId "com.chad.baserecyclerviewadapterhelper"
8-
minSdkVersion 14
8+
minSdkVersion 16
99
targetSdkVersion 28
1010
versionCode 5
1111
versionName "2.1"
@@ -24,9 +24,8 @@ android {
2424
}
2525

2626
dependencies {
27-
implementation fileTree(include: ['*.jar'], dir: 'libs')
27+
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
2828
implementation project(path: ':library')
29-
implementation project(':material-spinner-1.0.5')
3029
implementation 'com.google.android.material:material:1.0.0'
3130
implementation 'androidx.cardview:cardview:1.0.0'
3231
implementation 'androidx.appcompat:appcompat:1.0.2'
File renamed without changes.
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
package com.chad.baserecyclerviewadapterhelper;
22

3-
import android.app.Application;
4-
import android.test.ApplicationTestCase;
5-
63
/**
74
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
85
*/
9-
public class ApplicationTest extends ApplicationTestCase<Application> {
10-
public ApplicationTest() {
11-
super(Application.class);
12-
}
13-
public void test() {
14-
15-
}
6+
public class ApplicationTest {
7+
168
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
android:launchMode="singleTask"></activity>
3737
<activity android:name=".UpFetchUseActivity" />
3838
<activity android:name=".SectionMultipleItemUseActivity" />
39+
<activity android:name=".DiffUtilActivity" />
3940
</application>
4041

4142
</manifest>

app/src/main/java/com/chad/baserecyclerviewadapterhelper/AnimationUseActivity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
public class AnimationUseActivity extends Activity {
2525
private RecyclerView mRecyclerView;
2626
private AnimationAdapter mAnimationAdapter;
27-
private ImageView mImgBtn;
28-
private int mFirstPageItemCount = 3;
2927

3028
@Override
3129
protected void onCreate(Bundle savedInstanceState) {
@@ -41,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
4139

4240
private void initView() {
4341

44-
mImgBtn = (ImageView) findViewById(R.id.img_back);
42+
ImageView mImgBtn = (ImageView) findViewById(R.id.img_back);
4543
mImgBtn.setOnClickListener(new View.OnClickListener() {
4644
@Override
4745
public void onClick(final View v) {
@@ -53,6 +51,7 @@ public void onClick(final View v) {
5351
private void initAdapter() {
5452
mAnimationAdapter = new AnimationAdapter();
5553
mAnimationAdapter.openLoadAnimation();
54+
int mFirstPageItemCount = 3;
5655
mAnimationAdapter.setNotDoAnimationCount(mFirstPageItemCount);
5756
mAnimationAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
5857
@Override
@@ -73,6 +72,8 @@ public void onItemChildClick(BaseQuickAdapter adapter, View view, int position)
7372
Toast.makeText(AnimationUseActivity.this, content, Toast.LENGTH_LONG).show();
7473
// you have set clickspan .so there should not solve any click event ,just empty
7574
break;
75+
default:
76+
break;
7677

7778
}
7879
}
@@ -112,7 +113,8 @@ public void onItemSelected(MaterialSpinner view, int position, long id, String i
112113
mRecyclerView.setAdapter(mAnimationAdapter);
113114
}
114115
});
115-
mAnimationAdapter.isFirstOnly(false);//init firstOnly state
116+
//init firstOnly state
117+
mAnimationAdapter.isFirstOnly(false);
116118
SwitchButton switchButton = (SwitchButton) findViewById(R.id.switch_button);
117119
switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
118120
@Override

0 commit comments

Comments
 (0)