Cyborg for Android

What is Cyborg?

If you are an Android developer then you must know the pain of an Android Application birth, the logs, the screens, the lists, view pagers, adapters, activities, fragments and just the thought about all this code you need to write(or copy) AGAIN, is simply depressing!

Cyborg allows you to quickly develop an Android application using a sophisticated injection mechanism, and a module based architecture, that put together saves a lot of code, time and Android agony.

The amount of code required to use Cyborg in comparison to Android, or other Android frameworks is infinitesimal, it encapsulate actions, callbacks, dispatching events, large repetitive common logical flows and enforces proper Java architecture, while giving you the freedom to write any logic you like.

The module based architecture allows Cyborg to wrap any business logic you need for your application, and any function of Android, with already dozens of modules implemented(Which are currently not a part of this package), e.g. Ads, Bluetooth v2.1, Automation recording, Crash report, Google Analytics, In-App purchases, Location, Share/Feedback/Rate, and plenty more.

This sounds like magic... well, it is not, it is years of hard work, that is finally brought to the surface.

MVC In Android:

There are ongoing debats about the MVC in Android, but in the general sense in Android the Model (Actiity) is a UI component, the Controller(Used to be Activity nowadays Fragments) is a semi-UI component, and the Views are also UI components.

Cyborg defines things differently to overcome this flaw with a Module driven development as the Model, the Views are the only UI components and the Controllers are in place to manage UI behavior and bridge between the Views and the Model, a real MVC/P.

Notice

Since this is the birth of Cyborg, I'm promoting the Birth License for the first 20 clients or more, so I can get a proper feedback and improve the framework and samples.

Be aware that although I have hundreds of actual implementations of every corner of Cyborg exporting these as samples takes time, so we’ll do it together.

At the moment I'm not publishing any extra Modules with Cyborg for the above reasons, once this is done, I would start publishing modules in this store.

In YourApplication initialize Cyborg using the CyborgConfiguration object:

publicclassYourApplication extendsApplication{ @Override @SuppressWarnings("unchecked") publicvoidonCreate(){super.onCreate();// If you plan on using your custom Launching Activity.CyborgBuilder.startCyborg(newCyborgConfiguration(this));// Providing the first layout to preset once the application launches. CyborgBuilder.startCyborg(newCyborgConfiguration(this,R.first_layout_to_display));

// Cyborg allows you to define a name for each of your screens, it can be useful with analytics. CyborgBuilder.startCyborg(newCyborgConfiguration(this,R.first_layout_to_display,"Screen Name")); }}

Application Launcher Activity:

Cyborg has many advantages, the most significant one been that Cyborg practically eliminates the need to declare new Activity or Fragment types, so also launching your application can done via Cyborg's default launching activity.

The ApplicationLauncher Activity is already declared in Cyborg's manifest.xml:

The View

Creating Screen Layouts (Activity layout):

As mentioned Earlier, there is no need to define Fragments, because Cyborg does not use them instead your controller layout will look somewhat like this (You could always wrap two in a regular layout... see the demo project):

Keep in mind that CyborgControllers with a little help will save their own states when onSaveState is called - so give your CyborgViews a unique tag.

The Controller

The Power of Controllers:

The result of the redundency of Activities and Fragments is the CyborgController, in a framework of bizzare MVC this controller provides some structure. The lifecycle of the controller matches to the lifecycle of an Activity, and its function is to control a group of views and their events and update the Model, for example:

The Model

Modules:

Most problematic issue in Android is the Model management, the lack in the ability to pass instances between Activities is a real hole in the design of Android, and this is where Cyborg takes every corner of Android to the next level.

If you have ever tried to use some feature of Android like: track the location of the device, catch networks drop events, develop a Bluetooth or NFC based application, integrate ads, use JNI libs, use Google analytics and anything else you might consider, together with the vast versions of Android, you'll find out that this requires a lot of configuration and is not trivial also for experienced developers but especially for beginners, and this is where the Modules come in...

Modules encapsulate the problematic logic and provide a consistant API for you to use hiding all the possible overhead from you and can be accessed from ANYWHERE in the code.

So if you have an application and you need to wrap some logic, you can create your own Module and access it from any part of the code, for example:

Module Packs:

In most cases you would need to configure the each Module, and in some cases you would have a few Modules packed together conversing about the state of your application each manage its own logic, so for a single or multiple Modules you'll need to declare a ModulePack for example:

@SuppressWarnings("unchecked")publicclassMyModulePack extendsModulesPack{ privateMyModulePack(){ super(MyModule.class); } @Override protectedvoidpreBuildModules(){ // You can get any module declared in the constructor and PRE-CONFIGURE it before it is initialized. getModule(MyModule.class).addString("0"); } @Override protectedvoidpostBuildModules(){ // Technically you can ask for any module and POST-CONFIGURE after it has initialized. getModule(MyModule.class).addString("4");}}

tags

#CyborgForAndroid #AndroidDev #AndroidDeveloper #AndroidSDK

Contact Us

About Us

If you want to know who I am and what I've done, then check out my LinkedIn Profile... (not everything is there)