@Override
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        break;
      case MotionEvent.ACTION_MOVE:
        if (parentView.getVisibility() == View.INVISIBLE) {
          break;
        }
        // 在移动时候leftview始终可见
        setLeftViewVisiable();
        int moveX = (int) event.getRawX();
        int deltaX = tempX - moveX;
        leftViewTotalMove += deltaX;
        long nowTime = System.currentTimeMillis();
        long deltaTime = nowTime - tempTime;
        tempTime = nowTime;
        tempX = moveX;
        if (Math.abs(moveX - downX) > mTouchSlop
            && Math.abs((int) event.getRawY() - downY) < mTouchSlop) {
          isSilding = true;
        }

        if (moveX - downX >= 0 && isSilding) {
          parentView.setX(parentView.getX() - deltaX);

          // 更新listview的文本
          changeListView();
          if (Math.abs(leftViewTotalMove * leftlist_move_rate) > 1) {
            float targetX = leftView.getX() - leftViewTotalMove * leftlist_move_rate;
            if (targetX >= -leftlist_img_width && leftView.getX() <= 0) {
              changeListView();
              leftView.setX(targetX);
            }
            leftViewTotalMove = 0;
          }
        }
        break;
      case MotionEvent.ACTION_UP:
        if (parentView.getVisibility() == View.INVISIBLE) {
          break;
        }
        leftViewTotalMove = 0;
        isSilding = false;
        if (parentView.getX() >= viewWidth / 3) { // 移动继续超过1/3就向右滑动
          scrollRight();
          extendLeftView();
        } else {
          scrollOrigin();
          leftViewSliding((int) leftView.getX(), -(int) leftlist_img_width, leftView, 500l);
        }

        break;
      case MotionEvent.ACTION_CANCEL:
        break;
    }

    return true;
  }
示例#2
0
  /** prevent bottom view get any touch event. Especially in LayDown mode. */
  private void safeBottomView() {
    Status status = getOpenStatus();
    ViewGroup bottom = getBottomView();

    if (status == Status.Close) {
      if (bottom.getVisibility() != INVISIBLE) bottom.setVisibility(INVISIBLE);
    } else {
      if (bottom.getVisibility() != VISIBLE) bottom.setVisibility(VISIBLE);
    }
  }
示例#3
0
  public static void hideProgress(ViewGroup mCover) {
    if (null == mCover) return;

    if (mCover.getVisibility() == View.VISIBLE) {
      mCover.setVisibility(View.GONE);
    }
  }
 /** Toggles visibility of chart/data UI parts. */
 protected void toggleChartData(MenuItem item) {
   if (View.VISIBLE == chartframe.getVisibility()) {
     chartframe.setVisibility(View.GONE);
     dataframe.setVisibility(View.VISIBLE);
     item.setIcon(this.getResources().getDrawable(R.drawable.icon_graph));
   } else {
     chartframe.setVisibility(View.VISIBLE);
     dataframe.setVisibility(View.GONE);
     item.setIcon(this.getResources().getDrawable(R.drawable.icon_data));
   }
 }
  public boolean onBackPressed() {
    if (mWorkspaceGridContainer != null
        && mWorkspaceGridContainer.getVisibility() == View.VISIBLE) {
      mAppearanceContainer.setVisibility(View.VISIBLE);
      mWorkspaceGridContainer.setVisibility(View.GONE);
      //	        View view = mAppearanceContainer.findViewWithTag("grid");
      //            if(view != null)
      //                view.setEnabled(true);

      return true;
    }
    return false;
  }
  public void setDrawerPosition(float value) {
    drawerPosition = value;
    if (drawerPosition > drawerLayout.getMeasuredWidth()) {
      drawerPosition = drawerLayout.getMeasuredWidth();
    } else if (drawerPosition < 0) {
      drawerPosition = 0;
    }
    requestLayout();

    final int newVisibility = drawerPosition > 0 ? VISIBLE : GONE;
    if (drawerLayout.getVisibility() != newVisibility) {
      drawerLayout.setVisibility(newVisibility);
    }
    setScrimOpacity(drawerPosition / (float) drawerLayout.getMeasuredWidth());
  }
 private void showOrHideSelectionMenu() {
   boolean shouldBeVisible = !mSelectedIds.isEmpty();
   boolean isVisible = mSelectionMenuView.getVisibility() == View.VISIBLE;
   if (shouldBeVisible) {
     updateSelectionMenu();
     if (!isVisible) {
       // show menu
       mSelectionMenuView.setVisibility(View.VISIBLE);
       mSelectionMenuView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.footer_appear));
     }
   } else if (!shouldBeVisible && isVisible) {
     // hide menu
     mSelectionMenuView.setVisibility(View.GONE);
     mSelectionMenuView.startAnimation(
         AnimationUtils.loadAnimation(this, R.anim.footer_disappear));
   }
 }
 public void setPanelElementsVisibility(int callType) {
   switch (callType) {
     case Phone.CALL_TYPE_VT:
       if (isCameraInitNeeded()) {
         initializeCamera();
       }
       break;
     case Phone.CALL_TYPE_VT_TX:
       if (isCameraInitNeeded()) {
         initializeCamera();
       }
       break;
     case Phone.CALL_TYPE_VT_RX:
       // Stop the preview and close the camera now because other
       // activities may need to use it
       if (mVideoCallManager.getCameraState() != CameraState.CAMERA_CLOSED) {
         stopRecordingAndPreview();
         closeCamera();
       }
       break;
     default:
       log("setPanelElementsVisibility: callType=" + callType);
       break;
   }
   log(
       "setPanelElementsVisibility: callType= "
           + callType
           + " VideoCallPanel is "
           + mVideoCallPanel.getVisibility()
           + " mCameraPreview is "
           + mCameraPreview.getVisibility()
           + " available="
           + mCameraPreview.isAvailable()
           + " activated= "
           + mCameraPreview.isActivated()
           + " mFarEndView is "
           + mFarEndView.getVisibility()
           + " available="
           + mFarEndView.isAvailable()
           + " activated= "
           + mFarEndView.isActivated());
 }
