SuperRecyclerView


Source link: https://github.com/nicolkill/SuperRecyclerView

Super RecyclerView

Super RecyclerView is a library that helps to use RecyclerView adapter without code, just using annotations on your class, creating Collection of that class and creating Adapter that parametrize that class, and its all.

Features

  • No adapter code required
  • Click and Long Click events
  • View element filter/hide
  • Single view click events
  • Data events (new, remove and replace single and all data)
  • Animations, single animation listener

You can know how it works if you see the code, all it's on SuperRecyclerAdapter file

For more functions or bugs, create a issue.

Usage

Step 1:

Add gradle dependecy

dependencies {

compile 'com.nicolkill:superrecyclerview:{
latest_release
}
' 
}
 

Step 2:

Use the LayoutResource annotation in your class and BindField of the method that you want bind:

@LayoutResource(R.layout.row) public class Option {

private int mOptionNumber;

public Option(int number) {

mOptionNumber = number;
  
}

@BindField(id = R.id.option_name)
  public String getOptionName() {

return "Option " + (mOptionNumber + 1);

  
}

@BindField(type = BindField.Type.IMAGE, id = R.id.option_logo)
  public String getOptionImage(Context context) {

return "https://dummyimage.com/200x200/" +

  Integer.toHexString(context.getResources().getColor(R.color.colorPrimary)) +

  "/ffffff.png&text=" + (mOptionNumber + 1);

  
}
  
}

Step 3:

Create the adapter:

ArrayList<Option> options = new ArrayList<>();
 SuperRecyclerAdapter<Option> adapter = new SuperRecyclerAdapter<>(options);
 

Step 4:

Customize the adapter with the functions and listeners that you want

// click adapter.setOnClickListener(new ClickListener<Option>() {

  @Override
  public void onItemSelected(View view, int position, Option element) {

Snackbar.make(view, "Click option selected: " + element.getOptionName(), Snackbar.LENGTH_SHORT).show();

  
}
 
}
);
  // long click adapter.setOnLongClickListener(new LongClickListener<Option>() {

  @Override
  public void onLongClickItemSelected(View view, int position, Option element) {

Snackbar.make(view, "Long Click ppt #### [Add slides:][Intro Activity]ion selected: " + element.getOptionName(), Snackbar.LENGTH_SHORT).show();

  
}
 
}
);
  // data listener adapter.addOnDataChangeListener(new OnDataChangeListener<Option>() {

  @Override
  public void onDataAdded(List<Option> objects) {

Log.e(TAG, "New data is added: " + objects.toString());

  
}

@Override
  public void onDataRemoved(List<Option> last) {

Log.e(TAG, "Data is removed: " + last.toString());

  
}

@Override
  public void onSimpleDataAdded(Option object) {

Log.e(TAG, "Individual data is added: " + object.getOptionName());

  
}

@Override
  public void onSimpleDataRemoved(Option object) {

Log.e(TAG, "Individual data is removed: " + object.getOptionName());

  
}

@Override
  public void onSimpleDataReplaced(Option object, Option last) {

Log.e(TAG, "Data replaced new: " + object.getOptionName() + ", last: " + last.getOptionName());

  
}
 
}
);
  // view functions adapter.addClickOnViewListener(R.id.option_logo, new ViewClickListener<Option>() {

  @Override
  public void onViewClick(View view, int position, Option element) {

Snackbar.make(view, "Click on logo of option selected: " + element.getOptionName(), Snackbar.LENGTH_SHORT)

  .show();

  
}
 
}
);
 adapter.addFilterApplicator(new FilterApplicator() {

  @Override
  public boolean canApplyFilter(int position) {

if (position % 2 == 0) {

 return true;

}

return false;
  
}
 
}
);
 adapter.addFilterToView(R.id.option_name, R.color.colorAccent);
  // view animations adapter.setItemLayoutAnimation(R.anim.slide_in_right);
 adapter.setItemsAnimationListener(new ItemsAnimationListener() {

  @Override
  public void onAnimationStart() {

Log.e(TAG, "Animation start!");

  
}

@Override
  public void onAnimationEnd() {

Log.e(TAG, "Animation end!");

  
}

@Override
  public void onAnimationConfigure(Animation animation, int position) {

// You can configure animation of any element
  
}
 
}
);
 adapter.disableAnimationOnEnd();

Resources

Easily display and retrieve contact information on Android.

Thin wrapper around the Android Bluetooth LE API.

Android animated clock Drawable.

It is a layout like GridLayout, but children in it will fill the column and you can filter your items with animation.

An anti-bikeshedding Kotlin linter with built-in formatter.

ProgressBar with Material Design.

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