HeaderAndFooterRecyclerView


Source link: https://github.com/cundong/HeaderAndFooterRecyclerView

HeaderAndFooterRecyclerView

Introduction

HeaderAndFooterRecyclerView is a RecyclerView solution that supports addHeaderView, addFooterView to a RecyclerView.

Through this library, you can implement RecyclerView's Page Loading by dynamically modify the FooterView's State, such as "loading", "loading error", "loading success", "slipping to the bottom".

How to Use It

  • Add HeaderView FooterView

  mHeaderAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter(mDataAdapter);

mRecyclerView.setAdapter(mHeaderAndFooterRecyclerViewAdapter);

 mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

 //add a HeaderView

RecyclerViewUtils.setHeaderView(mRecyclerView, new SampleHeader(this));

 //add a FooterView

RecyclerViewUtils.setFooterView(mRecyclerView, new SampleFooter(this));
  • LinearLayout/GridLayout/StaggeredGridLayout???RecyclerView????
mRecyclerView.addOnScrollListener(mOnScrollListener);
private EndlessRecyclerOnScrollListener mOnScrollListener = new EndlessRecyclerOnScrollListener() {

 @Override

public void onLoadNextPage(View view) {

 super.onLoadNextPage(view);

  LoadingFooter.State state = RecyclerViewStateUtils.getFooterViewState(mRecyclerView);

 if(state == LoadingFooter.State.Loading) {

  Log.d("@Cundong", "the state is Loading, just wait..");

  return;

 
}

  mCurrentCounter = mDataList.size();

  if (mCurrentCounter < TOTAL_COUNTER) {

  // loading more

  RecyclerViewStateUtils.setFooterViewState(EndlessLinearLayoutActivity.this, mRecyclerView, REQUEST_COUNT, LoadingFooter.State.Loading, null);

  requestData();

 
}
 else {

  //the end

  RecyclerViewStateUtils.setFooterViewState(EndlessLinearLayoutActivity.this, mRecyclerView, REQUEST_COUNT, LoadingFooter.State.TheEnd, null);

 
}

}

  
}
;

Attention

If you have already added a HeaderView for RecyclerView by RecyclerViewUtils.setHeaderView(mRecyclerView, view); , then call the ViewHolder 's getAdapterPosition()? getLayoutPosition(), ,the returned value will be affected by the addition of the HeaderView (the return position is the real position + headerCounter).

Therefore, in this case, please use: RecyclerViewUtils.getAdapterPosition(mRecyclerView, ViewHolder.this), RecyclerViewUtils.getLayoutPosition(mRecyclerView, ViewHolder.this) .

Sample

  • add HeaderView?FooterView

  • LinearLayout RecyclerView, Support Page Loading

  • GridLayout RecyclerView, Support Page Loading

  • StaggeredGridLayout RecyclerView, Support Page Loading

  • GridLayout RecyclerView, Support Page Loading, loading Error

License

Copyright 2015 Cundong  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Command line tool to access Android Demo Ui

This tools has 2 modes:

  • Standart mode, application will evaluate all arguments, apply them and exit
  • Live mode, application starts to listen for supplied arguments and apply them. This mode helps to tweak options and receive fast feedback.

A library that converts Time to its equivalent basic local languages starting with three basic Nigeria languages (Yoruba, Hausa and Igbo) with others in pipeline.

CameraView is a well documented, high-level library that makes capturing pictures and videos easy, addressing most of the common issues and needs.

Supports gestures (tap-to-focus, pinch-to-zoom, ...), grid drawing, system permissions handling, smart sizing, metadata support and much more.

Small & simple library to create a link url, mail, mention and tag in TextView.

A custom imageView which implements shared element transition pattern on your desired image.
Using TransitionalImageView instead of android.ImageView you can click on any image to animate it to full screen mode.

Allocine Api for Android, made for RxJava2. It fetches movies, stars, theaters and showtimes.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes