Skip to content
This repository was archived by the owner on Feb 27, 2022. It is now read-only.

Commit 2fc3f9a

Browse files
authored
Merge pull request #150 from luizgrp/develop
Release version 2.0.0
2 parents 5c8421e + 650fb22 commit 2fc3f9a

File tree

72 files changed

+885
-572
lines changed

Some content is hidden

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

72 files changed

+885
-572
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ cache:
1616
android:
1717
components:
1818
- tools
19-
- build-tools-26.0.2
20-
- android-27
19+
- build-tools-28.0.3
20+
- android-28
2121
- platform-tools
2222
- extra-android-m2repository
2323
- extra-google-m2repository
@@ -26,4 +26,4 @@ script:
2626
./gradlew build
2727

2828
before_install:
29-
- yes | sdkmanager "platforms;android-27"
29+
- yes | sdkmanager "platforms;android-28"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 2.0.0 - 06/03/2019
4+
5+
- Update to AndroidX
6+
7+
### SectionedRecyclerViewAdapter class
8+
9+
- Add methods `notifyAllItemsInsertedInSection`, `notifyAllItemsInsertedInSection`, `notifyAllItemsChangedInSection`, `notifyAllItemsChangedInSection`
10+
- Add method `getSectionItemViewTypeForAdapterViewType`
11+
312
## 1.2.0 - 10/03/2018
413

514
### Section class

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ In addition, each Section can have its state(Loading/Loaded/Failed/Empty) contro
2121
Add this to the `dependencies` section in your project-level **build.gradle** file:
2222

2323
```groovy
24-
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.2.0'
24+
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:2.0.0'
2525
```
2626

27+
If your project has not been migrated to AndroidX yet, you should use version `1.2.0`.
28+
2729
## Basic usage
2830

2931
##### 1) Create a custom Section class extending StatelessSection

app/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 27
5-
buildToolsVersion '26.0.2'
4+
compileSdkVersion 28
5+
buildToolsVersion '28.0.3'
66

77
defaultConfig {
88
applicationId "io.github.luizgrp.sectionedrecyclerviewadapter.demo"
99
minSdkVersion 14
10-
targetSdkVersion 27
10+
targetSdkVersion 28
1111
versionCode 1
1212
versionName "1.0"
1313
}
@@ -20,12 +20,12 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile project(':library')
25-
compile 'com.android.support:appcompat-v7:27.1.0'
26-
compile 'com.android.support:design:27.1.0'
27-
compile 'com.android.support:recyclerview-v7:27.1.0'
28-
compile 'com.android.support:cardview-v7:27.1.0'
23+
implementation fileTree(dir: 'libs', include: ['*.jar'])
24+
implementation project(':library')
25+
implementation 'androidx.appcompat:appcompat:1.0.2'
26+
implementation 'com.google.android.material:material:1.0.0'
27+
implementation 'androidx.recyclerview:recyclerview:1.0.0'
28+
implementation 'androidx.cardview:cardview:1.0.0'
2929

30-
testCompile 'junit:junit:4.12'
30+
testImplementation 'junit:junit:4.12'
3131
}

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">
45

56
<application
6-
android:allowBackup="true"
7+
android:allowBackup="false"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
910
android:supportsRtl="true"
10-
android:theme="@style/AppTheme.NoActionBar">
11+
android:theme="@style/AppTheme.NoActionBar"
12+
tools:ignore="GoogleAppIndexingWarning">
13+
1114
<activity android:name=".HomeActivity">
1215
<intent-filter>
1316
<action android:name="android.intent.action.MAIN"/>
1417

1518
<category android:name="android.intent.category.LAUNCHER"/>
1619
</intent-filter>
1720
</activity>
21+
1822
</application>
1923

2024
</manifest>

app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example1Fragment.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.github.luizgrp.sectionedrecyclerviewadapter.demo;
22

