Android Studio show errors on Operands.DOUBLE - double

PLUS("+", Operands.DOUBLE, 0) {
public Double resolve(Double f1, Double f2) {
return Double.valueOf(f1.doubleValue() + f2.doubleValue());
}
},
The Operand.DOUBLE keeps showing an error.
How can I solve this problem?

Related

Unity Problem with input selected in Android

I try this in unity
public class InputsNextFocusBehaviour : MonoBehaviour
{
public InputField _input1;
public InputField _input2;
public InputField _input3;
public InputField _input4;
public InputField _input5;
// Use this for initialization
private void Start()
{
_input1.onValueChanged.AddListener(arg0 =>
{
if (arg0.Length > 0)
{
_input2.Select();
}
});
_input2.onValueChanged.AddListener(arg0 =>
{
if (arg0.Length > 0)
{
_input3.Select();
}
});
_input3.onValueChanged.AddListener(arg0 =>
{
if (arg0.Length > 0)
{
_input4.Select();
}
});
_input4.onValueChanged.AddListener(arg0 =>
{
if (arg0.Length > 0)
{
_input5.Select();
}
});
_input5.onValueChanged.AddListener(arg0 =>
{
if (arg0.Length > 0)
{
Debug.Log("you are the best: the text input is" +
_input1.text + _input2.text + _input3.text + _input4.text + _input5.text);
}
});
}
}
basically when write a letter in the first inputField, select the next one, writes in the other an select next, until the last one.
In windows works ok, but in android around 3rd input, the touchscreenkeyboard does not appear anymore.
is there any way to solve this issue? or is there another alternative that works on windows and android? thanks and sorry for my english
This question has been bothering me for a long time.
Please do not switch the InputField component,use only one InputField component,change the inputfield.textcomponent.
But I also have confusion,some phone models pop up with minimal input.

Distinguishing between mouseDrag and mouseMove in Eclipse Mars

Since I migrated on Mars the drag and drop functionality of my RCP app is not working anymore.
After some debugging I found out a different behavior in Mars from Luna in this class org.eclipse.gef.ui.parts.DomainEventDispatcher in the method:
/**
* #see EventDispatcher#dispatchMouseMoved(org.eclipse.swt.events.MouseEvent)
*/
public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
if (!editorCaptured) {
super.dispatchMouseMoved(me);
if (draw2dBusy())
return;
}
if (okToDispatch()) {
if ((me.stateMask & InputEvent.ANY_BUTTON) != 0)
domain.mouseDrag(me, viewer);
else
domain.mouseMove(me, viewer);
}
}
The distinguish between mouseDrag and mouseMove is not revealed anymore because me.stateMask is 0 even when I am dragging the mouse (click and drag) inside the editor. Does anyone know if this is an Eclipse Bug or new behavior?
UPDATE:
I researched more and the problem doesn't come from there, but there is a method: receive(org.eclipse.swt.events.MouseEvent me) in the SWTEventDispatcher:
private void receive(org.eclipse.swt.events.MouseEvent me) {
currentEvent = null;
updateFigureUnderCursor(me);
if (captured) {
if (mouseTarget != null)
currentEvent = new MouseEvent(this, mouseTarget, me);
} else {
IFigure f = root.findMouseEventTargetAt(me.x, me.y);
if (f == mouseTarget) {
if (mouseTarget != null)
currentEvent = new MouseEvent(this, mouseTarget, me);
return;
}
if (mouseTarget != null) {
currentEvent = new MouseEvent(this, mouseTarget, me);
mouseTarget.handleMouseExited(currentEvent);
}
setMouseTarget(f);
if (mouseTarget != null) {
currentEvent = new MouseEvent(this, mouseTarget, me);
mouseTarget.handleMouseEntered(currentEvent);
}
}
}
In the specific case when I click on a figure/editpart, after dispatchMouseReleased is called (from SWTEventDispatcher), in the method receive(..), on Luna 'IFigure f = root.findMouseEventTargetAt(me.x, me.y);' is null and now on Mars it returns a Figure. This is the current difference I found that makes the drag and drop not work.
Yet..I don't understand what the difference is between Luna and Mars that org.eclipse.draw2d.findMouseEventTargetAt works differently.
So I managed to solve this problem.. org.eclipse.draw2d.Figure.findMouseEventTargetInDescendantsAt was changed from Luna to Mars.
in Luna we have this code:
if (fig.containsPoint(PRIVATE_POINT.x, PRIVATE_POINT.y)) {
fig = fig.findMouseEventTargetAt(PRIVATE_POINT.x,
PRIVATE_POINT.y);
return fig;
}
Mars:
if (fig.containsPoint(PRIVATE_POINT.x, PRIVATE_POINT.y)) {
fig = fig.findMouseEventTargetAt(PRIVATE_POINT.x,
PRIVATE_POINT.y);
if (fig != null) {
return fig;
}
}
I have my own class that extends LayeredPane and I had to override this method to always return the figure, even when it's null. Somehow in the receive(MouseEvent me) method from SWTEventDispatcher the root.findMouseEventTargetAt(me.x, me.y) should return null in the specific case a figure is being clicked and dragged but was returning a value != null.

Log to console from Javascript

