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 #150 from luizgrp/develop
Browse files Browse the repository at this point in the history
Release version 2.0.0
  • Loading branch information
luizgrp authored Mar 6, 2019
2 parents 5c8421e + 650fb22 commit 2fc3f9a
Show file tree
Hide file tree
Showing 72 changed files with 885 additions and 572 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ cache:
android:
components:
- tools
- build-tools-26.0.2
- android-27
- build-tools-28.0.3
- android-28
- platform-tools
- extra-android-m2repository
- extra-google-m2repository
Expand All @@ -26,4 +26,4 @@ script:
./gradlew build

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

## 2.0.0 - 06/03/2019

- Update to AndroidX

### SectionedRecyclerViewAdapter class

- Add methods `notifyAllItemsInsertedInSection`, `notifyAllItemsInsertedInSection`, `notifyAllItemsChangedInSection`, `notifyAllItemsChangedInSection`
- Add method `getSectionItemViewTypeForAdapterViewType`

## 1.2.0 - 10/03/2018

### Section class
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ 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.2.0'
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:2.0.0'
```

If your project has not been migrated to AndroidX yet, you should use version `1.2.0`.

## Basic usage

##### 1) Create a custom Section class extending StatelessSection
Expand Down
20 changes: 10 additions & 10 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 27
buildToolsVersion '26.0.2'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "io.github.luizgrp.sectionedrecyclerviewadapter.demo"
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -20,12 +20,12 @@ 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'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'

testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
}
10 changes: 7 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">
xmlns:tools="http://schemas.android.com/tools"
package="io.github.luizgrp.sectionedrecyclerviewadapter.demo">

<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.github.luizgrp.sectionedrecyclerviewadapter.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -26,7 +28,7 @@ public class Example1Fragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ex1, container, false);

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

RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(sectionAdapter);

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

private class ContactsSection extends StatelessSection {

String title;
List<String> list;
final String title;
final List<String> list;

ContactsSection(String title, List<String> list) {
super(SectionParameters.builder()
Expand Down Expand Up @@ -136,7 +138,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
HeaderViewHolder(View view) {
super(view);

tvTitle = (TextView) view.findViewById(R.id.tvTitle);
tvTitle = view.findViewById(R.id.tvTitle);
}
}

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

rootView = view;
imgItem = (ImageView) view.findViewById(R.id.imgItem);
tvItem = (TextView) view.findViewById(R.id.tvItem);
imgItem = view.findViewById(R.id.imgItem);
tvItem = view.findViewById(R.id.tvItem);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.github.luizgrp.sectionedrecyclerviewadapter.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -27,7 +29,7 @@ public class Example2Fragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ex2, container, false);

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

RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(sectionAdapter);

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

final int topic;

String title;
List<String> list;
int imgPlaceholderResId;
Expand All @@ -76,8 +76,6 @@ private class NewsSection extends StatelessSection {
.footerResourceId(R.layout.section_ex2_footer)
.build());

this.topic = topic;

switch (topic) {
case WORLD:
this.title = getString(R.string.world_topic);
Expand Down Expand Up @@ -175,7 +173,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
HeaderViewHolder(View view) {
super(view);

tvTitle = (TextView) view.findViewById(R.id.tvTitle);
tvTitle = view.findViewById(R.id.tvTitle);
}
}

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

rootView = view;
imgItem = (ImageView) view.findViewById(R.id.imgItem);
tvHeader = (TextView) view.findViewById(R.id.tvHeader);
tvDate = (TextView) view.findViewById(R.id.tvDate);
imgItem = view.findViewById(R.id.imgItem);
tvHeader = view.findViewById(R.id.tvHeader);
tvDate = view.findViewById(R.id.tvDate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -26,13 +28,13 @@

public class Example3Fragment extends Fragment {

private Handler mHandler = new Handler();
private final Handler mHandler = new Handler();

private SectionedRecyclerViewAdapter sectionAdapter;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ex3, container, false);

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

RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(sectionAdapter);

Expand Down Expand Up @@ -173,7 +175,7 @@ int getTopic() {
return topic;
}

public void setList(List<String> list) {
void setList(List<String> list) {
this.list = list;
}

Expand Down Expand Up @@ -263,7 +265,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder {
HeaderViewHolder(View itemView) {
super(itemView);

tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
tvTitle = itemView.findViewById(R.id.tvTitle);
}
}

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

rootView = view;
imgItem = (ImageView) view.findViewById(R.id.imgItem);
tvHeader = (TextView) view.findViewById(R.id.tvHeader);
tvDate = (TextView) view.findViewById(R.id.tvDate);
imgItem = view.findViewById(R.id.imgItem);
tvHeader = view.findViewById(R.id.tvHeader);
tvDate = view.findViewById(R.id.tvDate);
}
}
}
Loading

0 comments on commit 2fc3f9a

Please sign in to comment.