diff --git a/.travis.yml b/.travis.yml index b73a91a..9ee4f14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6abbedf..f0b3dcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 683eabc..47dd3c8 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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()); } diff --git a/app/build.gradle b/app/build.gradle index 986f468..5cf08a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" } @@ -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' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8d30539..ad1bc84 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="io.github.luizgrp.sectionedrecyclerviewadapter.demo"> - + - + diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example1Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example1Fragment.java index 4cde0fa..26567b5 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example1Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example1Fragment.java @@ -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 contacts = getContactsWithLetter(alphabet); if (contacts.size() > 0) { @@ -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); + } } } @@ -76,7 +76,8 @@ private class ContactsSection extends StatelessSection { List list; ContactsSection(String title, List 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()); @@ -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(); } }); } diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example2Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example2Fragment.java index 8c25527..78a08b8 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example2Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example2Fragment.java @@ -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); + } } } @@ -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()); @@ -98,7 +100,6 @@ private class NewsSection extends StatelessSection { this.imgPlaceholderResId = R.drawable.ic_directions_run_black_48dp; break; } - } private List getNews(int arrayResource) { @@ -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(); } }); } diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example3Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example3Fragment.java index e9c76e3..fabdba6 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example3Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example3Fragment.java @@ -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); + } } } @@ -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: @@ -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) @@ -166,7 +167,6 @@ private class NewsSection extends Section { this.imgPlaceholderResId = R.drawable.ic_directions_run_black_48dp; break; } - } int getTopic() { @@ -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(); } }); } diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example4Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example4Fragment.java index 235106e..cecaa2a 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example4Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example4Fragment.java @@ -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 contacts = getContactsWithLetter(alphabet); if (contacts.size() > 0) { @@ -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); + } } } @@ -77,7 +77,8 @@ private class ExpandableContactsSection extends StatelessSection { boolean expanded = true; ExpandableContactsSection(String title, List 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()); @@ -87,7 +88,7 @@ private class ExpandableContactsSection extends StatelessSection { @Override public int getContentItemsTotal() { - return expanded? list.size() : 0; + return expanded ? list.size() : 0; } @Override @@ -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(); } }); } diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example5Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example5Fragment.java index 2357b10..f104ce4 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example5Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example5Fragment.java @@ -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: @@ -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); + } } } @@ -100,7 +101,8 @@ private class MovieSection extends StatelessSection { List list; MovieSection(String title, List 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()); diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example6Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example6Fragment.java index 82da53a..ecff171 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example6Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example6Fragment.java @@ -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: @@ -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); + } } } @@ -101,7 +102,8 @@ private class ExpandableMovieSection extends StatelessSection { boolean expanded = true; ExpandableMovieSection(String title, List 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()); @@ -111,7 +113,7 @@ private class ExpandableMovieSection extends StatelessSection { @Override public int getContentItemsTotal() { - return expanded? list.size() : 0; + return expanded ? list.size() : 0; } @Override diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example7Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example7Fragment.java index 20c2c0c..35918a3 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example7Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example7Fragment.java @@ -38,7 +38,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, sectionAdapter = new SectionedRecyclerViewAdapter(); - for(char alphabet = 'A'; alphabet <= 'Z';alphabet++) { + for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++) { List contacts = getContactsWithLetter(alphabet); if (contacts.size() > 0) { @@ -67,8 +67,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_example7); + } } } @@ -84,10 +85,9 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onQueryTextChange(String query) { - // getSectionsMap requires library version 1.0.4+ - for (Section section : sectionAdapter.getSectionsMap().values()) { + for (Section section : sectionAdapter.getCopyOfSectionsMap().values()) { if (section instanceof FilterableSection) { - ((FilterableSection)section).filter(query); + ((FilterableSection) section).filter(query); } } sectionAdapter.notifyDataSetChanged(); @@ -119,7 +119,8 @@ private class ContactsSection extends StatelessSection implements FilterableSect List filteredList; ContactsSection(String title, List list) { - super(new SectionParameters.Builder(R.layout.section_ex7_item) + super(SectionParameters.builder() + .itemResourceId(R.layout.section_ex7_item) .headerResourceId(R.layout.section_ex7_header) .build()); @@ -128,8 +129,6 @@ private class ContactsSection extends StatelessSection implements FilterableSect this.filteredList = new ArrayList<>(list); } - - @Override public int getContentItemsTotal() { return filteredList.size(); @@ -152,7 +151,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(); } }); } @@ -174,8 +177,7 @@ public void filter(String query) { if (TextUtils.isEmpty(query)) { filteredList = new ArrayList<>(list); this.setVisible(true); - } - else { + } else { filteredList.clear(); for (String value : list) { if (value.toLowerCase().contains(query.toLowerCase())) { diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example8Fragment.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example8Fragment.java index ba7c2a9..1723862 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example8Fragment.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/Example8Fragment.java @@ -40,7 +40,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: @@ -73,8 +73,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_example8); + } } } @@ -114,7 +115,8 @@ private class NameSection extends StatelessSection { List list; NameSection(String tag, String title) { - super(new SectionParameters.Builder(R.layout.section_ex8_item) + super(SectionParameters.builder() + .itemResourceId(R.layout.section_ex8_item) .headerResourceId(R.layout.section_ex8_header) .build()); @@ -148,7 +150,7 @@ public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) { itemHolder.rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - int adapterPosition = itemHolder.getAdapterPosition(); + final int adapterPosition = itemHolder.getAdapterPosition(); if (adapterPosition != RecyclerView.NO_POSITION) { int positionInSection = sectionAdapter.getPositionInSection(adapterPosition); @@ -167,14 +169,28 @@ public RecyclerView.ViewHolder getHeaderViewHolder(View view) { @Override public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder) { - HeaderViewHolder headerHolder = (HeaderViewHolder) holder; + final HeaderViewHolder headerHolder = (HeaderViewHolder) holder; headerHolder.tvTitle.setText(title); + headerHolder.rootView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(final View view) { + final int adapterPosition = headerHolder.getAdapterPosition(); + if (adapterPosition != RecyclerView.NO_POSITION) { + final int sectionItemsTotal = getSectionItemsTotal(); + + sectionAdapter.removeSection(TAG); + + sectionAdapter.notifyItemRangeRemoved(adapterPosition, sectionItemsTotal); + } + } + }); + headerHolder.btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - int positionToInsertItemAt = 0; + final int positionToInsertItemAt = 0; list.add(positionToInsertItemAt, getRandomName()); @@ -185,7 +201,7 @@ public void onClick(View v) { headerHolder.btnClear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - int contentItemsTotal = getContentItemsTotal(); + final int contentItemsTotal = getContentItemsTotal(); list.clear(); @@ -197,6 +213,7 @@ public void onClick(View v) { private class HeaderViewHolder extends RecyclerView.ViewHolder { + private final View rootView; private final TextView tvTitle; private final Button btnAdd; private final Button btnClear; @@ -204,6 +221,7 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder { HeaderViewHolder(View view) { super(view); + rootView = view; tvTitle = (TextView) view.findViewById(R.id.tvTitle); btnAdd = (Button) view.findViewById(R.id.btnAdd); btnClear = (Button) view.findViewById(R.id.btnClear); diff --git a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/HomeActivity.java b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/HomeActivity.java index 847fe22..e0f1ff6 100644 --- a/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/HomeActivity.java +++ b/app/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/demo/HomeActivity.java @@ -13,7 +13,7 @@ import android.view.MenuItem; public class HomeActivity extends AppCompatActivity - implements NavigationView.OnNavigationItemSelectedListener { + implements NavigationView.OnNavigationItemSelectedListener { private Toolbar toolbar; @@ -26,7 +26,7 @@ protected void onCreate(Bundle savedInstanceState) { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( - this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); @@ -38,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) { HomeFragment homeFragment = new HomeFragment(); getSupportFragmentManager().beginTransaction() - .add(R.id.fragment_container, homeFragment).commit(); + .add(R.id.fragment_container, homeFragment).commit(); drawer.openDrawer(GravityCompat.START); } diff --git a/app/src/main/res/drawable/selector_btn.xml b/app/src/main/res/drawable/selector_btn.xml index 1096935..26622ef 100644 --- a/app/src/main/res/drawable/selector_btn.xml +++ b/app/src/main/res/drawable/selector_btn.xml @@ -1,6 +1,6 @@ - - - + + + diff --git a/app/src/main/res/drawable/selector_item.xml b/app/src/main/res/drawable/selector_item.xml index 1870208..1fdfdc8 100644 --- a/app/src/main/res/drawable/selector_item.xml +++ b/app/src/main/res/drawable/selector_item.xml @@ -1,6 +1,6 @@ - - - + + + diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index f8007e4..cae2968 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -1,17 +1,17 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/drawer_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:openDrawer="start"> + android:layout_height="match_parent"/> + app:menu="@menu/activity_home_drawer"/> diff --git a/app/src/main/res/layout/app_bar_home.xml b/app/src/main/res/layout/app_bar_home.xml index 47c58a9..b472b0e 100644 --- a/app/src/main/res/layout/app_bar_home.xml +++ b/app/src/main/res/layout/app_bar_home.xml @@ -1,11 +1,11 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:context="io.github.luizgrp.sectionedrecyclerviewadapter.demo.HomeActivity"> + app:popupTheme="@style/PopupOverlay"/> - + diff --git a/app/src/main/res/layout/content_home.xml b/app/src/main/res/layout/content_home.xml index 006653a..61abfe5 100644 --- a/app/src/main/res/layout/content_home.xml +++ b/app/src/main/res/layout/content_home.xml @@ -1,17 +1,17 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:context="io.github.luizgrp.sectionedrecyclerviewadapter.demo.HomeActivity" + tools:showIn="@layout/app_bar_home" + android:background="@color/app_background_color"> + android:layout_height="match_parent"/> diff --git a/app/src/main/res/layout/fragment_ex1.xml b/app/src/main/res/layout/fragment_ex1.xml index 3e6c255..225e747 100644 --- a/app/src/main/res/layout/fragment_ex1.xml +++ b/app/src/main/res/layout/fragment_ex1.xml @@ -1,7 +1,8 @@ + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent">