Mugen


Source link: https://github.com/vinaysshenoy/mugen

mugen

mugen is a microlibrary for implementing infinite scroll on Android.

Features

  • Add infinite scroll to your lists with a few lines of code.
  • Configuration allows you to decide how and when to trigger loading. You can even disable load more when all items have been fetched for network usage optimization.
  • Supports both AbsListView and RecyclerView! Which means it's one single library to enable infinite scroll for ListView, GridView and RecyclerView instances.

Usage

 //mCollectionView can be a ListView, GridView, RecyclerView or any instance of AbsListView!
  BaseAttacher attacher = Mugen.with(mCollectionView, new MugenCallbacks() {

 @Override

 public void onLoadMore() {

  /* Will be triggered when the next page has to be loaded. 

 * 

 * Do your load operation here. 

 * Note: this is NOT asynchronous! 

 */

 
}

  @Override

 public boolean isLoading() {

  /* Return true if a load operation is ongoing. This will 

 * be used as an optimization to prevent further triggers 

 * if the user scrolls up and scrolls back down before  

 * the load operation finished. 

 *  

 * If there is no load operation ongoing, return false 

 */

  return isLoading;

 
}

  @Override

 public boolean hasLoadedAllItems() {

  /* 

 * If every item has been loaded from the data store, i.e., no more items are 

 * left to fetched, you can start returning true here to prevent any more 

 * triggers of the load more method as a form of optimization. 

 * 

 * This is useful when say, the data is being fetched from the network 

 */

  return false;

 
}

}
).start();

 /* Use this to dynamically turn infinite scroll on or off. It is enabled by default */

attacher.setLoadMoreEnabled(true);

 /* Use this to change when the onLoadMore() function is called.  

  * By default, it is called when the scroll reaches 2 items from the bottom */

attacher.setLoadMoreOffset(4);

 /* 

  * mugen uses an internal OnScrollListener to detect and trigger load events. 

  * If you need to listen to scroll events yourself, you can set this and  

  * mugen will automatically forward all scroll events to the listener. 

  */

attacher.setOnScrollListener(listener);

mugen in action

Notes

mugen will only start working AFTER there are enough items in the list to make it scrollable. Ensure that you load at least enough data first so that the list becomes scrollable.

Installation

There are two ways you can install mugen.

As a gradle dependency(preferred)

Add the line compile 'com.vinaysshenoy:mugen:1.0.2' to your dependencies section in your build.gradle script

Cloning and adding

  1. Clone the repository
  2. Copy the library folder into your project root.
  3. Add the line include ':library' to your settings.gradle file
  4. Then, add the line compile project(':library') to the build.gradle file in your main project.
  5. Do a Gradle sync, and you should be good to go!

License

Copyright 2014 Vinay S Shenoy

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

Android library which uses annotation processor to help Android Developer easy to deal with Bundle to communicate between Activity, Fragment and Service.

PrettyBundle is inspired by Dart

A ViewPager implementation base on RecyclerView's code.

A simple Android library for implementing Bluetooth Serial Port Profile (SPP) communication.

This library imitates Google Inbox mailbox effect on the drop-down return.

A tool for mocking HTTP services.

Features:

  • HTTP response stubbing, matchable on URL, header and body content patterns
  • Request verification
  • Runs in unit tests, as a standalone process or as a WAR app
  • Configurable via a fluent Java API, JSON files and JSON over HTTP
  • Record/playback of stubs
  • Fault injection
  • Per-request conditional proxying
  • Browser proxying for request inspection and replacement
  • Stateful behaviour simulation
  • Configurable response delays

Mock your HTTP responses to test your REST API.

Mocky is a simple app which allows to generate custom HTTP responses. It's helpful when you have to request a build-in-progress WS, when you want to mock the backend response in a single app, or when you want to test your WS client.

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