IckleBot /'ikəl'bôt/ noun. 1 A boilerplate code generator with a simplified threading and event model. 2 A runtime dependency injection framework with model-view binding.
##About
IckleBot facilitates quick Android development by generating boilerplate code in Activity
and Fragment
instances and offers alternative simplified threading and event models. It encourages loose-coupling and maintainability by providing a runtime [dependency injection] (http://en.wikipedia.org/wiki/Dependency_injection) framework and model-view binding.
Annotation based Android development with...
-
Dependency Injection for...
- Layouts
- Resources
- System Services
- Applications
- POJOs
-
An alternative threading model which simplifies the execution of worker threads and UI tasks.
-
An alternative event model which simplifies binding event listeners.
-
Activity state management and configuration of window features.
-
Model-View binding which welcomes custom binders.
-
Support for handling network state changes.
##Overview
Leverage features by extending IckleActivity.
public class LoginActivity extends IckleActivity {
...
}
Manage activity configuration. ```java @Fullscreen @Layout(R.layout.act_login) public class LoginActivity extends IckleActivity { ... } ```
Inject views and resources. ```java @Fullscreen @Layout(R.layout.act_login) public class LoginActivity extends IckleActivity {
@InjectView(R.id.edt_username)
private EditText username;
@InjectView(R.id.btn_login)
private Button login;
@InjectDrawable(R.drawable.form_incomplete)
private Drawable form_incomplete;
...
}
<br>
...or let IckleBot figure it out.
```java
@InjectAll
@Fullscreen
@Layout(R.layout.act_login)
public class LoginActivity extends IckleActivity {
private EditText edt_username;
private Button btn_login;
private Drawable form_incomplete;
...
}
Notice that the variable names now assume the id.
Preserve instance state. ```java @InjectAll @Fullscreen @Layout(R.layout.act_tokens) public class LoginActivity extends IckleActivity {
@Stateful
private Integer loginAttempts;
...
}
<br>
Bind an event listener.
```java
@Layout(R.layout.act_messenger)
@Title(R.string.ttl_act_messenger)
public class MessengerActivity extends IckleActivity {
@InjectView(R.id.btn_send)
private Button btnSend;
@Click(R.id.btn_send)
private void submit() {
btnSend.setText("Sending...");
...
}
}
Run a background task. ```java @Layout(R.layout.act_news) @Title(R.string.ttl_act_news) public class NewsActivity extends IckleActivity {
private static final int ASYNC_SYNC_NEWS = 0;
@Override
protected void onResume() {
super.onResume();
runAsyncTask(ASYNC_SYNC_NEWS);
}
@Async(ASYNC_SYNC_NEWS)
private void refreshNews() {
...
}
}
<br>
Bind models to views. **(NOTE: This feature will be isolated in a separate module in the next release)**
```java
@Layout(R.layout.act_home)
@Title(R.string.ttl_act_home)
public class HomeActivity extends IckleActivity {
@InjectIckleService
private BindManager bindManager;
@InjectPojo
private AccountService accountService;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
User user = accountService.getCurrentUser();
bindManager.bind(profileSection, user);
}
}
Respond to network state changes. ```java @Layout(R.layout.act_mail) @Title(R.string.ttl_act_mail) public class MailActivity extends IckleActivity {
@Override
protected void onNetworkConnected() {
inbox.refresh();
}
}
<br><br>
##Setup
### 1. For Maven Based Android Projects
Add the following dependency in your project's pom.xml.
```xml
<dependency>
<groupId>com.lonepulse</groupId>
<artifactId>icklebot</artifactId>
<version>1.2.0</version>
<type>jar</type>
</dependency>
For information on building Android projects using Maven here's Chapter 14 of Maven: The Complete Reference
.
2. For Standard Android Projects
Download the IckleBot + Android-Support jars and add them to your libs folder.
##Wiki
Kickoff with the quickstart and follow the rest of the wiki pages.
##License This library is licensed under [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).