AutoAdapter


Source link: https://github.com/mnayef95/AutoAdapter

AutoAdapter

Make RecyclerView adapter easy with Adapter annotations.

What is AutoAdapter?

  • Auto create RecyclerView adapter from model with annotations.
  • 1.0.0

How do I get set up?

Project-level build.gradle (<project>/build.gradle):

allprojects {

  repositories {

...

maven {
 url 'https://jitpack.io' 
}

  
}
 
}
 

App-level build.gradle (<project>/<app-module>/build.gradle):

provided 'com.github.mnayef.AutoAdapter:annotations:v1.0.3' annotationProcessor 'com.github.mnayef.AutoAdapter:compiler:v1.0.3' 

Support components

  • ImageView (Picasso, Fresco(GIF))
  • TextView
  • CheckBox
  • RadioButton
  • VideoView
  • Visibility
  • Click
  • LongClick
  • Code
  • LinkPreview ( AndroidLinkPreview)

How to use?

  • Create Java Model.
  • Add Adapter Annotation above of class name

Example:

import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.Toast;  import com.mnayef.autoadapter.R; import com.mnayef.annotations.Adapter; import com.mnayef.annotations.Click; import com.mnayef.annotations.Image; import com.mnayef.annotations.Text; import com.mnayef.annotations.enums.ImageLibraries; import com.mnayef.annotations.enums.ImageSource;
/**  * Created by Mohamed Hamdan on 2017-May-26.  * [email protected]  */ @Adapter(adapterName = "MixAdapter", layoutId = R.layout.mix_row, clickable = true) public class MixModel {

private int id;
  @Text(R.id.title)
  private String title = "";
  @Text(R.id.date)
  private String date = "";
  @Image(value = R.id.thumbnail, library = ImageLibraries.PICASSO, progressId = R.id.thumbnail_progress, source = ImageSource.URL)
  private String thumbnail = "";
  @Image(value = R.id.image, library = ImageLibraries.FRESCO, progressId = R.id.image_progress, source = ImageSource.URL)
  private String image = "";

@Code("if (holder.title.getText().toString().isEmpty()) {
\nholder.title.setVisibility(android.view.View.GONE);
\n
}
\n")
  public String getTitle() {

return title;
  
}

public String getDate() {

return date;
  
}

public String getThumbnail() {

return thumbnail;
  
}

public String getImage() {

return image;
  
}

public void setImage(String image) {

this.image = image;
  
}

public int getId() {

return id;
  
}

@Click(R.id.like)
  public void like(RecyclerView.Adapter adapter, int position, View view) {

Toast.makeText(view.getContext(), "Like: " + getId(), Toast.LENGTH_SHORT).show();

  
}

@Click(R.id.comment)
  public void comment(RecyclerView.Adapter adapter, int position, View view) {

Toast.makeText(view.getContext(), "Comment: " + getId(), Toast.LENGTH_SHORT).show();

  
}

@LongClick(R.id.comment)
  public void commentLongClick(RecyclerView.Adapter adapter, int position, View view) {

Toast.makeText(view.getContext(), "LongClick Comment: " + getId(), Toast.LENGTH_SHORT).show();

  
}
 
}
 

Rebuild your project and use in your activity like this

RecyclerView rvAll = (RecyclerView) view.findViewById(R.id.rv_all);
 rvAll.setLayoutManager(new LinearLayoutManager(getContext()));
 rvAll.setAdapter(new MixAdapter(TestData.getInstance().getMix()));
 

License

Copyright 2017 Mohamed Hamdan  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

Casty is a small Android library that provides a simple media player for Chromecast. It's fully consistent with Google Cast v3.

A modern Android oAuth2 library using OkHttp with resource owner password grant types and easy token refreshing. This library aims to provide a solution for the less commonly used resource owner password grant type as well as providing dynamic parameter support that can be used with frameworks that allow for more flexible and dynamic oAuth2 parameters.

Android Starter is a starter project which implements MVP Pattern. It includes libraries:

  • RxJava2
  • RxAndroid
  • Dagger2
  • Butterknife
  • Crashlytics
  • Timber
  • GreenDao
  • Realm
  • Retrofit
  • OkHttp
  • Gson
  • Picasso

Implementation of List Item from Material Design guidelines.

Android Toolbar with marqueeable title / subtitle.

Shareable is a small android library to help implement direct share and social media actions into your android app. For example if you want to share something specifically to Twitter or Facebook.

The API is design to allow you to specify specific social channels to share to using the Builder design pattern. If the app is not available the default is to use all Intent.ACTION_SEND apps on the phone.

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