@@ -6,9 +6,8 @@ import androidx.appcompat.app.AppCompatActivity
66import androidx.appcompat.content.res.AppCompatResources
77import androidx.recyclerview.widget.LinearLayoutManager
88import androidx.recyclerview.widget.RecyclerView
9- import kotlinx.android.synthetic.main.activity_main.*
9+ import xyz.sangcomz.stickytimelineview.TimeLineRecyclerView
1010import xyz.sangcomz.stickytimelineview.callback.SectionCallback
11- import xyz.sangcomz.stickytimelineview.decoration.VerticalSectionItemDecoration
1211import xyz.sangcomz.stickytimelineview.model.SectionInfo
1312
1413class MainActivity : AppCompatActivity () {
@@ -39,52 +38,50 @@ class MainActivity : AppCompatActivity() {
3938
4039 private fun initVerticalRecyclerView () {
4140 val singerList = getSingerList()
42- vertical_recycler_view.adapter = SingerAdapter (
43- layoutInflater,
44- singerList,
45- R .layout.recycler_vertical_row
46- )
47-
48- // Currently only LinearLayoutManager is supported.
49- vertical_recycler_view.layoutManager = LinearLayoutManager (
50- this ,
51- RecyclerView .VERTICAL ,
52- false
53- )
54-
55- vertical_recycler_view.addItemDecoration(getSectionCallback(singerList))
41+ findViewById<TimeLineRecyclerView >(R .id.vertical_recycler_view).apply {
42+ adapter = SingerAdapter (
43+ layoutInflater,
44+ singerList,
45+ R .layout.recycler_vertical_row
46+ )
47+ layoutManager = LinearLayoutManager (
48+ this @MainActivity,
49+ RecyclerView .VERTICAL ,
50+ false
51+ )
52+ addItemDecoration(getSectionCallback(singerList))
53+ }
5654 }
5755
5856 private fun initHorizontalRecyclerView () {
5957 val singerList = getSingerList()
60- horizontal_recycler_view.adapter = SingerAdapter (
61- layoutInflater,
62- singerList,
63- R .layout.recycler_horizontal_row
64- )
65-
66- horizontal_recycler_view2.adapter = SingerAdapter (
67- layoutInflater,
68- singerList,
69- R .layout.recycler_horizontal_row
70- )
71-
72-
73- // Currently only LinearLayoutManager is supported.
74- horizontal_recycler_view.layoutManager = LinearLayoutManager (
75- this ,
76- RecyclerView .HORIZONTAL ,
77- false
78- )
79-
80- horizontal_recycler_view2.layoutManager = LinearLayoutManager (
81- this ,
82- RecyclerView .HORIZONTAL ,
83- false
84- )
85-
86- horizontal_recycler_view.addItemDecoration(getSectionCallback(singerList))
87- horizontal_recycler_view2.addItemDecoration(getSectionCallbackWithDrawable(singerList))
58+ findViewById<TimeLineRecyclerView >(R .id.horizontal_recycler_view).apply {
59+ adapter = SingerAdapter (
60+ layoutInflater,
61+ singerList,
62+ R .layout.recycler_horizontal_row
63+ )
64+ layoutManager = LinearLayoutManager (
65+ this @MainActivity,
66+ RecyclerView .HORIZONTAL ,
67+ false
68+ )
69+ addItemDecoration(getSectionCallback(singerList))
70+ }
71+
72+ findViewById<TimeLineRecyclerView >(R .id.horizontal_recycler_view2).apply {
73+ adapter = SingerAdapter (
74+ layoutInflater,
75+ singerList,
76+ R .layout.recycler_horizontal_row
77+ )
78+ layoutManager = LinearLayoutManager (
79+ this @MainActivity,
80+ RecyclerView .HORIZONTAL ,
81+ false
82+ )
83+ addItemDecoration(getSectionCallbackWithDrawable(singerList))
84+ }
8885 }
8986
9087 // Get data method
0 commit comments