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

Add support annotations for pixel dimension and color int #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

ext {
supportLibVersion = '24.2.1'
}

allprojects {
repositories {
jcenter()
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jun 23 11:31:54 JST 2016
#Tue Sep 27 16:13:47 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:recyclerview-v7:$supportLibVersion"
}

android.libraryVariants.all { variant ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.Px;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
Expand Down Expand Up @@ -354,7 +356,7 @@ public T paintProvider(PaintProvider provider) {
return (T) this;
}

public T color(final int color) {
public T color(@ColorInt final int color) {
return colorProvider(new ColorProvider() {
@Override
public int dividerColor(int position, RecyclerView parent) {
Expand Down Expand Up @@ -390,7 +392,7 @@ public T drawableProvider(DrawableProvider provider) {
return (T) this;
}

public T size(final int size) {
public T size(@Px final int size) {
return sizeProvider(new SizeProvider() {
@Override
public int dividerSize(int position, RecyclerView parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.DimenRes;
import android.support.annotation.Px;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
Expand Down Expand Up @@ -104,6 +105,7 @@ public interface MarginProvider {
* @param parent RecyclerView
* @return left margin
*/
@Px
int dividerLeftMargin(int position, RecyclerView parent);

/**
Expand All @@ -113,6 +115,7 @@ public interface MarginProvider {
* @param parent RecyclerView
* @return right margin
*/
@Px
int dividerRightMargin(int position, RecyclerView parent);
}

Expand All @@ -134,7 +137,7 @@ public Builder(Context context) {
super(context);
}

public Builder margin(final int leftMargin, final int rightMargin) {
public Builder margin(@Px final int leftMargin, @Px final int rightMargin) {
return marginProvider(new MarginProvider() {
@Override
public int dividerLeftMargin(int position, RecyclerView parent) {
Expand All @@ -148,7 +151,7 @@ public int dividerRightMargin(int position, RecyclerView parent) {
});
}

public Builder margin(int horizontalMargin) {
public Builder margin(@Px int horizontalMargin) {
return margin(horizontalMargin, horizontalMargin);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.DimenRes;
import android.support.annotation.Px;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
Expand Down Expand Up @@ -104,6 +105,7 @@ public interface MarginProvider {
* @param parent RecyclerView
* @return top margin
*/
@Px
int dividerTopMargin(int position, RecyclerView parent);

/**
Expand All @@ -113,6 +115,7 @@ public interface MarginProvider {
* @param parent RecyclerView
* @return bottom margin
*/
@Px
int dividerBottomMargin(int position, RecyclerView parent);
}

Expand All @@ -134,7 +137,7 @@ public Builder(Context context) {
super(context);
}

public Builder margin(final int topMargin, final int bottomMargin) {
public Builder margin(@Px final int topMargin, @Px final int bottomMargin) {
return marginProvider(new MarginProvider() {
@Override
public int dividerTopMargin(int position, RecyclerView parent) {
Expand All @@ -148,7 +151,7 @@ public int dividerBottomMargin(int position, RecyclerView parent) {
});
}

public Builder margin(int verticalMargin) {
public Builder margin(@Px int verticalMargin) {
return margin(verticalMargin, verticalMargin);
}

Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ android {
dependencies {
compile project(':library')
// compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:recyclerview-v7:$supportLibVersion"
}