Ejemplo n.º 1
0
 @Override
 public boolean dispatchKeyEvent(KeyEvent event) {
   if (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
     if (mPanelRoot.getVisibility() == View.VISIBLE) {
       KPSwitchConflictUtil.hidePanelAndKeyboard(mPanelRoot);
       return true;
     }
   }
   return super.dispatchKeyEvent(event);
 }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_kbp_resolved);

    assignViews();
    KeyboardUtil.attach(
        this,
        mPanelRoot,
        // Add keyboard showing state callback, do like this when you want to listen in the
        // keyboard's show/hide change.
        new KeyboardUtil.OnKeyboardShowingListener() {
          @Override
          public void onKeyboardShowing(boolean isShowing) {
            Log.d(TAG, String.format("Keyboard is %s", isShowing ? "showing" : "hiding"));
          }
        });

    KPSwitchConflictUtil.attach(mPanelRoot, mPlusIv, mSendEdt);

    mSendImgTv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // mock start the translucent full screen activity.
            startActivity(new Intent(KBPresolvedActivity.this, TranslucentActivity.class));
          }
        });

    mContentRyv.setLayoutManager(new LinearLayoutManager(this));

    mContentRyv.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              KPSwitchConflictUtil.hidePanelAndKeyboard(mPanelRoot);
            }

            return false;
          }
        });
  }