CoreLogic is a framework meant to simplify android development, in the new era of single-activity apps.
CoreLogic does the heavy lifting, so you can code your app the way you want to. Some Android framework components such as Application, Activity, Fragment have subclasses you will need to extend so you can plug in and out different units of functionality into them, and have all the callbacks you need.
- minSdkVersion 14
- compileSdkVersion 28
In your app's build.gradle
(not the root one) add this dependency to your list of app dependencies
dependencies {
implementation 'com.github.claudiu-bele:core-logic:0.4.5'
}
This will provide you with our library, and all the dependencies we use. Currently there isn't an option to get a version of the library without any dependencies.
Our dependencies, which are provided at api level once core-logic
is imported into your project.
- Network: Retrofit(2.6.1) + Gson(2.8.5) + aux libraries
- DI: Koin(2.0.1) + Koin-androidx(2.0.1) + aux libraries
- Events: RxJava(2.2.12) + RxAndroid(2.1.1) + RxRelay(2.1.1) + AutoDispose(1.3.0)
- kotlin-stdlib-jdk8 (1.3.11)*
- AndroidX Navigation (1.0.0)
- AndroidX lifecycle (2.1.0)
- other UI
- ConstrainstLayout(2.0.0-beta2)
- android.material (1.1.0-alpha10)
- com.sothree.slidinguppanel (3.4.0)*
*: up for change
The ability to provide test dependencies will soon be removed. Check Build effective unit tests on setting your project up for all the types of testing you want.
Get started with the Navigation component
Subclass CoreActivity
and CoreFragment
in your classes or the following alternatives based on case:
CoreFragment
: Base fragment which comes backed withcore-logic
functionality.FragmentController
: To capture callbacks fromCoreFragment
, such asonBackPressed
,onActivityResult
. Useful for creating standalone self-contained units of functionality that control activity flow, so one fragment does not need to handle flow of e.g.GoogleSignInActivityResult
CoreNavHostFragment: NavHostFragment
: needed by navigation activities below, maintains navigation graph. Subclass it, or easily initialise withCoreNavHostFragment.create(yourGraphResId: Int, startDestinationArgs: Bundle? = null
)NavFragment: CoreFragment
: preffered fragment subclass for consumers ofNavActivityController
andCoreNavHostFragment
, due to additional propertyval: navController: NavController
. This property allows us to easily access the navigation graph.
CoreActivity
: Base activity which comes backed withcore-logic
functionalityActityController
: To capture callbacks fromCoreActivity
, such asonActivityResult
,onBackPressed
.CoreNavActivity: CoreActivity
: activity supporting the new android navigation components. You only need to provide aCoreNavHostFragment
to it in a function override.NavActivity: CoreNavActivity
: activity that by default contains a Bottom Bar, a Navigation Drawer, and an Action Bar, all automatically updating based on the current position in the navigation tree.
CoreActivity
: Base application which comes baked withcore-logic
functionalityApplicationController
: Capture callbacks fromCoreApplication
We'll go through the packages of the library and what they try to achieve. Explanation for the implementation of the sample and its libraries is here
- Extension functions for reflection (
Class.kt
,KClass.kt
) - for Rx (
Rx.kt
) - for types (
String.kt
)
- base/core
CoreApplication : Application
,CoreActivity : AppCompatActivity
,CoreFragment : Fragment
(androidx). and their controllers. - base controller classes for base classes:
ApplicationController, ActivityController, FragmentController
- activities and fragments have a
getVm(clazz)
for getting a VM that also saves and restores state.
StatefulViewModel: ViewModel
is a model that saves and restores state. Check outMoreInfoViewModel
for an implementation for data that survivesonCleared()
ViewModelActivityController: ActivityController
: controller added automatically byCoreActivity
. Manages saving and restoring the state inStatefulViewModel
sStatefulViewModelFactory: AndroidViewModelFactory
is a view model factory that you can use and is already used inViewModelActivityController
. It can createStatefulViewModel
andViewModel
in 7 different constructor variations!!!
ConstraintLayout
classes for animatingConstraintSet
changes.- (preview)
Recyclerview
-related classes. Might end up making a customRecyclerView.Adapter
- extension functions for
Theme
to retrieve colors from the theme easily (and more to come!)
- navigation-related fragments and activities
- custom
NavHostFragment
- support for multiple start destinations
- navigation controller classes containing layout logic
- formatting through
NumberFormattingUtils
andStringFormattingUtils
- time management through
TimeUtils