+ /// update state of expiration date switch and message depending on expiration date
+ /// update state of expiration date switch and message depending on expiration date
+ Switch expirationDateSwitch = getExpirationDateSwitch();
+ // set null listener before setChecked() to prevent infinite loop of calls
+ expirationDateSwitch.setOnCheckedChangeListener(null);
+ long expirationDate = mPublicShare.getExpirationDate();
+ if (expirationDate > 0) {
+ if (!expirationDateSwitch.isChecked()) {
+ expirationDateSwitch.toggle();
+ }
+ String formattedDate =
+ SimpleDateFormat.getDateInstance().format(
+ new Date(expirationDate)
+ );
+ getExpirationDateValue().setText(formattedDate);
+ } else {
+ if (expirationDateSwitch.isChecked()) {
+ expirationDateSwitch.toggle();
+ }
+ getExpirationDateValue().setText(R.string.empty);
+ }
+ // recover listener
+ expirationDateSwitch.setOnCheckedChangeListener(
+ mOnExpirationDateSwitchCheckedChangeListener
+ );
+