Skip to content

Commit 26c05fd

Browse files
committed
Implement setRibbonDrawableResource
1 parent 6f2cedc commit 26c05fd

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
![gif0](https://user-images.githubusercontent.com/24237865/51105497-7873e680-182c-11e9-954a-1bf767d15312.gif) ![gif1](https://user-images.githubusercontent.com/24237865/51105671-fb953c80-182c-11e9-8288-7ce97d5474e8.gif)
1010

1111
## Download
12-
[![Download](https://api.bintray.com/packages/devmagician/maven/androidribbon/images/download.svg) ](https://bintray.com/devmagician/maven/androidribbon/_latestVersion)
12+
[![Download](https://api.bintray.com/packages/devmagician/maven/androidribbon/images/download.svg)](https://bintray.com/devmagician/maven/androidribbon/_latestVersion)
1313
[![Jitpack](https://jitpack.io/v/skydoves/AndroidRibbon.svg)](https://jitpack.io/#skydoves/AndroidRibbon)
1414
### Gradle
1515
And add a dependency code to your **module**'s `build.gradle` file.
1616
```gradle
1717
dependencies {
18-
implementation "com.github.skydoves:androidribbon:1.0.1"
18+
implementation "com.github.skydoves:androidribbon:1.0.2"
1919
}
2020
```
2121

@@ -58,14 +58,14 @@ new RibbonView.Builder(context)
5858
### create using kotlin dsl
5959
This is how to create `RibbonView`'s instance using kotlin dsl.
6060
```kotlin
61-
val ribbonView = ribbonView(context) {
62-
text = "Android-Ribbon"
63-
textColor = Color.WHITE
64-
textSize = 13f
65-
textStyle = Typeface.BOLD
66-
ribbonRotation = -45
67-
ribbonDrawable = ContextCompat.getDrawable(context, R.drawable.ribbon02)
68-
}
61+
val ribbonView = ribbonView(this) {
62+
setText("Android-Ribbon")
63+
setTextColor(Color.WHITE)
64+
setTextSize(13f)
65+
setTextStyle(Typeface.BOLD)
66+
setRibbonRotation(-45)
67+
setRibbonDrawableResource(R.drawable.ribbon02)
68+
}
6969
```
7070

7171
## ShimmerRibbonView

androidribbon/src/main/java/com/skydoves/androidribbon/RibbonRecyclerView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ package com.skydoves.androidribbon
1919
import android.content.Context
2020
import android.content.res.TypedArray
2121
import android.util.AttributeSet
22-
import android.widget.LinearLayout
2322
import androidx.recyclerview.widget.LinearLayoutManager
2423
import androidx.recyclerview.widget.RecyclerView
24+
import com.skydoves.androidribbon.annotations.Dp
2525

2626
/** RibbonRecyclerView helps to create [RecyclerView] that has [RibbonView] as items. */
2727
@Suppress("LiftReturnOrAssignment")
2828
class RibbonRecyclerView : RecyclerView, IRibbonList {
2929

3030
private val ribbonAdapter: RibbonRecyclerAdapter = RibbonRecyclerAdapter()
31-
private var space = 3f
3231
private var orientation = 1
32+
@Dp private var space = 3f
3333

3434
constructor(context: Context) : super(context) {
3535
onCreate()
@@ -74,7 +74,7 @@ class RibbonRecyclerView : RecyclerView, IRibbonList {
7474
private fun onCreate() {
7575
when (orientation) {
7676
0 -> layoutManager = LinearLayoutManager(context)
77-
1 -> layoutManager = LinearLayoutManager(context, LinearLayout.HORIZONTAL, false)
77+
1 -> layoutManager = LinearLayoutManager(context, HORIZONTAL, false)
7878
}
7979
addItemDecoration(RibbonTagItemDecoration(space.dp2px(resources), orientation))
8080
adapter = ribbonAdapter

androidribbon/src/main/java/com/skydoves/androidribbon/RibbonView.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import android.util.AttributeSet
2626
import android.view.Gravity
2727
import androidx.annotation.ColorInt
2828
import androidx.annotation.ColorRes
29+
import androidx.annotation.DrawableRes
2930
import androidx.appcompat.widget.AppCompatTextView
3031
import androidx.core.content.ContextCompat
3132
import com.skydoves.androidribbon.annotations.Dp
@@ -233,6 +234,10 @@ class RibbonView : AppCompatTextView, RibbonInterface {
233234
this.ribbonDrawable = RibbonDrawable
234235
}
235236

237+
fun setRibbonDrawableResource(@DrawableRes drawable: Int): Builder = apply {
238+
this.ribbonDrawable = ContextCompat.getDrawable(this.context, drawable)
239+
}
240+
236241
fun setRibbonBackgroundColor(@ColorInt color: Int): Builder = apply {
237242
this.ribbonBackgroundColor = color
238243
}

dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ext.versions = [
22
minSdk : 16,
33
compileSdk : 29,
4-
versionCode : 2,
5-
versionName : '1.0.1',
4+
versionCode : 3,
5+
versionName : '1.0.2',
66

77
gradleBuildTool : '3.5.3',
88
spotlessGradle : '3.26.1',

0 commit comments

Comments
 (0)