@SuppressWarnings({"PMD.NPathComplexity", "PMD.ExcessiveMethodLength"})
    private void refreshType(final CalculatedCoordinateType newType, final boolean initialLoad) {
        if (!initialLoad && calcCoord.getType() == newType) {
            return;
        }

        calcCoord.setType(newType);

        Geopoint currentGp = null;
        if (calcCoord != null) {
            currentGp = calcCoord.calculateGeopoint(varList::getValue);
        }
        if (currentGp == null) {
            currentGp = geopoint;
        }
        binding.PlainFormat.setVisibility(newType == PLAIN ? View.VISIBLE : View.GONE);
        binding.NonPlainFormat.setVisibility(newType != PLAIN ? View.VISIBLE : View.GONE);
        if (newType == PLAIN) {
            binding.NonPlainFormat.unmarkButtons();
        }
        binding.ccGuidedFormat.setVisibility(newType == PLAIN ? View.GONE : View.VISIBLE);
        binding.ccSwitchGuided.setChecked(newType != PLAIN);
        if (newType != PLAIN) {
            displayType.set(newType);
        }
        binding.ccPlainTools.setVisibility(newType != PLAIN ? View.GONE : View.VISIBLE);

        binding.ccPaste.setVisibility(newType != PLAIN ? View.GONE : View.VISIBLE);
        binding.ccPaste.setEnabled(!FormulaUtils.scanForCoordinates(Collections.singleton(ClipboardUtils.getText()), null).isEmpty());

        if (newType == PLAIN) {
            if (initialLoad) {
                binding.PlainLat.setText(calcCoord.getLatitudePattern() == null ? "" : calcCoord.getLatitudePattern());
                binding.PlainLon.setText(calcCoord.getLongitudePattern() == null ? "" : calcCoord.getLongitudePattern());
            } else {
                final Pair<String, String> coords = binding.NonPlainFormat.getPlain();
                binding.PlainLat.setText(coords.first);
                binding.PlainLon.setText(coords.second);
            }
        } else {
            binding.NonPlainFormat.setData(newType, calcCoord.getLatitudePattern(), calcCoord.getLongitudePattern(), currentGp);
        }
    }
Save the current state of the calculator such that it can be restored after screen rotation (or similar)
main/src/main/java/cgeo/geocaching/ui/dialog/CoordinatesCalculateGlobalDialog.java