33
import android.os.Bundle;
4-
import android.support.annotation.Nullable;
5-
import android.support.v4.app.Fragment;
6-
import android.support.v7.app.AppCompatActivity;
7-
import android.support.v7.widget.LinearLayoutManager;
8-
import android.support.v7.widget.RecyclerView;
4+
5+
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
7+
import androidx.fragment.app.Fragment;
8+
import androidx.appcompat.app.AppCompatActivity;
9+
import androidx.recyclerview.widget.LinearLayoutManager;
10+
import androidx.recyclerview.widget.RecyclerView;
911
import android.view.LayoutInflater;
1012
import android.view.View;
1113
import android.view.ViewGroup;
@@ -26,7 +28,7 @@ public class Example1Fragment extends Fragment {
2628

2729
@Nullable
2830
@Override
29-
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
31+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
3032
View view = inflater.inflate(R.layout.fragment_ex1, container, false);
3133

3234
sectionAdapter = new SectionedRecyclerViewAdapter();
@@ -39,7 +41,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3941
}
4042
}
4143

42-
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
44+
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
4345
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
4446
recyclerView.setAdapter(sectionAdapter);
4547

@@ -72,8 +74,8 @@ private List<String> getContactsWithLetter(char letter) {
7274

7375
private class ContactsSection extends StatelessSection {
7476

75-
String title;
76-
List<String> list;
77+
final String title;
78+
final List<String> list;
7779

7880
ContactsSection(String title, List<String> list) {
7981
super(SectionParameters.builder()
@@ -136,7 +138,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
136138
HeaderViewHolder(View view) {
137139
super(view);
138140

139-
tvTitle = (TextView) view.findViewById(R.id.tvTitle);
141+
tvTitle = view.findViewById(R.id.tvTitle);
140142
}
141143
}
142144

@@ -150,8 +152,8 @@ private class ItemViewHolder extends RecyclerView.ViewHolder {
150152
super(view);
151153

152154
rootView = view;
153-
imgItem = (ImageView) view.findViewById(R.id.imgItem);
154-
tvItem = (TextView) view.findViewById(R.id.tvItem);
155+
imgItem = view.findViewById(R.id.imgItem);
156+
tvItem = view.findViewById(R.id.tvItem);
155157
}
156158
}
157159
}

app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example2Fragment.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.github.luizgrp.sectionedrecyclerviewadapter.demo;
22

33
import android.os.Bundle;
4-
import android.support.annotation.Nullable;
5-
import android.support.v4.app.Fragment;
6-
import android.support.v7.app.AppCompatActivity;
7-
import android.support.v7.widget.LinearLayoutManager;
8-
import android.support.v7.widget.RecyclerView;
4+
5+
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
7+
import androidx.fragment.app.Fragment;
8+
import androidx.appcompat.app.AppCompatActivity;
9+
import androidx.recyclerview.widget.LinearLayoutManager;
10+
import androidx.recyclerview.widget.RecyclerView;
911
import android.view.LayoutInflater;
1012
import android.view.View;
1113
import android.view.ViewGroup;
@@ -27,7 +29,7 @@ public class Example2Fragment extends Fragment {
2729

2830
@Nullable
2931
@Override
30-
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
32+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
3133
View view = inflater.inflate(R.layout.fragment_ex2, container, false);
3234

3335
sectionAdapter = new SectionedRecyclerViewAdapter();
@@ -37,7 +39,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3739
sectionAdapter.addSection(new NewsSection(NewsSection.TECHNOLOGY));
3840
sectionAdapter.addSection(new NewsSection(NewsSection.SPORTS));
3941

40-
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
42+
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
4143
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
4244
recyclerView.setAdapter(sectionAdapter);
4345

@@ -63,8 +65,6 @@ private class NewsSection extends StatelessSection {
6365
final static int TECHNOLOGY = 2;
6466
final static int SPORTS = 3;
6567

66-
final int topic;
67-
6868
String title;
6969
List<String> list;
7070
int imgPlaceholderResId;
@@ -76,8 +76,6 @@ private class NewsSection extends StatelessSection {
7676
.footerResourceId(R.layout.section_ex2_footer)
7777
.build());
7878

79-
this.topic = topic;
80-
8179
switch (topic) {
8280
case WORLD:
8381
this.title = getString(R.string.world_topic);
@@ -175,7 +173,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
175173
HeaderViewHolder(View view) {
176174
super(view);
177175

178-
tvTitle = (TextView) view.findViewById(R.id.tvTitle);
176+
tvTitle = view.findViewById(R.id.tvTitle);
179177
}
180178
}
181179

@@ -201,9 +199,9 @@ private class ItemViewHolder extends RecyclerView.ViewHolder {
201199
super(view);
202200

203201
rootView = view;
204-
imgItem = (ImageView) view.findViewById(R.id.imgItem);
205-
tvHeader = (TextView) view.findViewById(R.id.tvHeader);
206-
tvDate = (TextView) view.findViewById(R.id.tvDate);
202+
imgItem = view.findViewById(R.id.imgItem);
203+
tvHeader = view.findViewById(R.id.tvHeader);
204+
tvDate = view.findViewById(R.id.tvDate);
207205
}
208206
}
209207
}

app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example3Fragment.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import android.os.Bundle;
44
import android.os.Handler;
5-
import android.support.annotation.Nullable;
6-
import android.support.v4.app.Fragment;
7-
import android.support.v7.app.AppCompatActivity;
8-
import android.support.v7.widget.LinearLayoutManager;
9-
import android.support.v7.widget.RecyclerView;
5+
6+
import androidx.annotation.NonNull;
7+
import androidx.annotation.Nullable;
8+
import androidx.fragment.app.Fragment;
9+
import androidx.appcompat.app.AppCompatActivity;
10+
import androidx.recyclerview.widget.LinearLayoutManager;
11+
import androidx.recyclerview.widget.RecyclerView;
1012
import android.view.LayoutInflater;
1113
import android.view.View;
1214
import android.view.ViewGroup;
@@ -26,13 +28,13 @@
2628

2729
public class Example3Fragment extends Fragment {
2830

29-
private Handler mHandler = new Handler();
31+
private final Handler mHandler = new Handler();
3032

3133
private SectionedRecyclerViewAdapter sectionAdapter;
3234

3335
@Nullable
3436
@Override
35-
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
37+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
3638
View view = inflater.inflate(R.layout.fragment_ex3, container, false);
3739

3840
sectionAdapter = new SectionedRecyclerViewAdapter();
@@ -52,7 +54,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5254
loadNews(techNews);
5355
loadNews(sportsNews);
5456

55-
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
57+
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
5658
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
5759
recyclerView.setAdapter(sectionAdapter);
5860

@@ -173,7 +175,7 @@ int getTopic() {
173175
return topic;
174176
}
175177

176-
public void setList(List<String> list) {
178+
void setList(List<String> list) {
177179
this.list = list;
178180
}
179181

@@ -263,7 +265,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
263265
HeaderViewHolder(View itemView) {
264266
super(itemView);
265267

266-
tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
268+
tvTitle = itemView.findViewById(R.id.tvTitle);
267269
}
268270
}
269271

@@ -300,9 +302,9 @@ private class ItemViewHolder extends RecyclerView.ViewHolder {
300302
super(view);
301303

302304
rootView = view;
303-
imgItem = (ImageView) view.findViewById(R.id.imgItem);
304-
tvHeader = (TextView) view.findViewById(R.id.tvHeader);
305-
tvDate = (TextView) view.findViewById(R.id.tvDate);
305+
imgItem = view.findViewById(R.id.imgItem);
306+
tvHeader = view.findViewById(R.id.tvHeader);
307+
tvDate = view.findViewById(R.id.tvDate);
306308
}
307309
}
308310
}

0 commit comments

Comments
 (0)