Example #1
0
 @Override
 public void handleMessage(Message msg) {
   // 关
   if (msg.what == 0) {
     state = 2;
     int left = btnRight.getLeft();
     int right = btnRight.getRight();
     // 0,45
     if (left - movePDis <= 0) {
       isChecked = false;
       isAimationMoving = false;
       state = 0;
     } else {
       currentBtn.layout(left - movePDis, 0, right - movePDis, btnHeight);
     }
   }
   // 开
   else if (msg.what == 1) {
     state = 3;
     int left = btnLeft.getLeft();
     int right = btnLeft.getRight();
     // 35,80
     if (left + movePDis >= moveWidth) {
       isChecked = true;
       isAimationMoving = false;
       state = 1;
     } else {
       currentBtn.layout(left + movePDis, 0, right + movePDis, btnHeight);
     }
     // 关
   } else if (msg.what == 3) {
     currentBtn = btnLeft;
     btnRight.setVisibility(View.GONE);
     btnLeft.setVisibility(View.VISIBLE);
     isChecked = false;
     isAimationMoving = false;
     state = 0;
   }
   // 开
   else if (msg.what == 4) {
     currentBtn = btnRight;
     btnLeft.setVisibility(View.GONE);
     btnRight.setVisibility(View.VISIBLE);
     isChecked = true;
     isAimationMoving = false;
     state = 1;
   }
 }