Is it possible to log to the java console?
I've tried to supply an object with a method on it to use for logging but nothing shows up in debug console.
Am I missing something?
window.setMember("mylog", new Console());
execute("mylog.log('11111111'))
public class Console {
public void log(Object ... objects) {
Logger...get..then..log(obj);
}
}
Is there a better way to log to the Java console ?
This is not working.
Unfortunately, my code relies on a number of libraries and I am unable to push the solution to the UI4J repo.
It basically overrides the normal console.log and works similarly. It intentionally avoids to JSON.stringify(object) since circular dependencies can cause serious issues.
The code:
import netscape.javascript.JSObject;
import momomo.com.Opensource.sources.Functional.lambdas.version.interfaces.Lambda;
....
try {
this.page = navigate( IO.toString(file) );
putConsole();
}
finally {
IO.remove(file);
}
private void putConsole() {
// Note that we call log using the entire arguments ( array )
execute("console.log = function() {" +
put(CONSOLE) + ".log(arguments);" +
"};");
}
}
private static final Console CONSOLE = new Console();
public static final class Console {
public void log(JSObject js) {
StringBuilder sb = new StringBuilder();
iterate(js, (o) -> {
sb.append(o).append(" ");
});
$Log.info(Console.class, sb.toString());
}
}
public static void iterate(JSObject js, Lambda.V1<Object> lambda) {
iterate(js, lambda.R1());
}
public static void iterate(JSObject js, Lambda.R1<Boolean, Object> lambda) {
if ( js != null ) {
Object member;
int i = 0;
while (true) {
member = js.getSlot(i);
if ( "undefined".equals(member) || Is.False( lambda.call(member) ) ) {
return;
}
i++;
}
}
}
Outdated but useful Lambda.java reference:
https://github.com/momomo/Opensource/blob/master/src/momomo/com/Opensource/sources/Functional/lambdas/version/interfaces/Lambda.java
Note that put(CONSOLE) call above, basically calls execute("window").setMember("key", new Console()), so there is no magic there, although I have some other logic to achive the same result.

Chrome issue : Enable/Disable sorting on columns fails in chrome in GWT

I am using CellTable from GWT. When user click on some column header to sort, I would like to disable sorting untill the data is retrieved. For this, I am using following code:
private void setHeadersSortable(boolean enable) {
if (_table.getColumnCount() > 0) {
if (enable) {
// enable only columns specified in _sortPropertyByColumn
Iterator<Column<T, ?>> sortableColsIter = _sortPropertyByColumn.keySet().iterator();
while (sortableColsIter.hasNext()) {
sortableColsIter.next().setSortable(enable);
}
} else {
// disable all columns
for (int i = 0; i < _table.getColumnCount(); i++) {
_table.getColumn(i).setSortable(enable);
}
}
_table.redrawHeaders();
}
}
This all works fine in Firefox and IE but not in chrome.
It seems that in Chrome, it fails in _table.redrawHeaders(). The call fails in gwt class AbstractHasData which throws IndexOutOfBoundsException
protected void checkRowBounds(int row) {
if (!isRowWithinBounds(row)) {
throw new IndexOutOfBoundsException("Row index: " + row + ", Row size: " + getRowCount());
}
}
protected boolean isRowWithinBounds(int row) {
return row >= 0 && row < presenter.getVisibleItemCount();
}
The issue is resolved by deferring redrawHeaders() call
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
#Override
public void execute() {
_table.redrawHeaders();
}
});
}

gtk: how to hide a window when the application loses focus

I want to duplicate the behaviour of tool windows in OpenOfice. When the application loses focus, the tool windows (if they are not docked) are hidden.
So, I have a main window, and another utility window (win_dock). I want to hide win_dock when all the windows of the application loses focus and show it again if a window gain focus.
What I did is that I connected to the focus-in-event and focus-out-event of all windows of the application, and I maintain a counter of how many windows have focus. When this counter drops to zero, I want to hide win_dock, and if this counter is positive again, I want to show win_dock
The problem is with this solution I can never focus win_dock. Because when I click on it, the main window drops the focus, so it hides win_dock that still hadn't gained the focus. Nevertheless the focus-in-event is still sent to win_dock and the windows reappears. But in the meantime it has lost the focus.
Do you have a better solution?
Here is the Vala source code:
public class Main
{
private Gtk.Builder builder;
private Gtk.Window win_messages;
private Gtk.Window win_dock;
private int focus_count = 0;
public Main() {
builder = new Gtk.Builder();
builder.add_from_file("ui2.glade");
win_messages = builder.get_object("win_messages") as Gtk.Window;
win_dock = builder.get_object("win_dock") as Gtk.Window;
handle_focus(win_messages);
handle_focus(win_dock);
}
public void start(){
win_messages.show_all();
//win_dock.show_all();
Gtk.main();
}
private void handle_focus(Gtk.Window w) {
w.focus_in_event.connect ((w, e) => {
stdout.printf("Focus In (%s)\n", w.name);
focus_count++;
manage_focus(w == win_dock);
});
w.focus_out_event.connect((w, e) => {
stdout.printf("Focus Out (%s)\n", w.name);
focus_count--;
manage_focus(w == win_dock);
});
}
private void manage_focus(bool is_dock){
if(focus_count > 0) {
win_dock.show_all();
stdout.printf("Show (focus: %d)\n", focus_count);
} else if(is_dock) {
win_dock.hide_all();
stdout.printf("Hide (focus: %d, has: %d) dock\n", focus_count, win_dock.is_active ? 1 : 0);
} else if(!is_dock) {
if(win_dock.is_active) {
win_dock.hide_all();
stdout.printf("Hide (focus: %d, has: %d) !dock\n", focus_count, win_dock.is_active ? 1 : 0);
} else {
stdout.printf("Nop (focus: %d, has: %d) !dock\n", focus_count, win_dock.is_active ? 1 : 0);
}
}
}
public static int main (string[] args)
{
Gtk.init (ref args);
Main m = new Main();
m.start();
return 0;
}
}
Thanks.
Is there a good reason to make the dialog disappear? Wouldn't it be enough to make win_dock transient (win_dock.set_transient_for) for the main window?
Otherwise you could try using GLib.Idle.add to call manage_focuswhich will cause
manage_focus to run after all your focus event callbacks have run. It will then have the correct number of focused windows.