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

Commit

Permalink
Merge pull request #103 from luizgrp/develop
Browse files Browse the repository at this point in the history
Merge version 1.2.0
  • Loading branch information
luizgrp authored Mar 10, 2018
2 parents c64d766 + 74ba12b commit 1f24843
Show file tree
Hide file tree
Showing 85 changed files with 2,823 additions and 1,998 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ cache:
android:
components:
- tools
- build-tools-25.0.3
- android-25
- build-tools-26.0.2
- android-27
- platform-tools
- extra-android-m2repository
- extra-google-m2repository

script:
./gradlew build

before_install:
- yes | sdkmanager "platforms;android-27"
27 changes: 25 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
# Changelog

## 1.2.0 - 10/03/2018

### Section class
- Remove all deprecated constructors.
- Add methods `isItemViewWillBeProvided`, `isHeaderViewWillBeProvided`, `isFooterViewWillBeProvided`, `isLoadingViewWillBeProvided`, `isFailedViewWillBeProvided` and `isEmptyViewWillBeProvided`.
- Add methods `getItemView`, `getHeaderView`, `getFooterView`, `getLoadingView`, `getFailedView` and `getEmptyView`.

### SectionedRecyclerViewAdapter class
- Remove method `getSectionsMap`.
- Add method `getCopyOfSectionsMap`
- Add method `removeSection(Section)`.

### SectionParameters class
- Add factory method for `Builder` class.

### SectionParameters.Builder class
- Deprecate constructor with itemResourceId as parameter.
- Add method `itemResourceId`.
- Add methods `itemViewWillBeProvided`, `headerViewWillBeProvided`, `footerViewWillBeProvided`, `loadingViewWillBeProvided`, `failedViewWillBeProvided` and `emptyViewWillBeProvided`.

### StatelessSection class
- Remove all deprecated constructors.

## 1.1.3 - 22/07/2017

### Section class
- Add checks for resource ids in `setState` and throw exception if missing
- Add checks for resource ids in `setState` and throw exception if missing.

### SectionedRecyclerViewAdapter class
- Add methods `notifyNotLoadedStateChanged`, `notifyStateChangedToLoaded` and `notifyStateChangedFromLoaded`.
- Add methods `notifyHeaderInsertedInSection`, `notifyFooterInsertedInSection`, `notifyHeaderRemovedFromSection` and `notifyFooterRemovedFromSection`.
- Add methods `notifySectionChangedToVisible` and `notifySectionChangedToInvisible`
- Add methods `notifySectionChangedToVisible` and `notifySectionChangedToInvisible`.

## 1.1.2 - 30/06/2017
### SectionParameters class
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In addition, each Section can have its state(Loading/Loaded/Failed/Empty) contro
Add this to the `dependencies` section in your project-level **build.gradle** file:

```groovy
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.1.3'
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.2.0'
```

## Basic usage
Expand All @@ -34,7 +34,8 @@ class MySection extends StatelessSection {

public MySection() {
// call constructor with layout resources for this Section header and items
super(new SectionParameters.Builder(R.layout.section_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_item)
.headerResourceId(R.layout.section_header)
.build());
}
Expand Down
17 changes: 9 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "io.github.luizgrp.sectionedrecyclerviewadapter.demo"
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand All @@ -22,9 +22,10 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'

testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">

<application
android:allowBackup="true"
Expand All @@ -10,9 +10,9 @@
android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

sectionAdapter = new SectionedRecyclerViewAdapter();


for(char alphabet = 'A'; alphabet <= 'Z';alphabet++) {
for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++) {
List<String> contacts = getContactsWithLetter(alphabet);

if (contacts.size() > 0) {
Expand All @@ -53,8 +52,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example1);
}
}
}

Expand All @@ -76,7 +76,8 @@ private class ContactsSection extends StatelessSection {
List<String> list;

ContactsSection(String title, List<String> list) {
super(new SectionParameters.Builder(R.layout.section_ex1_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex1_item)
.headerResourceId(R.layout.section_ex1_header)
.build());

Expand Down Expand Up @@ -106,7 +107,11 @@ public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), String.format("Clicked on position #%s of Section %s", sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()), title), Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(),
String.format("Clicked on position #%s of Section %s",
sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()),
title),
Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example2);
}
}
}

