Android動畫效果Widget – Android移動開發技術文章_手機開發 Android移動開發教學課程

請參照前面的飛行模式widget和wifi widget,不同代碼:

 

private void handStateChanged(int state){

  Message msg = mHandler.obtainMessage(BluetoothDefinition.START_ANIMATION);

  msg.arg1 = 0;

  switch (state) {

  case BluetoothAdapter.STATE_TURNING_ON:

      if (sIsOnClick) {

          BluetoothDefinition.mRunAnimation = true;

             mHandler.sendMessage(msg);

             sIsOnClick = false;

      }

   break;

  case BluetoothAdapter.STATE_ON:

   BluetoothDefinition.mRunAnimation = false;

   mHandler.sendEmptyMessage(BluetoothDefinition.END_ANIMATION);

   break;

  case BluetoothAdapter.STATE_TURNING_OFF:

      if (sIsOnClick) {

             mHandler.sendMessage(msg);

             sIsOnClick = false;

      }

   break;

  case BluetoothAdapter.STATE_OFF:

   mHandler.sendEmptyMessage(BluetoothDefinition.END_ANIMATION);

   break;

  default:

  }

 }

You May Also Like