@Override
    public void onClick(DialogInterface dialog, int which) {
      final String oldUri = mImageUriProvider.getUriOverride();
      final String newUri = mEditText.getText().toString();
      switch (which) {
        case DialogInterface.BUTTON_POSITIVE:
          try {
            if (oldUri != null) {
              mSharedPreferences.edit().putString(KEY_URI_OVERRIDE_HISTORY, oldUri).apply();
            }
            mImageUriProvider.setUriOverride(newUri);
          } catch (IllegalArgumentException e) {
            Toast.makeText(
                    getContext(),
                    getString(
                        R.string.preference_uri_override_dialog_edittext_error_bad_uri,
                        e.getMessage()),
                    Toast.LENGTH_SHORT)
                .show();
          }
          break;
        case DialogInterface.BUTTON_NEGATIVE:
          if (oldUri != null) {
            mSharedPreferences.edit().putString(KEY_URI_OVERRIDE_HISTORY, oldUri).apply();
          }
          mImageUriProvider.setUriOverride(null);

          break;
      }
    }
Dialog asking for a new URI override
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/settings/SettingsFragment.java