lcacheux / crudroid

Quickly create CRUD Android activities to manipulate data sources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crudroid

Quickly create activities to manage your data in your activity. CRUD is an acronym for Create Read Update Delete, which is all the basic functionality you need to manipulate objects from a database or another source.

Crudroid provide a base activity with these features to have a test application, a debug mode or even part of a real production app ready in a few minutes. Using Android Architecture Components' ViewModel, any kind of data source can be plugged to your activity.

Requirements

Minimum requirement for this library is API level 19 (Android 4.4 KitKat).

Crudroid relies on some libraries from Android Jetpack, so they will be included in your project as dependencies :

  • v7 Support Libraries
  • Design Support Library
  • Lifecycle's LiveData and ViewModel

Usage

Crudroid is available on Maven Central, so you can add it as a dependency. In your root build.gradle file, add mavenCentral():

allprojects {
    repositories {
        mavenCentral()
    }
}

In your module build.gradle file, add crudroid:

dependencies {
    implementation 'net.cacheux.crudroid:crudroid:0.1.0'
}

Declare a new activity in your application which will inherit CrudActivity with T as the model class you want to manage. You'll have to override three abstract methods :

  • getListAdapter: It must provide an instance of CrudListAdapter, which is a RecyclerView.Adapter.
  • getEditViewBinder: Must provide an instance of EditViewBinder, an interface which provide a layout for the edit popup and methods to match its views with the T values.
  • getViewModelClass: Return the class for the CrudViewModel implementation, which is a AndroidViewModel. It must provide a CrudProvider with implementations for the create/read/update/delete methods.

Using simple implementations

For simple models with a single field, simple implementations of EditViewBinder and CrudListAdapter are provided. Your model class must implement the SimpleItem interface with a method to set the value from a String.

About

Quickly create CRUD Android activities to manipulate data sources

License:Apache License 2.0


Languages

Language:Java 100.0%