示例#1
0
文件: Util.java 项目: gubo/slipwire
  /** @param view */
  public static void showSoftKeyboard(final View view) {
    if (view == null) {
      return;
    }

    final Runnable action =
        new Runnable() {
          @Override
          public void run() {
            final InputMethodManager imm =
                (InputMethodManager)
                    view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
          }
        };

    final View.OnFocusChangeListener restoreOnFocusChangeListener = view.getOnFocusChangeListener();

    final View.OnFocusChangeListener temporaryOnFocusChangeListener =
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(final View v, final boolean hasFocus) {
            view.setOnFocusChangeListener(restoreOnFocusChangeListener);
            view.postDelayed(action, 25);
          }
        };

    view.setOnFocusChangeListener(temporaryOnFocusChangeListener);
    view.requestFocus();
  }
示例#2
0
  private synchronized void handleViewChange(View view, boolean makeServer) {
    if (makeServer) initializeNewSymmetricKey(view instanceof MergeView);

    // if view is a bit broken set me as keyserver
    List<Address> members = view.getMembers();
    if (members == null || members.isEmpty() || members.get(0) == null) {
      becomeKeyServer(local_addr, false);
      return;
    }
    // otherwise get keyserver from view controller
    Address tmpKeyServer = view.getMembers().get(0);

    // I am  keyserver - either first member of group or old key server is no more and
    // I have been voted new controller
    if (makeServer || (tmpKeyServer.equals(local_addr))) becomeKeyServer(tmpKeyServer, makeServer);
    else handleNewKeyServer(tmpKeyServer, view instanceof MergeView);
  }
示例#3
0
文件: Util.java 项目: gubo/slipwire
  /** @param view */
  public static void hideSoftKeyboard(final View view) {
    if (view == null) {
      return;
    }

    final Runnable action =
        new Runnable() {
          @Override
          public void run() {
            final InputMethodManager imm =
                (InputMethodManager)
                    view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(
                view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
          }
        };

    view.postDelayed(action, 25);
  }