Skip to content

Commit 64ba02e

Browse files
committed
dev: Scroller added
1 parent b4858ae commit 64ba02e

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed
0 Bytes
Binary file not shown.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/params/com/statusView/StatusView.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,27 @@ import android.text.TextPaint
1212
import android.util.AttributeSet
1313
import android.util.TypedValue
1414
import android.view.View
15+
import android.widget.HorizontalScrollView
1516
import kotlin.properties.Delegates
1617
import kotlin.reflect.KProperty
1718

19+
class StatusViewScroller @JvmOverloads constructor(
20+
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
21+
) : HorizontalScrollView(context, attrs, defStyleAttr) {
22+
23+
private var statusView:StatusView = StatusView(context,attrs)
24+
25+
init{
26+
addView(statusView)
27+
}
28+
29+
fun scrollToPos(count:Int){
30+
scrollTo(statusView.getScrollPosForStatus(count).toInt(),scrollY)
31+
}
32+
fun smoothScrollToPos(count:Int){
33+
smoothScrollTo(statusView.getScrollPosForStatus(count).toInt(),scrollY)
34+
}
35+
}
1836

1937
/**
2038
* Created by Parminder Saini on 12/06/18.
@@ -1090,5 +1108,13 @@ class StatusView @JvmOverloads constructor(
10901108
return TypedValue.applyDimension(unit,this,resources.displayMetrics)
10911109
}
10921110

1111+
fun getScrollPosForStatus(count: Int): Int {
1112+
val posIndex = count - 1
1113+
return if (posIndex> 0 && posIndex < drawingData.size) {
1114+
drawingData[posIndex].circleItem.center.x.toInt()
1115+
} else {
1116+
0
1117+
}
1118+
}
10931119

10941120
}

app/src/main/res/layout/activity_main.xml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
tools:ignore="ResAuto">
88

99

10-
<HorizontalScrollView
11-
android:id="@+id/scrollView"
12-
app:layout_constraintLeft_toLeftOf="parent"
13-
app:layout_constraintRight_toRightOf="parent"
14-
app:layout_constraintTop_toTopOf="parent"
15-
app:layout_constraintBottom_toBottomOf="parent"
16-
android:layout_width="wrap_content"
17-
android:layout_height="wrap_content">
18-
19-
<params.com.statusView.StatusView
10+
11+
12+
<params.com.statusView.StatusViewScroller
2013
android:id="@+id/statusView"
2114
android:layout_width="wrap_content"
2215
android:layout_height="wrap_content"
16+
app:layout_constraintTop_toTopOf="parent"
17+
app:layout_constraintBottom_toBottomOf="parent"
18+
app:layout_constraintStart_toStartOf="parent"
19+
app:layout_constraintEnd_toEndOf="parent"
2320
app:circleColorType="fillStroke"
24-
app:statusCount="4"
21+
app:statusCount="15"
2522
app:currentCount="3"
2623
app:lineLength="25dp"
2724
app:circleRadius="25dp"
@@ -32,7 +29,8 @@
3229
app:labelFont="@font/roboto_r"
3330
android:entries="@array/statuses"
3431
app:current_drawable="@drawable/ic_tag_faces_black_24dp" />
35-
</HorizontalScrollView>
32+
33+
3634

3735

3836

0 commit comments

Comments
 (0)