Class PopupManager


  • public final class PopupManager
    extends java.lang.Object
    Manages the viewing and editing of a Popup.
    Since:
    100.0.0
    • Constructor Detail

      • PopupManager

        public PopupManager​(android.content.Context context,
                            Popup popup)
        Constructs a PopupManager to manage the specified Popup. The GeoElement associated with the Popup must be loaded for the PopupManager to work properly.
        Parameters:
        popup - the Popup to manage
        Throws:
        java.lang.IllegalArgumentException - if popup or context is null
        Since:
        100.0.0
    • Method Detail

      • getPopup

        public Popup getPopup()
        Gets the Popup being managed.
        Returns:
        the Popup being managed
        Since:
        100.0.0
      • getDisplayedFields

        public java.util.List<PopupField> getDisplayedFields()
        Gets the list of PopupFields that are visible.
        Returns:
        an unmodifiable list of PopupFields that are visible
        Since:
        100.0.0
      • getEditableFields

        public java.util.List<PopupField> getEditableFields()
        Gets the list of PopupFields that are editable.
        Returns:
        an unmodifiable list of PopupFields that are editable
        Since:
        100.0.0
      • getFeatureTypes

        public java.util.List<FeatureType> getFeatureTypes()
        Gets the list of feature types or null if the GeoElement is not an ArcGISFeature in an ArcGISFeatureTable.
        Returns:
        an unmodifiable list of feature types
        Since:
        100.0.0
      • getFieldType

        public Field.Type getFieldType​(PopupField popupField)
        Gets the Field.Type corresponding to the PopupField.
        Parameters:
        popupField - the PopupField for which to get the Field.Type
        Returns:
        the Field.Type corresponding to the PopupField
        Since:
        100.0.0
      • isEditing

        public boolean isEditing()
        Checks whether the PopupManager is currently in editing mode.
        Returns:
        true if the Popup is currently being edited; otherwise false
        Since:
        100.0.0
      • startEditing

        public boolean startEditing()
        Initiates an editing session with the Popup.
        Returns:
        true if an editing session is started; false if the Popup is already in editing or editing is not allowed
        Since:
        100.0.0
      • finishEditingAsync

        public ListenableFuture<ArcGISRuntimeException> finishEditingAsync()
        Finishes the editing session.
        Returns:
        a ListenableFuture that can be used to track the status of the operation; the result is an ArcGISRuntimeException, or null if the editing session succeeded
        Since:
        100.0.0
      • cancelEditing

        public void cancelEditing()
        Cancels the editing session. This rolls the GeoElement back to its original state.
        Since:
        100.0.0
      • isGeoElementValid

        public boolean isGeoElementValid()
        Checks whether the GeoElement is valid or not.

        A GeoElement with a geometry is considered valid if both its geometry and attributes are valid; a GeoElement with null geometry is valid only if it is from a non-spatial enabled table and its attributes are valid.

        Returns:
        true if the GeoElement is valid; otherwise false
        Since:
        100.0.0
      • doesChangeRequireNotification

        public boolean doesChangeRequireNotification​(FeatureTemplate featureTemplate)
        Checks whether changing to the specified FeatureTemplate requires warning the user that some data may be overwritten by the change.
        Parameters:
        featureTemplate - the new FeatureTemplate
        Returns:
        true if the user needs to be warned of data loss; otherwise false
        Since:
        100.0.0
      • updateValue

        public ArcGISRuntimeException updateValue​(FeatureTemplate featureTemplate,
                                                  PopupManager.FeatureTypeChangeMode changeMode)
        Updates the GeoElement's FeatureTemplate value, which in turn updates the values of its attribute table to match those in the feature template, dependent on the change mode. If changeMode is RESET_TO_DEFAULTS, then all current values will be reset to the defaults specified in the FeatureTemplate. If KEEP_VALUES, current values will be kept unless they are not valid for the new feature type (for example, if a CodedValueDomain changes and the current value is not in the new domain).
        Parameters:
        featureTemplate - the FeatureTemplate to use in updating the attribute table
        changeMode - the FeatureTypeChangeMode to apply
        Returns:
        null if successful or an ArcGISRuntimeException if the type ID field is invalid
        Since:
        100.0.0
      • getAttachmentManager

        public PopupAttachmentManager getAttachmentManager()
        Returns the PopupAttachmentManager for this PopupManager, or null if there isn't one.
        Returns:
        the PopupAttachmentManager
        Since:
        100.0.0
      • updateValue

        public ArcGISRuntimeException updateValue​(java.lang.Object newValue,
                                                  PopupField popupField)
        Updates the value of the specified PopupField to the specified value.
        Parameters:
        newValue - the value with which to update the PopupField
        popupField - the PopupField to update
        Returns:
        null if successful or an ArcGISRuntimeException if the value isn't valid
        Since:
        100.0.0
      • getValidationError

        public ArcGISRuntimeException getValidationError​(PopupField popupField)
        Checks if the PopupField's current attribute value is valid. If it is invalid, an ArcGISRuntimeException will be returned.
        Parameters:
        popupField - the PopupField to check
        Returns:
        null if successful or an ArcGISRuntimeException if the value isn't valid
        Since:
        100.0.0
      • getRangeDomainValidationText

        public java.lang.String getRangeDomainValidationText​(PopupField popupField)
        Gets a String that can be used to hint the acceptable values for a RangeDomain field.
        Parameters:
        popupField - the PopupField for which to get a range domain hint
        Returns:
        a String hinting at the acceptable values
        Since:
        100.0.0
      • getField

        public Field getField​(PopupField popupField)
        Gets the Field corresponding to the PopupField, or null if the GeoElement is not an ArcGISFeature.
        Parameters:
        popupField - the PopupField for which to get the corresponding Field
        Returns:
        the Field corresponding to the PopupField
        Since:
        100.0.0
      • isShowCustomHtmlDescription

        public boolean isShowCustomHtmlDescription()
        Checks whether the custom HTML description should be shown.
        Returns:
        true if it should be shown
        Since:
        100.0.0
      • isShowRelatedRecords

        @Deprecated
        public boolean isShowRelatedRecords​(ArcGISMap map)
        Deprecated.
        Checks if related records should be shown.
        Parameters:
        map - the map
        Returns:
        true if related records should be shown
        Since:
        100.0.0
      • getTitle

        public java.lang.String getTitle()
        Gets the Popup's title text.
        Returns:
        the Popup's title text
        Since:
        100.0.0
      • getCustomHtmlDescription

        public java.lang.String getCustomHtmlDescription()
        Gets the Popup's custom HTML description. Returns null if a description is not defined on the popup.

        If PopupDefinition.getExpressions() is not empty, the custom HTML description may be using expressions with Arcade FeatureSet functions. Use Popup.evaluateExpressionsAsync() to evaluate the Arcade expressions before trying to call PopupManager.getCustomHtmlDescription(); otherwise it may not return the correct description.

        Returns:
        the Popup's custom description HTML
        Since:
        100.0.0
      • getEditSummary

        public java.lang.String getEditSummary()
        Gets the current edit summary. This details the user and/or time of the last edit, or of the creation if the ArcGISFeature has not been edited. Returns null if the GeoElement is not an ArcGISFeature or if there is no editor tracking information.
        Returns:
        the edit summary
        Since:
        100.0.0
      • getEditInfo

        public EditFieldsInfo getEditInfo()
        If the Popup's GeoElement is an ArcGISFeature, this returns the EditFieldsInfo contained in the ArcGISFeatureTable's ArcGISFeatureLayerInfo. Otherwise, null is returned.
        Returns:
        the EditFieldsInfo
        Since:
        100.0.0
      • getMaxLength

        public int getMaxLength​(PopupField popupField)
        Gets the maximum allowed length of the specified PopupField.
        Parameters:
        popupField - the PopupField to check
        Returns:
        the maximum length of the PopupField, or -1 if the GeoElement is not an ArcGISFeature
        Since:
        100.0.0
      • isNullable

        public boolean isNullable​(PopupField popupField)
        Checks if the specified PopupField is nullable.
        Parameters:
        popupField - the PopupField to check
        Returns:
        true if the PopupField is nullable; otherwise false
        Since:
        100.0.0
      • getRelatedRecords

        @Deprecated
        public java.lang.String getRelatedRecords()
        Deprecated.
        Gets the records that are related to the popup being managed, such as other features of the same type or within a certain vicinity.
        Returns:
        the related records
        Since:
        100.0.0
      • isAllowEdit

        public boolean isAllowEdit()
        Checks whether editing the GeoElement's attributes is allowed.
        Returns:
        true if the GeoElement's attributes can be edited; otherwise false
        Since:
        100.0.0
      • isAllowDelete

        public boolean isAllowDelete()
        Checks whether deleting the GeoElement is allowed.
        Returns:
        true if the GeoElement can be deleted; otherwise false
        Since:
        100.0.0
      • isAllowEditGeometry

        public boolean isAllowEditGeometry()
        Checks whether editing the GeoElement's geometry is allowed.
        Returns:
        true if editing the GeoElement's geometry is allowed; otherwise false
        Since:
        100.0.0
      • isShowAttachments

        public boolean isShowAttachments()
        Checks whether attachments should be shown.
        Returns:
        true if attachments should be shown; otherwise false
        Since:
        100.0.0
      • isShowMedia

        public boolean isShowMedia()
        Checks whether the PopupMedias should be shown.
        Returns:
        true if the PopupMedias should be shown; otherwise false
        Since:
        100.0.0
      • isShowEditSummary

        public boolean isShowEditSummary()
        Checks whether the EditInfo summary should be shown.
        Returns:
        true if the EditInfo summary should be shown; otherwise false
        Since:
        100.0.0
      • getFormattedValue

        public java.lang.String getFormattedValue​(PopupField popupField)
        Returns a formatted String representation of the current popup field's value.

        If PopupDefinition.getExpressions() is not empty, the PopupField may be using expressions with Arcade FeatureSet functions. Use Popup.evaluateExpressionsAsync() to evaluate the Arcade expressions before trying to get the formatted String representation of the popup field's value, otherwise it may return an empty string.

        If the field is part of a CodedValueDomain, the CodedValue.getName() is returned.

        Parameters:
        popupField - the PopupField for which to get a formatted String
        Returns:
        the formatted String
        Since:
        100.0.0
      • getFieldLabel

        public java.lang.String getFieldLabel​(PopupField popupField)
        Gets the field label string for the given PopupField. If popupField is an Arcade expression field, it will return the title of the PopupExpression associated with the popup field.
        Parameters:
        popupField - the PopupField object
        Returns:
        a label string for the popup field
        Since:
        100.3.0
      • substitute

        public java.lang.String substitute​(java.lang.String templateString)
        Substitutes attribute values for attribute place-holders in a given template string. If PopupDefinition.getExpressions() is not empty, the input string may be using expressions with Arcade FeatureSet functions. Use Popup.evaluateExpressionsAsync() to evaluate the Arcade expressions before trying to get the substitute String; otherwise it may return an empty string.

        An example string would be: "This tree's leaves are {leafColor} in the {season}", where leafColor and season are both attribute-keys / field-names.

        Parameters:
        templateString - the template string containing place-holders
        Returns:
        a String with attribute values substituted for the place-holders
        Since:
        100.0.0
      • setGeoElementValidityChangedListener

        public void setGeoElementValidityChangedListener​(GeoElementValidityChangedListener geoElementValidityChangedListener)
        Sets a GeoElementValidityChangedListener to be invoked when the validity of the Popup's GeoElement changes. For example, this could be used to change the UI when a Popup is determined to be invalid, such as disabling a submit button or showing a warning.
        Parameters:
        geoElementValidityChangedListener - the listener to set
        Since:
        100.0.0
      • setFeatureTypeChangedListener

        public void setFeatureTypeChangedListener​(FeatureTypeChangedListener featureTypeChangedListener)
        Sets a FeatureTypeChangedListener to be invoked when the FeatureType of the Popup's GeoElement changes. For example, this could be used to change the symbol of the GeoElement if each feature type has its own unique symbol.
        Parameters:
        featureTypeChangedListener - the listener to set
        Since:
        100.0.0
      • getField

        public Field getField​(java.lang.String fieldName)
        Gets the Field object corresponding to the specified field name, or null if either there is no such field or the GeoElement is not an ArcGISFeature with fields.
        Parameters:
        fieldName - the name of the field for which to get the Field object
        Returns:
        the Field object for the specified field name
        Since:
        100.0.0
      • isFeatureType

        public boolean isFeatureType​(PopupField popupField)
        Checks if the specified PopupField is the feature type field.
        Parameters:
        popupField - the PopupField to check
        Returns:
        true if the PopupField is the type ID field; otherwise false
        Since:
        100.0.0
      • getDomain

        public Domain getDomain​(PopupField popupField)
        Gets the Domain for the specified PopupField or null if there isn't one.
        Parameters:
        popupField - the PopupField for which to get the Domain
        Returns:
        the Domain for the specified PopupField
        Since:
        100.0.0
      • getSymbol

        public Symbol getSymbol()
        Gets the symbol of the Popup.
        Returns:
        the symbol of the Popup
        Since:
        100.0.0
      • getEvaluatedElements

        public java.util.List<PopupElement> getEvaluatedElements()
        Gets an unmodifiable list of PopupElement evaluated asynchronously by Popup.evaluateExpressionsAsync(). During the evaluation, the ExpressionPopupElement are replaced by the PopupElement returned by the arcade expression. If the Arcade expression returns a list of attributes to use by the popup element, these attributes will be used by getFormattedValue(PopupField) or getFieldValue(PopupField).

        The array is empty while Popup.evaluateExpressionsAsync() has not been executed and is cleared if Popup.evaluateExpressionsAsync() is executed more than once. After evaluation, the order of the PopupElement in the List is the order that elements are in the PopupDefinition.getElements() and are shown in the pop-up window. If an ExpressionPopupElement is failed to be evaluated, it will be skipped in the List. The error can be found in the array of PopupExpressionEvaluation returned from Popup.evaluateExpressionsAsync().

        Returns:
        an unmodifiable list of PopupElement evaluated asynchronously by Popup.evaluateExpressionsAsync(). During the evaluation, the ExpressionPopupElement are replaced by the PopupElement returned by the arcade expression. If the Arcade expression returns a list of attributes to use by the popup element, these attributes will be used by PopupManager.getFormattedValue(PopupField) or PopupManager.getFieldValue(PopupField).
        Since:
        100.14.0
        See Also:
        PopupDefinition.getElements()
      • getFieldValue

        public java.lang.Object getFieldValue​(java.lang.String fieldName,
                                              PopupElement popupElement)
        Returns the attribute value for the pop-up field specified by a name.

        If any field is using expressions, use Popup.evaluateExpressionsAsync() to evaluate the Arcade expressions before trying to get the fields' values. Otherwise, the values may not be evaluated properly.

        If the field is part of a CodedValueDomain, the CodedValue.getCode() is returned (unlike getFormattedValue(PopupField), which returns the CodedValue.getName()).

        Parameters:
        fieldName - the name of the field
        popupElement - the popup element to look up for the field. This argument is useful only if the popup element is coming from an Arcade expression evaluation that can return a list of attributes (see getEvaluatedElements()).
        Throws:
        java.lang.IllegalArgumentException - if fieldName is null
        java.lang.IllegalArgumentException - if popupElement is null
        Since:
        100.14.0
      • getContingentValuesForField

        public ContingentValuesResult getContingentValuesForField​(PopupField popupField)
        Gets the contingent values for the given popup field. The result will contain values for each FieldGroup the Field belongs to and all groups if there is more than one field group (the intersection of the values for each field group).
        Parameters:
        popupField - the PopupField to get the contingent values for
        Returns:
        a ContingentValuesResult object, or null if no contingent values are defined, or popup field not well defined.
        Since:
        100.14.0
      • getContingencyValidationErrors

        public java.util.Map<java.lang.String,​ArcGISRuntimeException> getContingencyValidationErrors()
        Get the pairs of field group name and an associated contingent values validation errors. Errors are reported in validation when editing is defined as restrictive in the FieldGroup.
        Returns:
        an unmodifiable Map for the pairs of field group name and an associated contingent values validation error
        Since:
        100.14.0
      • getContingencyValidationWarnings

        public java.util.Map<java.lang.String,​ArcGISRuntimeException> getContingencyValidationWarnings()
        Get the pairs of field group name and an associated contingent values validation warnings. Warnings are reported in validation when editing is defined as non-restrictive in the FieldGroup.
        Returns:
        an unmodifiable Map for the pairs of field group name and an associated contingent values validation warning
        Since:
        100.14.0
      • isFieldInFieldGroup

        public boolean isFieldInFieldGroup​(PopupField popupField)
        Gets whether the given PopupField is part of a FieldGroup as defined in a ContingentValuesDefinition.
        Parameters:
        popupField - a PopupField
        Returns:
        true if the popupField is a part of the FieldGroup defined in a ContingentValuesDefinition
        Since:
        100.14.0