Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Javadocs to library #6

Merged
merged 5 commits into from
Aug 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds an offset to the bottom of a {@link RecyclerView} with a
* {@link android.support.v7.widget.GridLayoutManager} or its subclass.
*/
public class GridBottomOffsetItemDecoration extends RecyclerView.ItemDecoration {

private int mOffsetPx;
private int mNumColumns;

/**
* Sole constructor. Takes in the size of the offset to be added to the
* bottom of the {@link RecyclerView}.
*
* @param offsetPx The size of the offset to be added to the bottom of the
* {@code RecyclerView} in pixels
* @param numColumns The number of columns in the grid of the {@code RecyclerView}
*/
public GridBottomOffsetItemDecoration(int offsetPx, int numColumns) {
mOffsetPx = offsetPx;
mNumColumns = numColumns;
}

/**
* Determines the size and the location of the offset to be added to the
* bottom of the {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,56 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds interior dividers to a {@link RecyclerView} with a
* {@link android.support.v7.widget.GridLayoutManager}.
*/
public class GridDividerItemDecoration extends RecyclerView.ItemDecoration {

private Drawable mHorizontalDivider;
private Drawable mVerticalDivider;
private int mNumColumns;

/**
* Adds dividers to a RecyclerView with a GridLayoutManager.
* Sole constructor. Takes in {@link Drawable} objects to be used as
* horizontal and vertical dividers.
*
* @param horizontalDivider A divider Drawable to be drawn on the rows of
* the grid of the RecyclerView
* @param verticalDivider A divider Drawable to be drawn on the columns of
* the grid of the RecyclerView
* @param numColumns The number of columns in the grid of the RecyclerView
* @param horizontalDivider A divider {@code Drawable} to be drawn on the
* rows of the grid of the {@link RecyclerView}
* @param verticalDivider A divider {@code Drawable} to be drawn on the
* columns of the grid of the {@code RecyclerView}
* @param numColumns The number of columns in the grid of the {@code RecyclerView}
*/
public GridDividerItemDecoration(Drawable horizontalDivider, Drawable verticalDivider, int numColumns) {
mHorizontalDivider = horizontalDivider;
mVerticalDivider = verticalDivider;
mNumColumns = numColumns;
}

/**
* Draws horizontal and/or vertical dividers onto the parent {@link RecyclerView}.
*
* @param canvas The {@link Canvas} onto which dividers will be drawn
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
drawHorizontalDividers(canvas, parent);
drawVerticalDividers(canvas, parent);
}

/**
* Determines the size and location of offsets between items in the parent
* {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand All @@ -49,8 +72,11 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, Recycle
}

/**
* Adds horizontal dividers to a RecyclerView with a GridLayoutManager (or
* its subclass).
* Adds horizontal dividers to a {@link RecyclerView} with a
* {@link android.support.v7.widget.GridLayoutManager} or its subclass.
*
* @param canvas The {@link Canvas} onto which dividers will be drawn
* @param parent The {@code RecyclerView} onto which dividers are being added
*/
private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) {
int parentTop = parent.getPaddingTop();
Expand All @@ -69,8 +95,11 @@ private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) {
}

/**
* Adds vertical dividers to a RecyclerView with a GridLayoutManager (or
* its subclass).
* Adds vertical dividers to a {@link RecyclerView} with a
* {@link android.support.v7.widget.GridLayoutManager} or its subclass.
*
* @param canvas The {@link Canvas} onto which dividers will be drawn
* @param parent The {@code RecyclerView} onto which dividers are being added
*/
private void drawVerticalDividers(Canvas canvas, RecyclerView parent) {
int parentLeft = parent.getPaddingLeft();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds an offset to the top of a {@link RecyclerView} with a
* {@link android.support.v7.widget.GridLayoutManager} or its subclass.
*/
public class GridTopOffsetItemDecoration extends RecyclerView.ItemDecoration {

private int mOffsetPx;
private int mNumColumns;

/**
* Sole constructor. Takes in the size of the offset to be added to the top
* of the {@link RecyclerView}.
*
* @param offsetPx The size of the offset to be added to the top of the
* {@code RecyclerView} in pixels
* @param numColumns The number of columns in the grid of the {@code RecyclerView}
*/
public GridTopOffsetItemDecoration(int offsetPx, int numColumns) {
mOffsetPx = offsetPx;
mNumColumns = numColumns;
}

/**
* Determines the size and the location of the offset to be added to the
* top of the {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds interior dividers to a {@link RecyclerView} with a
* {@link LinearLayoutManager} or its subclass.
*/
public class DividerItemDecoration extends RecyclerView.ItemDecoration {

private Drawable mDivider;
private int mOrientation;

/**
* Adds dividers to a RecyclerView with a LinearLayoutManager.
* Sole constructor. Takes in a {@link Drawable} to be used as the interior
* divider.
*
* @param divider A divider Drawable to be drawn on the RecyclerView
* @param divider A divider {@code Drawable} to be drawn on the {@link RecyclerView}
*/
public DividerItemDecoration(Drawable divider) {
mDivider = divider;
}

/**
* Draws horizontal or vertical dividers onto the parent {@link RecyclerView}.
*
* @param canvas The {@link Canvas} onto which dividers will be drawn
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
if (mOrientation == LinearLayoutManager.HORIZONTAL) {
Expand All @@ -30,6 +43,18 @@ public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state)
}
}

/**
* Determines the size and location of offsets between items in the parent
* {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child
* view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being
* added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand All @@ -47,8 +72,13 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, Recycle
}

/**
* Adds dividers to a RecyclerView with a LinearLayoutManager (or its
* subclass) oriented horizontally.
* Adds dividers to a {@link RecyclerView} with a
* {@link LinearLayoutManager} or its subclass oriented horizontally.
*
* @param canvas The {@link Canvas} onto which horizontal dividers will be
* drawn
* @param parent The {@code RecyclerView} onto which horizontal dividers
* are being added
*/
private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) {
int parentTop = parent.getPaddingTop();
Expand All @@ -69,8 +99,13 @@ private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) {
}

/**
* Adds dividers to a RecyclerView with a LinearLayoutManager (or its
* subclass) oriented vertically.
* Adds dividers to a {@link RecyclerView} with a
* {@link LinearLayoutManager} or its subclass oriented vertically.
*
* @param canvas The {@link Canvas} onto which vertical dividers will be
* drawn
* @param parent The {@code RecyclerView} onto which vertical dividers are
* being added
*/
private void drawVerticalDividers(Canvas canvas, RecyclerView parent) {
int parentLeft = parent.getPaddingLeft();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds an offset to the end of a {@link RecyclerView} using a
* {@link LinearLayoutManager} or its subclass.
* <p>
* If the {@link android.support.v7.widget.RecyclerView.LayoutManager} is
* oriented vertically, the offset will be added to the bottom of the
* {@code RecyclerView}. If the {@code LayoutManager} is oriented horizontally,
* the offset will be added to the right of the {@code RecyclerView}.
*/
public class EndOffsetItemDecoration extends RecyclerView.ItemDecoration {

private int mOffsetPx;

/**
* Sole constructor. Takes in the size of the offset to be added to the end
* of the {@link RecyclerView}.
*
* @param offsetPx The size of the offset to be added to the end of the
* {@code RecyclerView} in pixels
*/
public EndOffsetItemDecoration(int offsetPx) {
mOffsetPx = offsetPx;
}

/**
* Determines the size and location of the offset to be added to the end
* of the {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Adds an offset to the start of a {@link RecyclerView} using a
* {@link LinearLayoutManager} or its subclass.
* <p>
* If the {@link android.support.v7.widget.RecyclerView.LayoutManager} is
* oriented vertically, the offset will be added to the top of the
* {@code RecyclerView}. If the {@code LayoutManager} is oriented horizontally,
* the offset will be added to the left of the {@code RecyclerView}.
*/
public class StartOffsetItemDecoration extends RecyclerView.ItemDecoration {

private int mOffsetPx;

/**
* Sole constructor. Takes in the size of the offset to be added to the
* start of the {@link RecyclerView}.
*
* @param offsetPx The size of the offset to be added to the start of the
* {@code RecyclerView} in pixels
*/
public StartOffsetItemDecoration(int offsetPx) {
mOffsetPx = offsetPx;
}

/**
* Determines the size and location of the offset to be added to the start
* of the {@link RecyclerView}.
*
* @param outRect The {@link Rect} of offsets to be added around the child view
* @param view The child view to be decorated with an offset
* @param parent The {@code RecyclerView} onto which dividers are being added
* @param state The current {@link android.support.v7.widget.RecyclerView.State}
* of the {@code RecyclerView}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
Expand Down