Beispiel #1
0
  @Override
  protected void loop(int n) {
    p("start runner loop " + mainActivity + ", group: " + group);
    if (heartbeatperiod != 0 && n % heartbeatperiod == 0)
      pl("android id: " + mainActivity.androidId + ", loop: " + n);

    super.loop(n);
    if (!isNetworkInterfaceUp) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  mainActivity.networkStuff.checkWifi();
                }
              },
              "checkwifi")
          .start();
    }
    mainActivity.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            boolean isServerRunning = tablet != null && tablet.isServerRunning();
            gui.serverStatus.setBackgroundColor(
                Colors.aColor(isServerRunning ? Colors.green : Colors.red));
            gui.wifiStatus.setBackgroundColor(
                Colors.aColor(isNetworkInterfaceUp ? Colors.green : Colors.red));
            gui.routerStatus.setBackgroundColor(
                Colors.aColor(isRouterOk ? Colors.green : Colors.red));
            gui.singleStatus.setBackgroundColor(
                Colors.aColor(
                    isServerRunning && isNetworkInterfaceUp && isRouterOk
                        ? Colors.green
                        : Colors.red));
          }
        });
    p("end runner loop " + mainActivity);
  }
Beispiel #2
0
 @Override
 public void buildGui(MessageReceiver.Model model) {
   pl("building gui.");
   final RelativeLayout relativeLayout = gui.builGui();
   gui.setStatusVisibility(
       gui.status[0].getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
   mainActivity.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           mainActivity.setContentView(relativeLayout);
         }
       });
   hasATablet = gui;
   model.addObserver(gui);
   p("building gui adapter.");
   guiAdapterABC = gui.buildGuiAdapter();
   gui.guiAdapterABC = guiAdapterABC;
   hasATablet.setTablet(null);
   guiAdapterABC.setTablet(null);
   p("gui adapter: " + guiAdapterABC);
   p("gui built.");
 }