Skip to content
Snippets Groups Projects
Commit 7913cbab authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Allow creation of ignore rules

parent 43964f14
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,7 @@ class IgnoreItemFragment : SettingsFragment() {
return view
}
override fun onSave() = item?.let { data ->
override fun onSave() = item.let { data ->
val intent = Intent()
intent.putExtra("old", data)
val new = IgnoreListManager.IgnoreListItem(
......@@ -139,6 +139,6 @@ class IgnoreItemFragment : SettingsFragment() {
intent.putExtra("new", new)
requireActivity().setResult(Activity.RESULT_OK, intent)
true
} ?: false
}
}
......@@ -47,6 +47,11 @@ class IgnoreListFragment : SettingsFragment() {
helper = ItemTouchHelper(callback)
helper.attachToRecyclerView(list)
add.setOnClickListener {
val intent = Intent(requireContext(), IgnoreItemActivity::class.java)
startActivityForResult(intent, REQUEST_CREATE_RULE)
}
viewModel.ignoreListManager
.filter(Optional<IgnoreListManager>::isPresent)
.map(Optional<IgnoreListManager>::get)
......@@ -77,14 +82,18 @@ class IgnoreListFragment : SettingsFragment() {
val oldRule = data.getSerializableExtra("old") as? IgnoreListManager.IgnoreListItem
val newRule = data.getSerializableExtra("new") as? IgnoreListManager.IgnoreListItem
println(oldRule)
println(newRule)
if (oldRule != null && newRule != null) {
val index = adapter.indexOf(oldRule.ignoreRule)
adapter.replace(index, newRule)
}
}
REQUEST_CREATE_RULE -> {
val newRule = data.getSerializableExtra("new") as? IgnoreListManager.IgnoreListItem
if (newRule != null) {
adapter.add(newRule)
}
}
}
}
}
......@@ -97,5 +106,6 @@ class IgnoreListFragment : SettingsFragment() {
companion object {
private const val REQUEST_UPDATE_RULE = 1
private const val REQUEST_CREATE_RULE = 2
}
}
......@@ -19,7 +19,6 @@
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:visibility="gone"
app:fabSize="normal"
app:srcCompat="@drawable/ic_add"
app:tint="?colorTextPrimaryInverse" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment