-
Notifications
You must be signed in to change notification settings - Fork 1
Extending BlueNimble Apps SDK
This wiki intends to show you how to extend the BlueNimble Apps SDK.
Here is how to create your own:
public class AwesomeComponentFactory extends AbstractComponentFactory {
private static final String Id = "awesome";
public AwesomeComponentFactory () {
supportEvent (EventListener.Event.press);
supportEvent (EventListener.Event.longPress);
// add additional events you want to support or other initialization
}
@Override
public String id () {
return Id;
}
@Override
public View create (UIActivity activity, ViewGroup group, LayerSpec layer, ComponentSpec spec, DataHolder dh) {
AwesomeComponent component = new AwesomeComponent (); // could be anything android built-in or yours.
return applyStyle (group, component, spec, dh);
}
@Override
public void bind (ComponentSpec.Binding binding, View view, ApplicationSpec application, ComponentSpec spec, DataHolder dh) {
// Your data binding logic
}
@Override
public void addEvent (UIActivity activity, View view, ApplicationSpec applicationSpec, ComponentSpec component, String eventName, JsonObject eventSpec) {
// your events attachments
}
}
Then register your component factory in the ComponentsRegistry by simply writing:
[UIApplication Instance].getSpec ().componentFactory ().register (new AwesomeComponentFactory ());
Now you can reffer to your component in the spec by awsome like any other component type such as text or button
"awsome:id ? ? aStyle"
For working examples check out BlueNimble Out-Of-The-Box Components
Here is how to create your own:
public class AwesomeService implements Service {
private static final long serialVersionUID = 2077148821012512850L;
public interface Spec {
// your specs (how you want your service to be defined)
}
private enum Verb {
GET,
POST,
DELETE
// Other verbs or less
}
@Override
public void execute (String id, JsonObject masterSpec, ApplicationSpec application, DataHolder dh, Context appContext) throws Exception {
// Your service logic
}
}
Then register your service in the Backend by simply writing:
[UIApplication Instance].getSpec ().backend ().register ("awesomeService", new AwesomeService ());
For working examples check out BlueNimble Out-Of-The-Box Services
Here is how to create your own:
public class AwesomeEffect implements Effect {
private static final long serialVersionUID = 3783743185246914342L;
private static final String Id = "awesome";
@Override
public String id () {
return Id;
}
@Override
public void apply (UIActivity activity, ApplicationSpec application, PageSpec page, Object spec, View origin, DataHolder dh) {
// your effect logic
}
}
Then register your awesome effect in the EffectsRegistry by simply writing:
[UIApplication Instance].getSpec ().effectsRegistry ().register (new AwesomeEffect ());
For working examples check out BlueNimble Out-Of-The-Box Effects.
For more customizations, browse the source code or reach out!