示例#9
0
  private void changeVisibility() {

    scrollView.setVisibility(View.VISIBLE);

    if (selectAddressChild.getVisibility() == View.GONE) {
      selectAddress.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_minus, 0, 0, 0);
      if (addNewAddressChild.getVisibility() == View.GONE) {

        expand(selectAddressChild);
      } else {

        expand(selectAddressChild);
        selectAddress.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_plus, 0, 0, 0);
        //
        // addNewAddressChild.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_plus,0,0,0);
        collapse(addNewAddressChild);
      }

    } // if it is visible then execute the else part and collapse it
    else {
      selectAddress.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_plus, 0, 0, 0);
      collapse(selectAddressChild);
    }
  }
 /**
  * Returns true if this activity is showing multiple panes -- the headers and a preference
  * fragment.
  */
 public boolean isMultiPane() {
   return hasHeaders() && mPrefsContainer.getVisibility() == View.VISIBLE;
 }
示例#11
0
  @Override // Fragment
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
      Log.d(
          engSpaActivity.getTag(),
          "EngSpaFragment.onCreateView(); question="
              + question
              + "; savedInstanceState is "
              + (savedInstanceState == null ? "" : "not ")
              + "null");
    }
    // Potentially restore state after configuration change; before we re-create
    // the views, get relevant information from current values. See knowledgeBase.txt
    CharSequence questionText = null;
    CharSequence attributeText = null;
    CharSequence pendingAnswer = null;
    CharSequence statusText = null;
    int selfMarkLayoutVisibility = View.GONE;
    if (questionTextView != null) {
      questionText = questionTextView.getText();
      attributeText = attributeTextView.getText();
      pendingAnswer = answerEditText.getText();
      statusText = statusTextView.getText();
      selfMarkLayoutVisibility = selfMarkLayout.getVisibility();
    }
    // Now get new layout
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    this.userNameTextView = (TextView) rootView.findViewById(R.id.userNameTextView);
    this.userNameTextView.setText(this.engSpaUser.getUserName());
    this.currentCtTextView = (TextView) rootView.findViewById(R.id.currentCtTextView);
    this.failCtTextView = (TextView) rootView.findViewById(R.id.failCtTextView);
    failCtTextView.setOnLongClickListener(this);
    rootView.findViewById(R.id.failCtLabel).setOnLongClickListener(this);

    this.selfMarkLayout = (ViewGroup) rootView.findViewById(R.id.selfMarkLayout);
    this.buttonLayout = (ViewGroup) rootView.findViewById(R.id.buttonLayout);
    this.selfMarkLayout.setVisibility(View.GONE);
    Button button = (Button) rootView.findViewById(R.id.goButton);
    button.setOnClickListener(this);
    button.setOnLongClickListener(this);
    this.micButton = (ImageButton) rootView.findViewById(R.id.micButton);
    this.micButton.setOnClickListener(this);
    this.micButton.setOnLongClickListener(this);
    button = (Button) rootView.findViewById(R.id.incorrectButton);
    button.setOnClickListener(this);
    button.setOnLongClickListener(this);
    button = (Button) rootView.findViewById(R.id.correctButton);
    button.setOnClickListener(this);
    button.setOnLongClickListener(this);
    this.questionTextView = (TextView) rootView.findViewById(R.id.questionTextView);
    this.attributeTextView = (TextView) rootView.findViewById(R.id.attributeTextView);
    this.answerEditText = (EditText) rootView.findViewById(R.id.answerEditText);
    this.statusTextView = (TextView) rootView.findViewById(R.id.statusTextView);
    if (questionTextView != null) {
      this.questionTextView.setText(questionText);
      this.answerEditText.setText(pendingAnswer);
      this.attributeTextView.setText(attributeText);
      this.statusTextView.setText(statusText);
      if (selfMarkLayoutVisibility == View.VISIBLE) showSelfMarkLayout();
    }
    this.answerEditText.setOnEditorActionListener(this);
    if (this.spanish == null) {
      askQuestion(true);
      showUserLevel();
    } else {
      showStats();
    }
    saveOrientation();
    return rootView;
  }