java.lang.Object
com.pranavpandey.android.dynamic.support.popup.base.DynamicPopup
All Implemented Interfaces:
DynamicProductFlavor
Direct Known Subclasses:
DynamicSimplePopup

public abstract class DynamicPopup extends Object implements DynamicProductFlavor
Base PopupWindow to provide the basic functionality to its descendants.

Extend this class to create popup windows according to the requirements.

  • Field Details

    • mAnchor

      protected View mAnchor
      Anchor view used by this popup.
    • mViewType

      protected int mViewType
      View type used by this popup.
    • mPopupWindowColor

      protected Integer mPopupWindowColor
      Color for the popup window background.
  • Constructor Details

    • DynamicPopup

      public DynamicPopup()
  • Method Details

    • getAnchor

      @NonNull public View getAnchor()
      Get the anchor view to display the popup.
      Returns:
      The anchor view to display the popup.
    • setAnchor

      public void setAnchor(@NonNull View anchor)
      Set the anchor view to display the popup.
      Parameters:
      anchor - The anchor view to be set.
    • getHeaderView

      @Nullable protected View getHeaderView()
      Returns the header view for the popup.

      Default is null to hide the header.

      Returns:
      The header view for the popup.
    • getView

      @Nullable protected abstract View getView()
      This method will be called to return the content view for the popup.
      Returns:
      The content view for the popup.
    • getFooterView

      @Nullable protected View getFooterView()
      Returns the footer view for the popup.

      Default is null to hide the footer.

      Returns:
      The footer view for the popup.
    • getPopupWindow

      public PopupWindow getPopupWindow()
      Returns the popup window displayed by this class.
      Returns:
      The popup window displayed by this class.
    • getViewRoot

      @Nullable public View getViewRoot()
      Returns the root view for the popup.
      Returns:
      The view root to add scroll indicators if the content can be scrolled.
    • setViewRoot

      public void setViewRoot(@Nullable View viewRoot)
      Set the view root for this the popup.
      Parameters:
      viewRoot - The view root to be set.
    • getViewType

      public int getViewType()
      Returns the view type for the popup.
      Returns:
      The view type used by the popup.
    • setViewType

      public void setViewType(int viewType)
      Set the view type used by the popup.
      Parameters:
      viewType - The view type to be set.
    • getPopupWindowColor

      @Nullable public Integer getPopupWindowColor()
      Returns the popup window color.
      Returns:
      The popup window color used by the popup.
    • setPopupWindowColor

      public void setPopupWindowColor(@ColorInt int popupWindowColor)
      Set the popup window color.
      Parameters:
      popupWindowColor - The popup window color to be set.
    • build

      @NonNull protected abstract DynamicPopup build()
      Build this popup and make it ready to show.

      Please call show() method to show the popup.

      Returns:
      The popup after building it according to the supplied parameters.
    • getWindowAnimationStyle

      @StyleRes protected int getWindowAnimationStyle()
      Returns the window animation style for the popup.
      Returns:
      The window animation style for the popup.
    • getMaxWidth

      protected int getMaxWidth()
      Returns the maximum width for the popup.
      Returns:
      The maximum width for the popup.
    • getSizeOffset

      protected int getSizeOffset()
      The offset to adjust the size of the window if enough space is not available.
      Returns:
      The offset to adjust the size of the window if enough space is not available.
    • getLocationOffsetX

      protected int getLocationOffsetX()
      The offset to adjust the location of the window on the x-axis.
      Returns:
      The offset to adjust the location of the window on the x-axis.
    • getLocationOffsetY

      protected int getLocationOffsetY()
      The offset to adjust the location of the window on the y-axis.
      Returns:
      The offset to adjust the location of the window on the y-axis.
    • onCustomisePopup

      protected void onCustomisePopup(@NonNull PopupWindow popupWindow, @NonNull View content, @ColorInt int backgroundColor)
      This method will be called just before showing this popup.
      Parameters:
      popupWindow - The popup window to be displayed by this popup.
      content - The content to be displayed by this popup.
      backgroundColor - The background color of this popup.
    • show

      public void show()
      Build and show PopupWindow according to the supplied parameters.
    • dismiss

      public void dismiss()
      Try to dismiss the popup window.
      See Also:
    • getProductFlavor

      public String getProductFlavor()
      Specified by:
      getProductFlavor in interface DynamicProductFlavor