DanaHistoryActivity spinner replacement
This commit is contained in:
parent
cb1e40bd90
commit
3212e9d906
|
@ -83,6 +83,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = DanarHistoryActivityBinding.inflate(layoutInflater)
|
binding = DanarHistoryActivityBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
setTheme(R.style.AppTheme)
|
||||||
|
|
||||||
binding.recyclerview.setHasFixedSize(true)
|
binding.recyclerview.setHasFixedSize(true)
|
||||||
binding.recyclerview.layoutManager = LinearLayoutManager(this)
|
binding.recyclerview.layoutManager = LinearLayoutManager(this)
|
||||||
|
@ -108,11 +109,10 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, rh.gs(R.string.danar_history_refill)))
|
typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, rh.gs(R.string.danar_history_refill)))
|
||||||
typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, rh.gs(R.string.danar_history_syspend)))
|
typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, rh.gs(R.string.danar_history_syspend)))
|
||||||
}
|
}
|
||||||
binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList)
|
binding.typeList.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, typeList))
|
||||||
|
|
||||||
binding.reload.setOnClickListener {
|
binding.reload.setOnClickListener {
|
||||||
val selected = binding.spinner.selectedItem as TypeList?
|
val selected = typeList.firstOrNull { it.name == binding.typeList.text.toString() } ?: return@setOnClickListener
|
||||||
?: return@setOnClickListener
|
|
||||||
binding.reload.visibility = View.GONE
|
binding.reload.visibility = View.GONE
|
||||||
binding.status.visibility = View.VISIBLE
|
binding.status.visibility = View.VISIBLE
|
||||||
clearCardView()
|
clearCardView()
|
||||||
|
@ -126,16 +126,10 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
binding.typeList.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
|
||||||
val selected = typeList[position]
|
val selected = typeList[position]
|
||||||
swapAdapter(selected.type)
|
|
||||||
showingType = selected.type
|
showingType = selected.type
|
||||||
}
|
swapAdapter(selected.type)
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
clearCardView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
android:background="?attr/activity_title_backgroundColor"
|
android:background="?attr/activity_title_backgroundColor"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/spinner"
|
app:layout_constraintBottom_toTopOf="@+id/typeListLayout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
@ -49,29 +49,29 @@
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
<TextView
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:id="@+id/textView"
|
android:id="@+id/typeListLayout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:text="@string/eventtype"
|
android:hint="@string/eventtype"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
app:boxStrokeColor="@color/list_delimiter"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/spinner"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/spinner"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/spinner" />
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/spinner"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/status"
|
app:layout_constraintBottom_toTopOf="@+id/status"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/textView"
|
app:layout_constraintStart_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/header" />
|
app:layout_constraintTop_toBottomOf="@+id/header">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
|
||||||
|
android:id="@+id/typeList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:enabled="false"
|
||||||
|
tools:ignore="KeyboardInaccessibleWidget" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/status"
|
android:id="@+id/status"
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
app:layout_constraintBottom_toTopOf="@+id/recyclerview"
|
app:layout_constraintBottom_toTopOf="@+id/recyclerview"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
app:layout_constraintTop_toBottomOf="@+id/typeListLayout" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recyclerview"
|
android:id="@+id/recyclerview"
|
||||||
|
@ -100,9 +100,9 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="1dp"
|
android:layout_marginBottom="1dp"
|
||||||
|
android:text="@string/reload"
|
||||||
app:icon="@drawable/ic_actions_refill"
|
app:icon="@drawable/ic_actions_refill"
|
||||||
app:iconTint="@color/ic_actions_refill"
|
app:iconTint="@color/ic_actions_refill"
|
||||||
android:text="@string/reload"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue