Humor Random Comments Thread

Android programming.

Apparently the API designer believes that being able to do it in just one thread would be too quaint. So he will force you to use 3.

Sounds like classic Swing programming in Java. Luckily, there now is JavaFX.
 
Nobody likes an unresponsive UI.

By way of explanation, what I want to do is that:

- show dialog
- wait for response from server
- close dialog on response

Provided that the UI is running in a separate thread (which it does), all I have to do is spawn one thread which does the above. Well, not so fast. Turns out that:

- In order to show a dialog, I must manually spawn new a Runnable into UI thread. Never mind that this could be done in a thread-safe way via message passing. Or the framework could be nice and do it itself.

- For some reason, dialog objects passed to UI thread have to be declared as final. But I'm going to be spawning multiple of these dialogs over the lifetime of the object, and trying to re-assign a final variable will throw an exception. So this dictates that the AlertDialog object must be created inside the UI thread's Runnable.

- And, I cannot block the UI thread waiting for the server response, so waiting for server must now go into a separate thread, spawned from within the UI Runnable. While at it, I must also take care to block the main thread, so it does not attempt to read from the socket while this thread does.

- By some miracle I am now allowed to call dialog.dismiss() from this other thread. If I wasn't, then I'd have to spawn another UI Runnable...
 
Last edited:
The other option is Google Earth. They've got a Mars mode for it.

Seems to be pretty underdeveloped, unfortunately. Uggly texture collage, and only very few named landmarks... Orbiters Map MFD seems to more useful than this :lol:
 
xEfG7i0.jpg


 
By way of explanation, what I want to do is that:

For comparison, here is the same logic in C# .NET. Just one thread plus delegate/Runnable:

Code:
public void ShowForm(string data) {
    m_DialogOpen = true;
    this.Invoke((MethodInvoker)delegate     {
        Show(m_form);
    });
}

public void HideForm() {
    if (m_DialogOpen) {
        m_DialogOpen = false;
        this.Invoke((MethodInvoker)delegate {
            Hide();
        });
    }
}

public void ThreadMain()
{
    try {
        while (true) {
            byte[] buf = new byte[1024];
            m_Socket.Receive(buf);

            [...] - parse buf into state 

            if (state.Equals("QUERY")) {
                ShowForm(data);
            } else if (state.Equals("ABORTED")) {
                HideForm();
            } else if (state.Equals("STATUS")) {
                if (data.Equals("0")) {
                    MessageBox.Show("Server rejected input!");
                    return;
                } else if (data.Equals("1")) {
                    // accepted, do nothing
                } else {
                    MessageBox.Show("Unknown status code " + data);
                }
            }
        }
    }
    catch (Exception ex) {
        MessageBox.Show("NetDialog error:" + ex);
    }
}
 
Last edited:
Just crossed the border into North California. Smoky as hell from the forest fires.
 
Never underestimate candles.
When all power fails, they will keep your evening going.
 
When all power fails the WiFi fails and the evening isn't worth continuing anymore.

I might or might not be addicted.

If you are really addicted, you are prepared to set up a local WAN in a few hours.... too keep you busy during the brownout. :lol:
 
If you are really addicted, you are prepared to set up a local WAN in a few hours.... too keep you busy during the brownout. :lol:

I could also create an island in the North Atlantic and populate it with dragons. Then again I don't know how either works and without internet, how would I?

I'm a noob.
 
I could also create an island in the North Atlantic and populate it with dragons. Then again I don't know how either works and without internet, how would I?

I'm a noob.

You could print the websites.... :rofl:
 
Better yet, you could 3D-print them and then you could go and live in them.

Better not... for the sake of it... remember, the internet is for porn. And you can only take so much of it at once. :rofl:
 
Back
Top