Skip to content

Instantly share code, notes, and snippets.

View nicoqueijo's full-sized avatar

Nicolas Queijo nicoqueijo

View GitHub Profile
class MainActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...
}
private fun addRow(currency: Currency) {
class MainActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...
findViewById<FloatingActionButton>(R.id.floating_action_button).setOnClickListener {
if (removedCurrencies.isNotEmpty()) {
removedCurrencies.pop().let {
private fun addRow(currency: Currency) {
CurrencyRow(this).run row@{
initRow(currency)
dragLinearLayout.run {
addView(this@row)
setViewDraggable(this@row, this@row)
scrollableArea.setOnLongClickListener {
val indexToRemove = indexOfChild(this@row)
addedCurrencies.removeAt(indexToRemove).let {
removedCurrencies.push(it)
private fun addRow(currency: Currency) {
CurrencyRow(this).run row@{
initRow(currency)
dragLinearLayout.run {
addView(this@row)
setViewDraggable(this@row, this@row)
scrollableArea.setOnLongClickListener {
val indexToRemove = indexOfChild(this@row)
addedCurrencies.removeAt(indexToRemove).let {
removedCurrencies.push(it)
class MainActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...
}
private fun addRow(currency: Currency) {
CurrencyRow(this).run row@{
class CurrencyRow(context: Context?, attrs: AttributeSet? = null) :
ConstraintLayout(context, attrs) {
val scrollableArea: ConstraintLayout
...
init {
LayoutInflater.from(context).inflate(R.layout.row_currency, this)
scrollableArea = findViewById(R.id.scrollable_area)
...
class MainActivity : AppCompatActivity() {
private lateinit var scrollView: ScrollView
private lateinit var dragLinearLayout: DragLinearLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
scrollView = findViewById(R.id.scroll_view)
class MainActivity : AppCompatActivity() {
private lateinit var scrollView: ScrollView
private lateinit var dragLinearLayout: DragLinearLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
scrollView = findViewById(R.id.scroll_view)
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/dark_gray">
<com.jmedeisis.draglinearlayout.DragLinearLayout
android:id="@+id/drag_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/divider"
android:orientation="vertical"
android:paddingBottom="90dp"
android:showDividers="middle|beginning|end" />