Current Version : 1.1.8
Nucleo is the heart of the superb Android application core functionalities to help the developers in developing the Android app with some capabilities such as :
Good code structure.
Handle the major and repetitive things in Android application development such as : Networking, Persistence, Data Flow, Dependency Injections, Custom UI, Extensions and tons of ready to use common functionalities.
Reduce boilerplate code.
Improve separation of concern across application layers.
Easy to use and less headeache during development.
Continously maintained.
Developer focus will be only features during development.
Backed up with code generators and templates to boost your app development.
Developer happiness.
The main recipe is years of experience of developing the applications and realizing that the one app and to many app we have developed have similarities and common functionalities that reused many times. The main show like :
Our ultimate goal is making Nucleo as the reflections of culture and working framework across development team. It encapsulates the complexity to deliver the roboust, stable and high quality Android application.
The concrete implementation of Nucleo focus on how the main three things below working in harmony to support every business rules, expectation and all the components are independent, testable and easy to adapt with changes.
Three main parts that taken most of time our development can be solved with Nucleo with tons of functionalities, abstractions and functions to make developer's life easier. In Presentation architectural pattern Nucleo adapt the Model-View-ViewModel to handle data flow from the Presentation Layer to Data Layer.
The data in flow will be encapsulated in RxJava and LiveData observable object that brings the flexibility to be manipulated in their stream before the data to be consumed by the presentation layer. All the communication are inward and independent means that the each layer can be stood independently to do their responsibility without knowing each other, will be delivering through abstraction and to be able to isolated testing. We keep the relations among objects separated as much as possible to keep the cleanliness of the architecture. We keep the S.O.L.I.D flag flying high in this codebase.
Sample implementation of Nucleo data flow in a sequence diagram as follow :
So the class diagrams design of each object above will be defined as follow :
They are working independently, so how they can do task in harmony? thanks to the power of Dependency Injection that able nailing the dependency process among application components so no more hard dependency in Nucleo.
As the simplest Dependency Injection as the illustration below, when you need the object to be dependant then there's provider that fulfill that dependency to you without you need to do it by your self.
Koin fulfill our needs of Dependency Injection implementation, the main reason why we choose Koin as DI tool in Nucleo is the easiest implementation and learning curve that won't take long to any Android Developers even for inexperienced ones!
Koin offers some great features to implement DI and help the Nucleo to keep clean in many operations such as :
These code below will be telling you the magic of Koin in nailing our application components and generate the dependency graph.
A module in Kotlin
val profileModule = module {
single { ApiService.createReactiveService(ProfileApiClient::class.java, get(), get(named(BASE_URL))) }
single { ProfileApi(get()) }
single<ProfileRepository> { ProfileDataStore(get()) }
single<ProfileUseCase> { ProfileInteractor(get()) }
viewModel { ProfileViewModel(get(), get()) }
}
Nailing all module into Koin component
startKoin {
androidContext(this@BaseApplication)
modules(getDefinedModules())
}
Where getDefineModules()
will be
override fun getDefinedModules(): List<Module> {
return listOf(
apiModule,
dbModule,
preferenceModule,
rxModule,
utilityModule,
profileModule,
commentModule,
samplePreferenceModule,
endlessModule
)
}
And as the common DI tools, we can just use the dependency through the constructor or property. Here it is the sample implementation of calling an instance of viewmodel
object :
private val profileViewModel: ProfileViewModel by viewModel()
So easy right? Let's see how Nucleo provides you tons of functionalities to make your life as Developer comes easier.
No | Feature | Description |
---|---|---|
1 | Networking | Using roboust OkHttp-Retrofit-RXJava as the core of functionalities to abstract the Rest Api or webservice request. It handles various functionalities such as : - Creation of HttpClient object - Configuration of Timeout Custom Interceptor, Certificate Pinning - Response handler - Object Serialization - Authentication |
2 | Database | Manage the implementation and usage of local database persistance using Room library that handles some common functions : - Database Creation - CRUD Data Manipulation - Caching - Encryption coming soon - Reactive and Non Reactive Data Flow |
3 | Preference | Manage the implementation key-value persistance on the top of SharedPreference that handle the manipulation of Object and Primitive value. Such as : - Boolean - Int - String - Long - Float - Object - Encryption coming soon |
4 | Repository Pattern | Main idea of implementing the repository pattern is to abstract (by interface) and encapsulates the access of data source so the outer layer doesn't really know where the data comes from, it can be from network, files or persistence and another one is to make the change of data driver comes easier to be implemented eg. say we want to migrate from Room to Realm we can do just in the implementation or concrete classs of that Repository Interface. |
No | Features | Description |
---|---|---|
1 | Use Case | This play important role to provide application specific business rules. It encapsulates and implements all of the use cases of the system. |
2 | Interactor | It is the concrete implementation of Use Case that behaves to orchestrate required algorithm, manage the flow of data to and from the entities, and direct those entities to use their enterprise wide business rules to achieve the goals of the use case. |
3 | Mapper | To keep the Separation of Concerns work in any element of application components the mapper will behave as the adapter layer that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the Database or the API. It will produce the data that only recognized by the presentation layer as the output of mapping process from data layer. In short, we can have it by doing several ways such as : - Create the extension function - Mapper Object Class |
The data and domain layer powered by the awesomeness of RXJava Observable objects, process and operators. All do it end to end. The flexibility in doing asynchronous, multithreading and manipulating the stream of observable data are the main reason why Nucleo sticks to RXJava as the core of manipulating data from any sources.
No | Features | Description |
---|---|---|
1 | Base Activity | Abstract the Activity that provides common functions that required by the activity such as : - Base Functions ( initLib() , initIntent() , initUI() ,initProcess() , initObservers() , initActions() - Manage permission requestPermissionsSafely() - Manage toolbar setupToolbar() - Show hide Progess Loading showLoading() and hideLoading() - Attach fragments setFragment() - and more... Decendants of this class : - MultiStateActivity - SubActivity - MultiStateSubActivity |
2 | Base Fragment | Handle similar default process to Activity as the subset component of it. Decendants of this class : - MultiStateFragment |
3 | Base and Custom Views | Provide some custom views that enables to do repetitive important task such as : - RecyclerView Custom Adapter Abstraction - RecyclerView Endless Adapter Abstraction - RecyclerView Custom ViewHolder Abstraction - CircleImageView - Flexible Ratio ImageView - PhoneNumberView - EllipseView - MultistateView - CurrencyEditText - ImagePicker Abstraction - ViewPager Custom Adapter Abstraction |
4 | Dialog | Provide some base dialog abstraction to do dialog creation easier such as : - BottomSheetsDialogFragment Abstraction - BaseDialogFragment |
5 | UI State Management | Use the power of Kotlin in sealed class, MultiStateView and LiveData of Architecture component the UI State management is handled in this Result object which handles some condition of : - Loading State - Default - Empty - Success - Failure |
6 | Image Loader | Our ImageViewExt class encapsulates all the static access of various extension functions of loading Image using Glide that simplify the call only into a line! ex : imgAvatar.setImageURI(Uri.parse(it.path)) |
7 | Notification | NucleoNotificationBuilder class handles all the requirement of showing application notification both for pre OS Oreo or above Oreo also with or without image. |
8 | Servicecoming soon |
BaseService class will abstract the foreground service to be adapted with LifecycleAware component of Android Application. |
9 | Extensions | Contains of tons of extension functions to simplify the method or property calling that statically access from any components. Some of extensions covered in this : - View Dimension Converter - View Visibility - View onClick event - View onLongClick event - View onTextChanged event - View decoration (padding, margin) - MultistateView conditional stateView - SystemService WindowManager - SystemService connectivityManager - Context Share Email - Context Share Content - Context Inflater - Context browse and more... |
10 | Validations | Provide various functionalities to handle form-validations such as : - Regexes (Email, Phone, Alphanumeric, MinMax, NotEmpty, Password, Number Only, Alphabet Only) - ReactiveFormActivity - PassiveFormActivity - ReactiveValidator - PassiveValidator - Validation Rules (Checked Rule, Custom Rule, MinMax Rule, PhoneNumber Rule, Regex Rule, Spinner Rule etc) - View Validation such as ImageView Validation, TextInputLayout Validation, Spinner Validation, RadioButton Validation, Checkbox Validation, AutoCompleteTextView Validation, |
11 | Permissions | PermissionUtils handle the basic needs of resource permissions through extension functions that able easily adopted in Activity |
No | Features | Description |
---|---|---|
1 | Analytics Abstraction | Abstract the analytics handler to many analytics provider |
2 | Exception | Handle the common Restful Api Exception |
3 | CommonUtils | Provide common functions that usually needed during development such as : - isNetworkConnected() - getDeviceId() - loadJSONFromAsset() - getCurrentDate() - isMyServiceRunning() - getBitmapFromDrawable() - showKeyboard() & hideSoftKeyboard() and more... |
No | Function | Description |
---|---|---|
1 | Nucleo New Project | Project Skeleton Template that used for new setup new project with Nucleo code base |
2 | Nucleo Fragment | This template will create a fragment and layout class that will implement functions that are frequently used from Nucleo BaseFragment |
3 | Nucleo Empty Activity | This template will create an Activity class and layout that will implement functions that are frequently used from Nucleo BaseActivity |
4 | Nucleo List Activity | This template will create an Activity class, Adapter class and default layout such as MultiStateView, SwipeToRefresh and Recycler view with Nucleo BaseActivity |
5 | Nucleo Data-Domain-DI Generator | This generator will create classes and packages related to the data layer, domain, dependency injection (Koin File) to the view model. |