GLUON 4.0 - I cannot use FloatingActionButton in my Application - gluon-mobile

I migrated my Gluon Mobile Application from 3.0 to 4.0
After that, I cannot include a FloatingActionButton in my application.
This is my class:
...
public class DermatologosPresenter {
#FXML
private View visitasDermatologos;
public void initialize() {
FloatingActionButton fab = new FloatingActionButton();
fab.setOnAction(e -> {
System.out.println("HELLO");
});
visitasDermatologos.getLayers().add(fab);
visitasDermatologos.setShowTransitionFactory(BounceInRightTransition::new);
...
I have this error in my Netbeans:
Javier

You have to use:
view.getLayers().add(fab.getLayer())

Related

dropwizard version migration and DI

I've run to some issues trying to migrate dropwizard from 1.2 to 2.0.24 (and 2.0.25) related to DI, wondering if someone has had same issues or any ideas.
We have one application,
public class Account extends Application<AccountConfiguration> {
public static void main(String[] args) throws Exception {
new Account().run(args);
}
#Override
public void initialize(Bootstrap<Configuration> bootstrap) {
bootstrap.addBundle(new DropwizardBundle<>());
}
#Override
public void run(AccountConfiguration configuration, Environment environment) throws Exception {
...
environment.jersey().register(new SessionResource(authenticationService));
}
}
The DropWizardBundle class binds an instance to a class:
public void run(AccountConfiguration configuration, Environment environment) {
environment.jersey().register(new AbstractBinder() {
#Override
protected void configure() {
bind(configuration.getResponder()).to(Responder.class);
}
});
And the SessionResource looks like
#Path("/sessions")
#Consumes(MediaType.APPLICATION_JSON)
#Produces({MediaType.APPLICATION_JSON, "application/v1+json"})
#RequiredArgsConstructor
#Timed
public class SessionResource {
#Inject
private Responder responder;
private final AuthenticationService authenticationService;
#POST / #GET methods
}
The current code, in Dropwizard 1.2 is running and Responder is injected. Switching to 2.0.24/25 Responder is null. I am wondering if I missed something in the migration..
I'm not sure if this is working the way you intended (or the way you are think it is) in version1.X for you. I do not know what configuration.getResponder() is returning so I can't really test your case. I found for resource classes using DI, a lot of problems I see people face can be solved by registering the class and allow the H2K instantiate the resources for you.
environment.jersey().register(SessionResource.class);
You will have to update how AuthenticationService is passed into the resource by registering it to so it can also be injected. The below is an example of registering it as a AuthenticationService as a singleton.
public void run(AccountConfiguration configuration, Environment environment) {
environment.jersey().register(new AbstractBinder() {
#Override
protected void configure() {
//Not sure how AuthenticationService is instantiate but this is an example
bind(new AuthenticationService()).to(AuthenticationServic.class).in(Singleton.class);
}
});

Custom renderer doesn't work in iOS + library

I don't know why my Xamarin.Forms custom renderer doesn't work if I put it into a library and only on iOS, somebody could help me?
[assembly: ExportRenderer(typeof(HtmlLabel), typeof(HtmlLabelRenderer))]
namespace Plugin.HtmlLabel.iOS
{
public class HtmlLabelRenderer : LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (Control == null) return;
UpdateMaxLines();
UpdateText();
}
It works fine on Android, UWP and iOS if into the project.
https://github.com/matteobortolazzo/HtmlLabelPlugin
Add a do-nothing Initialize static method to your HtmlLabelRenderer class to insure your renderer types are loaded before Forms
Example:
public static void Initialize()
{
}
Usage:
In your AppDelegate before Forms.Init(), call your Initialize method:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Plugin.HtmlLabel.iOS.HtmlLabelRenderer.Initialize();
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}

How to explicitly access the Connector from Widget Side into Vaadin 7?

I create a Widget with his Server Side Class and the Client Side (Connector Class, ServerRPC Class, State Class and Widget Class).
Connector :
#Connect(Custom.class)
public class CustomConnector extends ButtonConnector {
...
public void myFunc() {
// DO Something
}
}
Widget :
public class CustomWidget extends VButton {
...
private CustomConnector conn = new CustomConnector();
public CustomWidget () {
conn.myFunc();
}
...
}
Now from the Widget Class i want to explicitly call/access the Connector Object, which are not a Singleton, so that i can access a function too. How can i solve it?
In my opinion you should not access connector directly from GWT widget. It is against Vaadin 7 architecture where GWT widgets are objects independent from vaadin at all.
However if we are talking about dirty migration from Vaadin 6 to 7 solution could be:
ComponentConnector connector = ConnectorMap.get(client).getConnector(CustomWidget.this); // client is taken from updateFromUIDL method (Vaadin6)
Better solution will be to add "state" listener to the widget
public interface CustomWidgetStateListener {
public void stateChanged();
}
public class CustomWidget extends VButton {
...
CustomWidgetStateListener listener;
public void addStateListener(CustomWidgetStateListener listener) {
this.listener = listener;
}
public void notifyStateChanged() { // You can call notifyStateChanged() whenever you want to notify connector
listener.stateChanged();
}
...
}
public class CustomConnector extends ButtonConnector {
public CustomConnector() {
getWidget().addStateListener(new CustomWidgetStateListener() {
public void stateChanged() {
myFunc();
}
});
}
...
public void myFunc() {
// DO Something
}
}

Blackberry MenuItem Deprecated

I am trying to use the MenuItem class of BlackBerry JDE 6.0 and I am encountering an error "The constructor MenuItem String(String, int, int) is deprecated". I am implementing it using a subclass under the MainScreen class. below is the sample deprecated code:
public class UiFunMainScreen extends MainScreen{
class LoginMenuItem extends MenuItem {
public LoginMenuItem() {
super("Login", 20, 10);
}
public void run() {
login();
}
}
class ClearMenuItem extends MenuItem {
public ClearMenuItem() {
super("Clear", 10, 20);
}
public void run() {
clearTextFields();
}
}
}
Use following version of code to create a MenuItem:
class MyUiScreen extends MainScreen
{
public MyUiScreen()
{
MenuItem myItem = new MenuItem(
new StringProvider("My Menu Item"),
0x230000,
0
);
// rest of codes...
from the RIM BlackBerry API 6.0 Documentation
Creating menu items by subclassing and implementing Runnable
If subclassing the extending class must implement the Runnable interface, which in turn supports abstract dispatching of menu actions on activation.
...
// setup the menu items
MenuItem item = new MyMenuItem();
menu.addItem(item);
...
class MyMenuItem extends MenuItem {
MyMenuItem() {
super(MyResourceBundle.getBundle(), MyResource.MY_MENU_ITEM, 0x230000, 0);
}
public void run() {
// do something
}
}
Explore the API.

Structuremap syntax in version 2.5.4

I have just updated to the latest structuremap dll and now my site no longer works at runtime due to deprecated methods in structuremap so I am trying to update my bootstrapper code.
In my bootstrapper class I have rewritten it to:
public class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(InitializeStructureMap);
}
private static void InitializeStructureMap(IInitializationExpression x)
{
x.AddRegistry(new DatabaseServiceRegistry());
x.For<IArticleService>().Use<ArticleService>();
x.For<IArticleRepository>().Use<SqlArticleRepository>();
}
}
I have added the registry line as I am using Linq to SQL which is in a seperate project.
This is the code that worked in the older version of StructureMap:
public class DatabaseServiceRegistry : Registry
{
public override void ConfigureStructureMap()
{
ForRequestedType<Database>()
.TheDefaultIs(() => new Database(Settings.Default.server))
.CacheBy(InstanceScope.Hybrid);
}
I think I need to rewrite it to something like this?
public void ConfigureStructureMap()
{
ObjectFactory.Configure(x =>
{
For<Database>().Use(new Database(Settings.Default.server));
});
}
This compiles but then I get a runtime error of:
StructureMap Exception Code: 202
No Default Instance defined for PluginFamily MyProject.Data.SqlRepository.Database
What am I doing wrong? I am finding it hard to find documentation that relates to the latest syntax and not referencing deprecated methods :(
You are almost right on with your new 2.5.4 syntax. You are just missing the Hybrid configuration. I tried to reproduce your problem and could not (using trunk or the 2.5.4 release). Here is my successful test.
public class DatabaseServiceRegistry : Registry
{
public const string DefaultSettings = "my settings";
public DatabaseServiceRegistry()
{
For<Database>().HybridHttpOrThreadLocalScoped().Use(new Database(DefaultSettings));
}
}
public class Database
{
public string Settings { get; set; }
public Database(string settings)
{
Settings = settings;
}
}
[TestFixture]
public class Structure_map_configuration
{
[Test]
public void TEST()
{
ObjectFactory.Initialize(cfg =>
{
cfg.AddRegistry<DatabaseServiceRegistry>();
});
ObjectFactory.GetInstance<Database>().Settings.ShouldEqual(DatabaseServiceRegistry.DefaultSettings);
}
}
Is it possible that you have two classes named 'Database' and are configuring the one of them in your registry and a different one in your service location?
Use ObjectFactory.Initialize instead if configure :
ObjectFactory.Initialize(x =>
{
x
.For<IProductsRepository>()
.LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.PerRequest))
.Use<SqlProductsRepository>()
.Ctor<string>("connectionString")
.Is(#"Data Source=.\sqlexpress2008;Initial Catalog=SportsStore;Persist Security Info=True;User ID=xxxxx;Password=xxxxxxx");
});
Hope this helps.

Resources