void Engine::HandleCmd()

in NearbyConnectionsCpp/app/src/main/cpp/NearbyNativeActivity_Engine.cpp [111:155]


void Engine::HandleCmd(struct android_app *app, int32_t cmd) {
  Engine *eng = reinterpret_cast<Engine *> (app->userData);
  LOGI("message %d", cmd);
  switch (cmd) {
    case APP_CMD_INIT_WINDOW:
      if (app->window != NULL) {
        eng->InitDisplay(APP_CMD_INIT_WINDOW);
        eng->DrawFrame();
      }
      break;
    case APP_CMD_TERM_WINDOW:
      // Disconnect all connections before going down
      eng->OnStopButtonClick();
      // Note that JUI helper needs to know if a window has been terminated
      eng->TermDisplay(APP_CMD_TERM_WINDOW);
      eng->has_focus_ = false;
      break;
    case APP_CMD_RESUME:
      jui_helper::JUIWindow::GetInstance()->Resume(app->activity,
                                                   APP_CMD_RESUME);
      // Players need re-connect since we teared down the connection when we
      // went suspension
      eng->EnableUI(true);
      break;
    case APP_CMD_GAINED_FOCUS:
      // Start animation
      eng->has_focus_ = true;
      jui_helper::JUIWindow::GetInstance()->Resume(app->activity,
                                                   APP_CMD_GAINED_FOCUS);
      break;
    case APP_CMD_LOST_FOCUS:
      // Also stop animating.
      eng->has_focus_ = false;
      eng->DrawFrame();
      break;
    case APP_CMD_CONFIG_CHANGED:
      // Configuration changes
      eng->TermDisplay(APP_CMD_CONFIG_CHANGED);
      eng->InitDisplay(APP_CMD_CONFIG_CHANGED);
      break;
    case APP_CMD_DESTROY:
      ndk_helper::JNIHelper::GetInstance()->DetachCurrentThread();
      break;
  }
}