Expand All @@ -69,7 +70,8 @@ private class NewsSection extends StatelessSection {
int imgPlaceholderResId;

NewsSection(int topic) {
super(new SectionParameters.Builder(R.layout.section_ex2_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex2_item)
.headerResourceId(R.layout.section_ex2_header)
.footerResourceId(R.layout.section_ex2_footer)
.build());
Expand Down Expand Up @@ -98,7 +100,6 @@ private class NewsSection extends StatelessSection {
this.imgPlaceholderResId = R.drawable.ic_directions_run_black_48dp;
break;
}

}

private List<String> getNews(int arrayResource) {
Expand Down Expand Up @@ -128,7 +129,11 @@ public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), String.format("Clicked on position #%s of Section %s", sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()), title), Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(),
String.format("Clicked on position #%s of Section %s",
sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()),
title),
Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example3);
}
}
}

Expand All @@ -91,8 +92,7 @@ public void run() {

if (failed == 1) {
section.setState(Section.State.FAILED);
}
else {
} else {
int arrayResource;
switch (section.getTopic()) {
case NewsSection.WORLD:
Expand Down Expand Up @@ -138,7 +138,8 @@ private class NewsSection extends Section {
int imgPlaceholderResId;

NewsSection(int topic) {
super(new SectionParameters.Builder(R.layout.section_ex3_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex3_item)
.headerResourceId(R.layout.section_ex3_header)
.footerResourceId(R.layout.section_ex3_footer)
.failedResourceId(R.layout.section_ex3_failed)
Expand Down Expand Up @@ -166,7 +167,6 @@ private class NewsSection extends Section {
this.imgPlaceholderResId = R.drawable.ic_directions_run_black_48dp;
break;
}

}

int getTopic() {
Expand Down Expand Up @@ -200,7 +200,11 @@ public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), String.format("Clicked on position #%s of Section %s", sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()), title), Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(),
String.format("Clicked on position #%s of Section %s",
sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()),
title),
Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

sectionAdapter = new SectionedRecyclerViewAdapter();


for(char alphabet = 'A'; alphabet <= 'Z';alphabet++) {
for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++) {
List<String> contacts = getContactsWithLetter(alphabet);

if (contacts.size() > 0) {
Expand All @@ -53,8 +52,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example4);
}
}
}

Expand All @@ -77,7 +77,8 @@ private class ExpandableContactsSection extends StatelessSection {
boolean expanded = true;

ExpandableContactsSection(String title, List<String> list) {
super(new SectionParameters.Builder(R.layout.section_ex4_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex4_item)
.headerResourceId(R.layout.section_ex4_header)
.build());

Expand All @@ -87,7 +88,7 @@ private class ExpandableContactsSection extends StatelessSection {

@Override
public int getContentItemsTotal() {
return expanded? list.size() : 0;
return expanded ? list.size() : 0;
}

@Override
Expand All @@ -107,7 +108,11 @@ public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), String.format("Clicked on position #%s of Section %s", sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()), title), Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(),
String.format("Clicked on position #%s of Section %s",
sectionAdapter.getPositionInSection(itemHolder.getAdapterPosition()),
title),
Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(sectionAdapter.getSectionItemViewType(position)) {
switch (sectionAdapter.getSectionItemViewType(position)) {
case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
return 2;
default:
Expand All @@ -61,8 +61,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example5);
}
}
}

Expand Down Expand Up @@ -100,7 +101,8 @@ private class MovieSection extends StatelessSection {
List<Movie> list;

MovieSection(String title, List<Movie> list) {
super(new SectionParameters.Builder(R.layout.section_ex5_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex5_item)
.headerResourceId(R.layout.section_ex5_header)
.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(sectionAdapter.getSectionItemViewType(position)) {
switch (sectionAdapter.getSectionItemViewType(position)) {
case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
return 2;
default:
Expand All @@ -61,8 +61,9 @@ public void onResume() {

if (getActivity() instanceof AppCompatActivity) {
AppCompatActivity activity = ((AppCompatActivity) getActivity());
if (activity.getSupportActionBar() != null)
if (activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(R.string.nav_example6);
}
}
}

Expand Down Expand Up @@ -101,7 +102,8 @@ private class ExpandableMovieSection extends StatelessSection {
boolean expanded = true;

ExpandableMovieSection(String title, List<Movie> list) {
super(new SectionParameters.Builder(R.layout.section_ex6_item)
super(SectionParameters.builder()
.itemResourceId(R.layout.section_ex6_item)
.headerResourceId(R.layout.section_ex6_header)
.build());

Expand All @@ -111,7 +113,7 @@ private class ExpandableMovieSection extends StatelessSection {

@Override
public int getContentItemsTotal() {
return expanded? list.size() : 0;
return expanded ? list.size() : 0;
}

@Override
Expand Down
Loading

0 comments on commit 1f24843

Please sign in to comment.