Preparing for selection
This commit is contained in:
parent
23549344d4
commit
229941e6de
|
@ -10,21 +10,25 @@ import android.widget.ImageView
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import java.io.File
|
||||
|
||||
class AbstractProductView: LinearLayout {
|
||||
private var productLayout: ConstraintLayout
|
||||
private var productPicture: ImageView
|
||||
private var productNameField: TextView
|
||||
private var netWeightField: TextView
|
||||
private var categoryField: TextView
|
||||
private var unitField: TextView
|
||||
var isProductSelected = false
|
||||
|
||||
constructor(activity: Activity, context: Context, productImageHash: String, productName: String, netWeight: Double, category: Int) : super(context) {
|
||||
|
||||
val inflater:LayoutInflater = activity.layoutInflater
|
||||
inflater.inflate(R.layout.abstract_product_view, this)
|
||||
|
||||
productLayout = findViewById(R.id.productLayout)
|
||||
productPicture = findViewById(R.id.productPicture)
|
||||
productNameField = findViewById(R.id.productNameView)
|
||||
netWeightField = findViewById(R.id.productNetWeightView)
|
||||
|
@ -46,16 +50,19 @@ class AbstractProductView: LinearLayout {
|
|||
startActivity(context, fullscreenIntent, extras)
|
||||
}
|
||||
|
||||
productLayout.setOnClickListener {
|
||||
|
||||
}
|
||||
|
||||
productNameField.text = productName
|
||||
netWeightField.text = netWeight.toString()
|
||||
|
||||
//TODO: category and units
|
||||
|
||||
|
||||
findViewById<ConstraintLayout>(R.id.productLayout).setOnClickListener {
|
||||
Log.d("QWERTYUIOP", "Clicked layout")
|
||||
productLayout.setOnLongClickListener {
|
||||
isProductSelected = !isProductSelected
|
||||
this.background = ContextCompat.getDrawable(context, if (isProductSelected) R.drawable.outline_selected else R.drawable.outline)
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:width="1dip" android:color="#28283f"/>
|
||||
<padding android:bottom="1dp" android:top="1dp" android:left="1dp" android:right="1dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:width="1dip" android:color="#840d15"/>
|
||||
<padding android:bottom="1dp" android:top="1dp" android:left="1dp" android:right="1dp" />
|
||||
</shape>
|
|
@ -2,7 +2,8 @@
|
|||
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" android:layout_width="200dp"
|
||||
android:layout_height="wrap_content" app:barrierMargin="1dp" android:clickable="false">
|
||||
android:layout_height="wrap_content" app:barrierMargin="1dp" android:clickable="false"
|
||||
android:outlineProvider="background" android:background="@drawable/outline">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue