EliteMvp


Source link: https://github.com/jemshit/EliteMvp

⚡? Simple, Tiny, Extendable Android MVP library. No complex Base Activity, Base Fragment or Base View. Just base Presenters and View interface for you to extend from. For MVP Cheatsheet read this.

Installation

Step 1. Add JitPack repository to your top level build.gradle file

allprojects {

  repositories {

...

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

  
}
 
}

Step 2. Add library dependency to your module build.gradle file

dependencies {

  ...
  compile 'com.jemshit:EliteMvp:2.0.2' 
}

Structure

There are 7 base Presenter classes to extend from and 1 base View interface.

  • EliteView: empty View interface. Your custom View interfaces must extend this.
  • EliteCorePresenter: Presenter interface with only 2 methods ( attachView(V), detachView()). Your custom Presenter can implement this or you can use one of the ready Presenters listed below.
  • ElitePresenter: Simple Presenter with ready methods ( getView(), isViewAttached(), onDestroy()) for holding View reference. Your custom Presenter can extend this and add additional methods.
  • EliteRx1Presenter: Simple Presenter that has 2 additional methods ( addToOnAttachSubscriptions(s), addToOnCreateSubscriptions(S)) for adding RxJava 1 Subscriptions into CompositeSubscription.
  • EliteRx2Presenter: Simple Presenter that has 2 additional methods ( addToOnAttachDisposables(D), addToOnCreateDisposables(D)) for adding RxJava 2 Disposables into CompositeDisposable.
  • EliteNullViewPresenter: Presenter which returns empty View after View is detached, so no need for view!=null check. Returned empty View methods does nothing when called, read more about Null Object Pattern here.
  • EliteNullViewRx1Presenter: Presenter which follows Null Object Pattern and has two CompositeSubscriptions for RxJava 1 Subscriptions.
  • EliteNullViewRx2Presenter: Presenter which follows Null Object Pattern and has two CompositeDisposables for RxJava 2 Disposables.

UML Diagram:

Usage

public interface YourActivityContract {

  interface View extends EliteView{

void viewMethod();

  
}

abstract class Presenter extends ElitePresenter<YourActivityContract.View> {

public abstract void presenterMethod();

  
}
 
}
public class YourActivityPresenter extends YourActivityContract.Presenter{

@Override public void presenterMethod() {

if(isViewAttached())

  getView().viewMethod();

  
}
 
}
public class YourActivity extends AppCompatActivity implements YourActivityContract.View {
 {

private YourActivityContract.Presenter presenter;

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_your);

 presenter = new YourActivityPresenter();

presenter.attachView(this);

presenter.presenterMethod();

  
}

@Override public void viewMethod(){
...
}

@Override protected void onDestroy() {

super.onDestroy();

presenter.onDestroy();

  
}
 
}

⭕? Check Samples for more examples.

⭕? For Orientation Change, Presenter Retaining, Caching... check applied solutions from community here

Resources

A memory leak detection library for Android and Java.

RecyclerView for devices using arrow keys or D-Pad to navigate. The cell selector is the backbone of this library and can be heavily customized.

HAHA is a Java library to automate the analysis of Android heap dumps.

Lightweight modular ORM for Java and Android.

A simple rating reminder that filters incoming input.

Perfect Java serialization to and from JSON format. Also, supports pretty-printing of JSON.

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