コード例 #1
0
ファイル: RhodesActivity.java プロジェクト: stinie/rhodes
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_BACK:
        RhodesService r = RhodesService.getInstance();
        if (DEBUG) Log.d(TAG, "onKeyDown: r=" + r);
        if (r == null) return false;

        MainView v = r.getMainView();
        v.back(v.activeTab());
        return true;
    }

    return super.onKeyDown(keyCode, event);
  }
コード例 #2
0
ファイル: RhodesActivity.java プロジェクト: stinie/rhodes
  public void setMainView(final MainView v, boolean waitUntilNavigationDone) {
    if (DEBUG) Log.d(TAG, "setMainView: v=" + v + "; mMainView=" + mMainView);

    // If there's no previous mMainView, don't wait
    if (mMainView == null) waitUntilNavigationDone = false;

    // Set mMainView right now but not yet do it visible
    mMainView = v;

    // This is action need to be executed when mMainView should become visible
    final Runnable setMainViewVisible =
        new Runnable() {
          public void run() {
            if (DEBUG) Log.d(TAG, "setMainViewAction: v=" + v);
            setContentView(v.getView());
          }
        };

    if (!waitUntilNavigationDone) {
      // Make new MainView visible right now
      setMainViewVisible.run();
    } else {
      // If we're requested to wait until first navigation will be done,
      // use the trick: keep current main view until first navigate will be
      // finished in the new MainView.
      // This will end up in good user experience - user will see
      // new MainView only when it will have completely load its content
      // (no blank screens for user).
      WebView webView = v.getWebView(0);
      webView.setWebViewClient(
          new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
              mWebViewClient.onPageFinished(view, url);
              // Restore standard WebViewClient to be sure this callback will not
              // be called anymore (it should be called only once)
              view.setWebViewClient(mWebViewClient);

              setMainViewVisible.run();
            }
          });
    }
  }