SlimAdapter


Source link: https://github.com/MEiDIK/SlimAdapter

First At A Glance :)

Intro

A slim & clean & typeable Adapter without# VIEWHOLDER

Features

  • No ViewHolder any more
  • No Reflection
  • Fluent & simple API
  • Multi-typeable adapter
  • Auto DiffUtils
  • Auto LoadMore
  • Support kotlin

Ex Features

  • Add Header & Footer Unlimitly
  • Auto emptyState with emptyView

Setup

compile 'net.idik:slimadapter:2.1.2'

Usages

Java

Step 0: Create SlimAdapter

SlimAdapter.create() SlimAdapter.create(SlimAdapterEx.class) //For ex features if need 

Step 1: register data types & attachTo target RecyclerView

  • register(layoutRes, SlimInjector<DataType>)

    Register a DataType to be associated with a layoutRes through a SlimInjector

  • registerDefault(layoutRes, SlimInjector)

    Register a default layoutRes to all the DataType which has not registered by alone.

 SlimAdapter.create()

  .register(R.layout.item_user, new SlimInjector<User>() {

@Override

protected void onInject(User data, IViewInjector injector) {
                         ...// inject data into views?step 2                     
}

  
}
)

  .register(R.layout.item_interger, new SlimInjector<Integer>() {

@Override

protected void onInject(Integer data, IViewInjector injector) {

 ...// inject data into views?step 2

}

  
}
)

  .register(R.layout.item_string, new SlimInjector<String>() {

@Override

protected void onInject(String data, IViewInjector injector) {

 ...// inject data into views?step 2

}

  
}
)

  .registerDefault(R.layout.item_string, new SlimInjector() {

@Override

protected void onInject(Object data, IViewInjector injector) {

 ...// inject data into views?step 2

}

  
}
)

  .attachTo(recyclerView);

  
}

  

Step 2: Inject data into views with fluent apis

injector.text(R.id.name, data.getName())

.text(R.id.age, String.valueOf(data.getAge()))

.textColor(R.id.age, Color.RED)

.textSize(R.id.age, 8)

.longClicked(R.id.name, new View.OnLongClickListener() {

 @Override

 public boolean onLongClick(View v) {

  //do stuff...

  return false;

 
}

}
)

.clicked(R.id.text, new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  //do stuff...

 
}

}
)

.with(R.id.name, new IViewInjector.Action<TextView>() {

 @Override

 public void action(TextView view) {

  //do stuff...

 
}

}
)

...;

Step 3: Use SlimAdapter as normal adapter

 List<Object> data = new ArrayList<>();

{

data.add(new SectionHeader("My Friends"));

data.add(new User("Jack", 21, R.drawable.icon1, "123456789XX"));

data.add(new User("Marry", 17, R.drawable.icon2, "123456789XX"));

data.add(new SectionHeader("My Images"));

data.add(new Image(R.drawable.cover1));

data.add(new Image(R.drawable.cover2));

data.add(new Image(R.drawable.cover3));

data.add(new Image(R.drawable.cover4));

data.add(new Image(R.drawable.cover5));

data.add(new Image(R.drawable.cover6));

data.add(new Image(R.drawable.cover7));

data.add(new Image(R.drawable.cover8));

data.add(new Image(R.drawable.cover9));

data.add(new Image(R.drawable.cover10));

data.add(new Image(R.drawable.cover11));

data.add(new SectionHeader("My Musics"));

data.add(new Music("Love story", R.drawable.icon3));

data.add(new Music("Nothing's gonna change my love for u", R.drawable.icon4));

data.add(new Music("Just one last dance", R.drawable.icon5));

  
}

    slimAdapter.updateData(data);

  

About SlimAdapterEx

SlimAdapter aims to be "Slim", not "Super", so the SlimAdapter core lib is focus on wrapping the RecycleAdapter to provide a more friendly api.

Anyway, Someone needs a more power Adpter, and this is the reason why SlimAdapterEx exsit.

In a word, SlimAdapterEx is focus on providing some power feature in a slim way.

SlimAdapter 💗 Kotlin

SlimAdapter.create()

  .register<String>(R.layout.item_string) {
 data, injector ->

...// inject data into views

  
}

  .register<User>(R.layout.item_user) {
 data, injector ->

...// inject data into views

  
}

  .register<Int>(R.layout.item_interger) {
 data, injector ->

...// inject data into views

  
}

  .registerDefault(R.layout.item_string) {
 data, injector ->

...// inject data into views

  
}

  .attachTo(recyclerView)

License

MIT License  Copyright (c) 2017 ?????  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Resources

Selecting a particular section of text and highlighting with different color and add notes to them.

Watch it in action here

go to this link to see integration

Simple Logger for Android.

Passay is password policy enforcement for Java including password generators and validators helpers.

It is a library that allows to have a horizontal menu with scroll, based on RecyclerView.

Secure Android SharedPreferences Using Conceal Crypto by Facebook.Conceal provides a set of Java APIs to perform cryptography on Android. It was designed to be able to encrypt large files on disk in a fast and memory efficient manner. Implementation on SharedPreferences of Android would be great data Encryption and Decryption.

An Android library providing the possibility to show a dialog, which asks the user to rate the app.

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