Class DynamicImagePreference

All Implemented Interfaces:
SharedPreferences.OnSharedPreferenceChangeListener, Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, BaseWidget, DynamicTintWidget, DynamicWidget

public class DynamicImagePreference extends DynamicSpinnerPreference
A DynamicSpinnerPreference with a secondary image view to represent data according to the need.
  • Constructor Details

  • Method Details

    • onLoadAttributes

      protected void onLoadAttributes(@Nullable AttributeSet attrs)
      Description copied from class: DynamicView
      Load values from the supplied attribute set.
      Overrides:
      onLoadAttributes in class DynamicSpinnerPreference
      Parameters:
      attrs - The attribute set to load the values.
    • onInflate

      protected void onInflate()
      Description copied from class: DynamicView
      This method will be called after loading the attributed.

      Initialize the view layout here.

      Overrides:
      onInflate in class DynamicSpinnerPreference
    • getPreferenceKey

      @Nullable public String getPreferenceKey()
      Description copied from class: DynamicPreference
      Get the shared preferences key used by this preference.
      Overrides:
      getPreferenceKey in class DynamicPreference
      Returns:
      The shared preferences key used by this preference.
    • getAltPreferenceKey

      @Nullable public String getAltPreferenceKey()
      Description copied from class: DynamicPreference
      Get the shared preferences key for alternate preference.
      Overrides:
      getAltPreferenceKey in class DynamicPreference
      Returns:
      The shared preferences key for alternate preference.
    • onUpdate

      protected void onUpdate()
      Description copied from class: DynamicView
      This method will be called whenever there is a change in the view attributes or parameters.

      It is better to do any real time calculation like updating the value string or checked state in this method.

      Overrides:
      onUpdate in class DynamicSpinnerPreference
    • onEnabled

      protected void onEnabled(boolean enabled)
      Description copied from class: DynamicView
      This method will be called whenever there is a change in the view state.

      Either enabled or disabled, other views like icon, title, color, etc. must be updated here to reflect the overall view state.

      Overrides:
      onEnabled in class DynamicSimplePreference
      Parameters:
      enabled - true if this view is enabled and can receive click events.
    • setColor

      public void setColor()
      Description copied from interface: DynamicWidget
      Set color for this widget according to the supplied values.
      Specified by:
      setColor in interface DynamicWidget
      Overrides:
      setColor in class DynamicSimplePreference
    • getImageView

      @Nullable public ImageView getImageView()
      Get the secondary image view to show the drawable.
      Returns:
      The secondary image view to show the drawable.
    • getImageDrawable

      @Nullable public Drawable getImageDrawable()
      Get the drawable for the image view.
      Returns:
      The drawable for the image view.
    • setImageDrawable

      public void setImageDrawable(@Nullable Drawable imageDrawable, boolean update)
      Set the drawable for the image view.
      Parameters:
      imageDrawable - The image drawable to be set.
      update - true to call DynamicView.update() method after setting the image drawable.
    • setImageDrawable

      public void setImageDrawable(@Nullable Drawable imageDrawable)
      Set the drawable for the image view.
      Parameters:
      imageDrawable - The image drawable to be set.
    • setImageResource

      public void setImageResource(@DrawableRes int drawableRes, boolean update)
      Set the drawable for the image view.
      Parameters:
      drawableRes - The drawable resource to be set.
      update - true to call DynamicView.update() method after setting the image resource.
    • setImageResource

      public void setImageResource(@DrawableRes int drawableRes)
      Set the drawable for the image view.
      Parameters:
      drawableRes - The drawable resource to be set.
    • setImageBitmap

      public void setImageBitmap(@Nullable Bitmap imageBitmap, boolean update)
      Set the bitmap for the image view.
      Parameters:
      imageBitmap - The image bitmap to be set.
      update - true to call DynamicView.update() method after setting the image bitmap.
    • setImageBitmap

      public void setImageBitmap(@Nullable Bitmap imageBitmap)
      Set the bitmap for the image view.
      Parameters:
      imageBitmap - The image bitmap to be set.
    • onSharedPreferenceChanged

      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Nullable String key)
      Specified by:
      onSharedPreferenceChanged in interface SharedPreferences.OnSharedPreferenceChangeListener
      Overrides:
      onSharedPreferenceChanged in class DynamicSpinnerPreference