Class DynamicRecyclerViewFrame

java.lang.Object
android.view.View
android.view.ViewGroup
android.widget.FrameLayout
com.pranavpandey.android.dynamic.support.recyclerview.DynamicRecyclerViewFrame
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent
Direct Known Subclasses:
DynamicPermissionsView, DynamicRecyclerViewNested

public abstract class DynamicRecyclerViewFrame extends FrameLayout
A RecyclerView inside a FrameLayout with some built-in functionality like swipe refresh layout, progress bar, etc. that can be initialized quickly.
  • Field Details

  • Constructor Details

  • Method Details

    • onLoadAttributes

      protected void onLoadAttributes(@Nullable AttributeSet attrs)
    • getLayoutRes

      @LayoutRes protected int getLayoutRes()
      This method will be called to get the layout resource for this view.

      Supply the view layout resource here to do the inflation.

      Returns:
      The layout used by this view. Override this to supply a different layout.
    • initialize

      protected void initialize()
      Initialize this view with default settings.
    • getRecyclerViewLayoutManager

      @Nullable public abstract RecyclerView.LayoutManager getRecyclerViewLayoutManager()
      This method will be called to return the layout manager for the recycler view.

      Override this method to supply the layout manager during.

      Returns:
      The layout manager for the recycler view.
    • setRecyclerViewLayoutManager

      public void setRecyclerViewLayoutManager(@Nullable RecyclerView.LayoutManager layoutManager, boolean notify)
      Set supplied LayoutManager to the RecyclerView.
      Parameters:
      layoutManager - Layout manager for the recycler view;
      notify - true to notify data set changed.
    • setRecyclerViewLayoutManager

      public void setRecyclerViewLayoutManager(@Nullable RecyclerView.LayoutManager layoutManager)
      Set supplied LayoutManager to the RecyclerView.
      Parameters:
      layoutManager - Layout manager for the recycler view;
      See Also:
    • setAdapter

      public void setAdapter(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter)
      Set an adapter for the recycler view.
      Parameters:
      adapter - The recycler view adapter.
    • checkForStaggeredGridLayoutManager

      protected void checkForStaggeredGridLayoutManager()
      Checks for the StaggeredGridLayoutManager to avoid the jumping of items.
    • getAdapter

      @Nullable public RecyclerView.Adapter<?> getAdapter()
      Returns the adapter used by the recycler view.
      Returns:
      The adapter used by the recycler view.
    • notifyDataSetChanged

      public void notifyDataSetChanged()
      Notify data set changed for the recycler view adapter.
    • notifyItemChanged

      public void notifyItemChanged(int position)
      Notify item changed for the recycler view adapter.
      Parameters:
      position - The changed position.
    • onCreateRecyclerView

      @CallSuper protected void onCreateRecyclerView(@NonNull RecyclerView recyclerView)
      Override this method to perform other operations on the recycler view.
      Parameters:
      recyclerView - The recycler view inside this view.
    • setOnRefreshListener

      @Nullable protected SwipeRefreshLayout.OnRefreshListener setOnRefreshListener()
      Override this method to set swipe refresh layout listener immediately after initializing the view.
      Returns:
      The on refresh listener for the swipe refresh layout.
      See Also:
    • getRecyclerView

      @NonNull public RecyclerView getRecyclerView()
      Get the recycler view used by this view.
      Returns:
      The recycler view to display the data.
    • getLayoutManager

      @Nullable public RecyclerView.LayoutManager getLayoutManager()
      Get the layout manager used by recycler view.
      Returns:
      The layout manager used by recycler view.
    • getSwipeRefreshLayout

      @Nullable public SwipeRefreshLayout getSwipeRefreshLayout()
      Get the swipe refresh layout used by this view.
      Returns:
      The swipe refresh layout used by this view.
    • setSwipeRefreshLayout

      public void setSwipeRefreshLayout(@Nullable SwipeRefreshLayout swipeRefreshLayout)
      Set the swipe refresh layout for this view.
      Parameters:
      swipeRefreshLayout - The swipe refresh layout to be set.
    • getOnRefreshListener

      @Nullable public SwipeRefreshLayout.OnRefreshListener getOnRefreshListener()
      Get the swipe refresh layout listener used by this view.
      Returns:
      The swipe refresh layout listener used by this view.
    • setOnRefreshListener

      public void setOnRefreshListener(@Nullable SwipeRefreshLayout.OnRefreshListener onRefreshListener)
      Set the swipe refresh layout listener to provide pull to efresh functionality.
      Parameters:
      onRefreshListener - The listener to be set.
    • getEmptyView

      @Nullable public DynamicEmptyView getEmptyView()
      Get the empty view that can be shown when the data is empty.
      Returns:
      The empty view that can be shown when the data is empty.
    • showEmptyView

      public void showEmptyView(boolean animate)
      Show empty view on top of the recycler view.
      Parameters:
      animate - true to animate the changes.
    • showEmptyView

      public void showEmptyView()
      Show empty view on top of the recycler view.
      See Also:
    • hideEmptyView

      public void hideEmptyView(boolean animate)
      Hide empty view from the top of the recycler view.
      Parameters:
      animate - true to animate the changes.
    • hideEmptyView

      public void hideEmptyView()
      Hide empty view from the top of the recycler view.
      See Also:
    • getProgressBar

      @Nullable public ProgressBar getProgressBar()
      Get the progress bar that can be shown while the data is loading in the background.
      Returns:
      The progress bar that can be shown while the data is loading in the background.
    • setRefreshing

      public void setRefreshing(boolean refreshing)
      Set the refreshing state for the swipe refresh layout.
      Parameters:
      refreshing - true if the the data is refreshing.
    • showProgress

      public void showProgress(boolean animate)
      Show progress bar and hide the recycler view.
      Parameters:
      animate - true to animate the changes.
    • showProgress

      public void showProgress()
      Show progress bar and hide the recycler view.
      See Also:
    • hideProgress

      public void hideProgress(boolean animate)
      Hide progress bar and show the recycler view.
      Parameters:
      animate - true to animate the changes.
    • hideProgress

      public void hideProgress()
      Hide progress bar and show the recycler view.
      See Also:
    • getViewRoot

      @Nullable public View getViewRoot()
      Returns the root scrollable view for this frame layout.
      Returns:
      The root scrollable view.
    • smoothScrollTo

      public void smoothScrollTo(int x, int y)
      Smooth scroll the root view according to the supplied values.
      Parameters:
      x - The x position to scroll to.
      y - The y position to scroll to.
    • scrollToPosition

      public void scrollToPosition(int position)
      Scroll the recycler view view layout manager to the supplied position.
      Parameters:
      position - The position to scroll to.