[m] UI & Cleaning
This commit is contained in:
parent
dccdd4dbf8
commit
f9dc122af5
@ -5,7 +5,9 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import net.helcel.beendroid.R
|
||||
@ -32,21 +34,27 @@ class FoldingListAdapter(private val ctx: Context, l: List<GeoLoc>) :
|
||||
override fun onBindViewHolder(holder: FoldingListViewHolder, position: Int) {
|
||||
val el = cg.toList()[position]
|
||||
holder.bind(el)
|
||||
holder.itemView.setOnClickListener {
|
||||
holder.checkBox.toggle()
|
||||
}
|
||||
holder.itemView.setOnLongClickListener {
|
||||
if (el.second) {
|
||||
cg[el.first] = false
|
||||
}else {
|
||||
cg.forEach {
|
||||
cg[it.key] = it.key == el.first
|
||||
}
|
||||
|
||||
holder.textView.setOnClickListener { holder.checkBox.toggle() }
|
||||
|
||||
val expandLambda = { _:View ->
|
||||
if (el.first.children.isEmpty() || el.first.type == LocType.STATE) {
|
||||
false
|
||||
} else {
|
||||
cg[el.first] = !el.second
|
||||
if (!el.second)
|
||||
cg.filter { (it.key != el.first) && (cg[it.key] == true) }.keys.forEach {
|
||||
cg[it] = false
|
||||
notifyItemChanged(cg.toList().map { e -> e.first }.indexOf(it))
|
||||
}
|
||||
|
||||
notifyItemChanged(position)
|
||||
true
|
||||
}
|
||||
notifyItemChanged(position)
|
||||
true
|
||||
|
||||
}
|
||||
holder.itemView.setOnLongClickListener(expandLambda)
|
||||
holder.expand.setOnClickListener { expandLambda(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
@ -54,24 +62,34 @@ class FoldingListAdapter(private val ctx: Context, l: List<GeoLoc>) :
|
||||
}
|
||||
|
||||
class FoldingListViewHolder(private val ctx: Context, itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
private val textView: TextView
|
||||
val textView: TextView
|
||||
val expand: ImageView
|
||||
val checkBox: CheckBox
|
||||
private val subItemView: View
|
||||
private val list: RecyclerView
|
||||
|
||||
init {
|
||||
textView = itemView.findViewById(R.id.textView)
|
||||
expand = itemView.findViewById(R.id.expand)
|
||||
expand.setImageDrawable(AppCompatResources.getDrawable(ctx,R.drawable.chevron_right_solid))
|
||||
checkBox = itemView.findViewById(R.id.checkBox)
|
||||
subItemView = itemView.findViewById(R.id.sub_item)
|
||||
list = itemView.findViewById(R.id.list_list)
|
||||
list.layoutManager = LinearLayoutManager(ctx, RecyclerView.VERTICAL, false)
|
||||
|
||||
}
|
||||
|
||||
fun bind(el: Pair<GeoLoc, Boolean>) {
|
||||
expand.rotation = if(el.second) 90f else 0f
|
||||
subItemView.visibility = if (el.second) View.VISIBLE else View.GONE
|
||||
textView.text = el.first.fullName
|
||||
if(el.first.type == LocType.STATE || el.first.children.isEmpty())
|
||||
return
|
||||
|
||||
val list: RecyclerView = itemView.findViewById(R.id.list_list)
|
||||
list.layoutManager = LinearLayoutManager(ctx, RecyclerView.VERTICAL, false)
|
||||
|
||||
textView.text = el.first.fullName
|
||||
if(el.first.type == LocType.STATE || el.first.children.isEmpty()){
|
||||
expand.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
textView.parent.parent.requestChildFocus(textView,textView)
|
||||
list.adapter = FoldingListAdapter(ctx, el.first.children)
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val fm = cm.values.fold("") { acc, e -> acc + e.data }
|
||||
val svg = SVG.getFromString("<svg id=\"map\" xmlns=\"http://www.w3.org/2000/svg\" width=\"1200\" height=\"1200\" x=\"0\" y=\"0\" >$fm</svg>")
|
||||
|
||||
val bitmap = Bitmap.createBitmap(1200,1200, Bitmap.Config.ARGB_8888)
|
||||
val bitmap = Bitmap.createBitmap(1200,900, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(bitmap)
|
||||
canvas.drawRGB(255, 255, 255)
|
||||
|
||||
|
8
app/src/main/res/anim/slide.xml
Normal file
8
app/src/main/res/anim/slide.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<translate
|
||||
android:duration="500"
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="100%" />
|
||||
</set>
|
9
app/src/main/res/drawable/chevron_right_solid.xml
Normal file
9
app/src/main/res/drawable/chevron_right_solid.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="320dp"
|
||||
android:height="512dp"
|
||||
android:viewportWidth="320"
|
||||
android:viewportHeight="512">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M310.6,233.4c12.5,12.5 12.5,32.8 0,45.3l-192,192c-12.5,12.5 -32.8,12.5 -45.3,0s-12.5,-32.8 0,-45.3L242.7,256 73.4,86.6c-12.5,-12.5 -12.5,-32.8 0,-45.3s32.8,-12.5 45.3,0l192,192z"/>
|
||||
</vector>
|
@ -8,15 +8,23 @@
|
||||
<com.caverock.androidsvg.SVGImageView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
app:css="" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/sv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:scrollbars="vertical" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:scrollbars="vertical" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
@ -9,33 +9,49 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/sub_item"
|
||||
<ImageView
|
||||
android:id="@+id/expand"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription=">"
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.844"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textColor="@color/design_default_color_on_primary"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/checkBox"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/checkBox"
|
||||
app:layout_constraintTop_toTopOf="@+id/checkBox"
|
||||
app:layout_constraintVertical_bias="0.5" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/checkBox"
|
||||
app:layout_constraintEnd_toStartOf="@+id/checkBox"
|
||||
app:layout_constraintStart_toEndOf="@+id/expand"
|
||||
app:layout_constraintTop_toTopOf="@+id/expand"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sub_item"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="32dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation 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:id="@+id/nav_graph"
|
||||
app:startDestination="@layout/activity_main">
|
||||
|
||||
</navigation>
|
Loading…
x
Reference in New Issue
Block a user