public void setBatteryValue(final int percent) {
    if (percent > 100 || percent < 0) {
      Log.w(TAG, "Can't set battery value. Invalid value " + percent);
      return;
    }

    int imgNum = Math.round((float) percent / 100.0f * 3.0f);

    txtBatteryStatus.setText(percent + "%");

    if (imgNum < 0) imgNum = 0;

    if (imgNum > 3) imgNum = 3;

    if (batteryIndicator != null) {
      batteryIndicator.setValue(imgNum);
    }
  }
 @Override
 public void didFailToConnect() {
   String state =
       context.getResources().getString(R.string.settings_item_connection_state_not_conneceted);
   stateTextView.setText(state);
 }