Esempio n. 1
0
    @Override
    public boolean onPreDraw() {

      if (updates-- <= 0) {
        target.getViewTreeObserver().removeOnPreDrawListener(this);
        Log.d("Remote display", "PreDrawListener remove from listerners");
        return true;
      } else {

        // RFBServerImpl.host.runOnUiThread(
        Thread t =
            new Thread() {

              @Override
              public void run() {
                updateForView(client, target);
              }
            };
        t.setPriority(Thread.MIN_PRIORITY);
        t.setName("update for view thread");
        t.start();
      }

      return true;
    }
Esempio n. 2
0
  @Override
  public void frameBufferUpdateRequest(
      final RFBClient client, boolean incremental, int x, int y, int w, int h) throws IOException {
    // TODO Auto-generated method stub
    //		host.getWindow().getDecorView().getViewTreeObserver().removeOnPreDrawListener(this);
    //		host.getWindow().getDecorView().getViewTreeObserver().addOnPreDrawListener(this);
    //		updateAttempts = 3;
    // sendWholeScreen(client);

    Thread t =
        new Thread() {

          @Override
          public void run() {
            while (true) {
              try {
                sendWholeScreen(client);
                Thread.sleep(40);
              } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          }
        };
    t.setName("loop update thread");
    t.setUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {

          @Override
          public void uncaughtException(Thread thread, Throwable ex) {
            // TODO Auto-generated method stub
            // thread.start();
          }
        });
    t.start();
  }