Class DynamicRemoteViewsFactory

java.lang.Object
com.pranavpandey.android.dynamic.support.factory.DynamicRemoteViewsFactory
All Implemented Interfaces:
RemoteViewsService.RemoteViewsFactory

public abstract class DynamicRemoteViewsFactory extends Object implements RemoteViewsService.RemoteViewsFactory
A customisable RemoteViewsService.RemoteViewsFactory to provide basic functionality.

Extend it and implement necessary methods according to the requirements.

  • Field Details

    • mContext

      protected final Context mContext
      Dynamic context used by this factory.
  • Constructor Details

    • DynamicRemoteViewsFactory

      public DynamicRemoteViewsFactory(@NonNull Context context, int appWidgetId, int appWidgetType, int width, int height)
      Constructor to initialize an object of this class.
      Parameters:
      context - The dynamic context for this factory.
      appWidgetId - The app widget id for this factory.
      appWidgetType - The app widget type for this factory.
      width - The current width of the widget provider.
      height - The current height of the widget provider.
    • DynamicRemoteViewsFactory

      public DynamicRemoteViewsFactory(@NonNull Context context, int appWidgetId, int appWidgetType, int width, int height, boolean adjustPosition)
      Constructor to initialize an object of this class.
      Parameters:
      context - The dynamic context for this factory.
      appWidgetId - The app widget id for this factory.
      appWidgetType - The app widget type for this factory.
      width - The current width of the widget provider.
      height - The current height of the widget provider.
      adjustPosition - true to adjust the scrollable view position.
  • Method Details

    • onInitialize

      public abstract void onInitialize()
      This method will be called on initializing the factory.
    • getContext

      @NonNull public Context getContext()
      Get the dynamic context used by this factory.
      Returns:
      The dynamic context used by this factory.
    • getAppWidgetId

      public int getAppWidgetId()
      Get the app widget id used by this factory.
      Returns:
      The app widget id used by this factory.
    • getAppWidgetType

      public int getAppWidgetType()
      Get the app widget type used by this factory.
      Returns:
      The app widget type used by this factory.
    • getWidth

      public int getWidth()
      Returns the current width of the widget provider used for this factory.
      Returns:
      The current width of the widget provider used for this factory.
    • setWidth

      public void setWidth(int width)
      Sets the current width of the widget provider used for this factory.
      Parameters:
      width - The width to be set.
    • getHeight

      public int getHeight()
      Returns the current height of the widget provider used for this factory.
      Returns:
      The current height of the widget provider used for this factory.
    • setHeight

      public void setHeight(int height)
      Sets the current height of the widget provider used for this factory.
      Parameters:
      height - The height to be set.
    • isAdjustPosition

      public boolean isAdjustPosition()
      Checks whether to adjust position of the scrollable view.
      Returns:
      true to adjust position of the scrollable view.
    • setAdjustPosition

      public void setAdjustPosition(boolean adjustPosition)
      Sets the adjust position of the scrollable view for this factory.
      Parameters:
      adjustPosition - true to adjust position of the scrollable view.
    • onDataSetChanged

      @CallSuper public void onDataSetChanged()
      Specified by:
      onDataSetChanged in interface RemoteViewsService.RemoteViewsFactory