-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainActivity.kt
67 lines (53 loc) · 2.34 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.azhar.recyclerdragdrop.activities
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.azhar.recyclerdragdrop.R
import com.azhar.recyclerdragdrop.adapter.MainAdapter
import com.azhar.recyclerdragdrop.utils.Listener
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
/**
* Created by Azhar Rivaldi on 19-09-2020
*/
class MainActivity : AppCompatActivity(), Listener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setTopRecyclerView()
setBottomRecyclerView()
tvEmptyListTop.setVisibility(View.GONE)
tvEmptyListBottom.setVisibility(View.GONE)
}
private fun setTopRecyclerView() {
rvTop.setHasFixedSize(true)
rvTop.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
val topList: MutableList<String> = ArrayList()
topList.add("A")
topList.add("B")
val topListAdapter = MainAdapter(topList, this)
rvTop.adapter = topListAdapter
tvEmptyListTop.setOnDragListener(topListAdapter.dragInstance)
rvTop.setOnDragListener(topListAdapter.dragInstance)
}
private fun setBottomRecyclerView() {
rvBottom.setHasFixedSize(true)
rvBottom.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
val bottomList: MutableList<String> = ArrayList()
bottomList.add("C")
bottomList.add("D")
val bottomListAdapter = MainAdapter(bottomList, this)
rvBottom.adapter = bottomListAdapter
tvEmptyListBottom.setOnDragListener(bottomListAdapter.dragInstance)
rvBottom.setOnDragListener(bottomListAdapter.dragInstance)
}
override fun setEmptyListTop(visibility: Boolean) {
tvEmptyListTop.visibility = if (visibility) View.VISIBLE else View.GONE
rvTop.visibility = if (visibility) View.GONE else View.VISIBLE
}
override fun setEmptyListBottom(visibility: Boolean) {
tvEmptyListBottom.visibility = if (visibility) View.VISIBLE else View.GONE
rvBottom.visibility = if (visibility) View.GONE else View.VISIBLE
}
}