Skip to content

Commit 6b74efd

Browse files
✨ CarouselPicker now supports textColor.
✨ Updated gradle files
1 parent ee2bf70 commit 6b74efd

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

app/build.gradle

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion 27
5+
buildToolsVersion '27.0.3'
66
defaultConfig {
77
applicationId "in.goodiebag.example"
88
minSdkVersion 15
9-
targetSdkVersion 25
9+
targetSdkVersion 27
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,11 +20,9 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(include: ['*.jar'], dir: 'libs')
24-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25-
exclude group: 'com.android.support', module: 'support-annotations'
26-
})
27-
compile 'com.android.support:appcompat-v7:25.3.1'
28-
testCompile 'junit:junit:4.12'
29-
compile project(':carouselpicker')
23+
implementation fileTree(include: ['*.jar'], dir: 'libs')
24+
25+
implementation 'com.android.support:appcompat-v7:27.1.1'
26+
testImplementation 'junit:junit:4.12'
27+
implementation project(':carouselpicker')
3028
}

app/src/main/java/in/goodiebag/example/MainActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
4747
mixItems.add(new CarouselPicker.TextItem("hi", 20));
4848

4949
CarouselPicker.CarouselViewAdapter mixAdapter = new CarouselPicker.CarouselViewAdapter(this, mixItems, 0);
50+
mixAdapter.setTextColor(getResources().getColor(R.color.colorPrimary));
5051
mixCarousel.setAdapter(mixAdapter);
5152

5253
imageCarousel.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.3'
9+
classpath 'com.android.tools.build:gradle:3.1.1'
910

1011
// NOTE: Do not place your application dependencies here; they belong
1112
// in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
1516
allprojects {
1617
repositories {
1718
jcenter()
19+
google()
1820
}
1921
}
2022

carouselpicker/build.gradle

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion 27
5+
buildToolsVersion "27.0.3"
66

77
defaultConfig {
88
minSdkVersion 15
9-
targetSdkVersion 25
9+
targetSdkVersion 27
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -22,10 +22,8 @@ android {
2222
}
2323

2424
dependencies {
25-
compile fileTree(dir: 'libs', include: ['*.jar'])
26-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27-
exclude group: 'com.android.support', module: 'support-annotations'
28-
})
29-
compile 'com.android.support:appcompat-v7:25.3.1'
30-
testCompile 'junit:junit:4.12'
25+
implementation fileTree(dir: 'libs', include: ['*.jar'])
26+
27+
implementation 'com.android.support:appcompat-v7:27.1.1'
28+
testImplementation 'junit:junit:4.12'
3129
}

carouselpicker/src/main/java/in/goodiebag/carouselpicker/CarouselPicker.java

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.res.TypedArray;
5+
import android.support.annotation.ColorInt;
56
import android.support.annotation.DrawableRes;
67
import android.support.v4.view.PagerAdapter;
78
import android.support.v4.view.ViewPager;
@@ -100,6 +101,7 @@ public static class CarouselViewAdapter extends PagerAdapter {
100101
List<PickerItem> items = new ArrayList<>();
101102
Context context;
102103
int drawable;
104+
int textColor = 0;
103105

104106
public CarouselViewAdapter(Context context, List<PickerItem> items, int drawable) {
105107
this.context = context;
@@ -132,6 +134,9 @@ public Object instantiateItem(ViewGroup container, int position) {
132134
iv.setVisibility(GONE);
133135
tv.setVisibility(VISIBLE);
134136
tv.setText(pickerItem.getText());
137+
if(textColor != 0){
138+
tv.setTextColor(textColor);
139+
}
135140
int textSize = ((TextItem) pickerItem).getTextSize();
136141
if (textSize != 0) {
137142
tv.setTextSize(dpToPx(((TextItem) pickerItem).getTextSize()));
@@ -143,6 +148,14 @@ public Object instantiateItem(ViewGroup container, int position) {
143148
return view;
144149
}
145150

151+
public int getTextColor() {
152+
return textColor;
153+
}
154+
155+
public void setTextColor(@ColorInt int textColor) {
156+
this.textColor = textColor;
157+
}
158+
146159
@Override
147160
public void destroyItem(ViewGroup container, int position, Object object) {
148161
container.removeView((View) object);
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Dec 28 10:00:20 PST 2015
1+
#Mon Jul 02 11:49:25 IST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)