Merge pull request #108 from Philoul/Automation_Remove_Swipe_To_Delete
Delete Automation rule with button
This commit is contained in:
commit
3f64dff011
3 changed files with 25 additions and 2 deletions
|
@ -192,6 +192,17 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
}
|
}
|
||||||
v.onTouchEvent(motionEvent)
|
v.onTouchEvent(motionEvent)
|
||||||
}
|
}
|
||||||
|
// remove event
|
||||||
|
holder.iconTrash.setOnClickListener {
|
||||||
|
showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.automationEvents[position].title,
|
||||||
|
Runnable {
|
||||||
|
automationPlugin.automationEvents.removeAt(position)
|
||||||
|
notifyItemRemoved(position)
|
||||||
|
rxBus.send(EventAutomationDataChanged())
|
||||||
|
rxBus.send(EventAutomationUpdateGui())
|
||||||
|
}, Runnable { rxBus.send(EventAutomationUpdateGui())
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = automationPlugin.automationEvents.size
|
override fun getItemCount(): Int = automationPlugin.automationEvents.size
|
||||||
|
@ -219,6 +230,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
val rootLayout: RelativeLayout = view.findViewById(R.id.rootLayout)
|
val rootLayout: RelativeLayout = view.findViewById(R.id.rootLayout)
|
||||||
val iconLayout: LinearLayout = view.findViewById(R.id.iconLayout)
|
val iconLayout: LinearLayout = view.findViewById(R.id.iconLayout)
|
||||||
val eventTitle: TextView = view.findViewById(R.id.viewEventTitle)
|
val eventTitle: TextView = view.findViewById(R.id.viewEventTitle)
|
||||||
|
val iconTrash: ImageView = view.findViewById(R.id.iconTrash)
|
||||||
val iconSort: ImageView = view.findViewById(R.id.iconSort)
|
val iconSort: ImageView = view.findViewById(R.id.iconSort)
|
||||||
val enabled: CheckBox = view.findViewById(R.id.automation_enabled)
|
val enabled: CheckBox = view.findViewById(R.id.automation_enabled)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class SimpleItemTouchHelperCallback(private val mAdapter: ItemTouchHelperAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isItemViewSwipeEnabled(): Boolean {
|
override fun isItemViewSwipeEnabled(): Boolean {
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int { // Set movement flags based on the layout manager
|
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int { // Set movement flags based on the layout manager
|
||||||
|
|
|
@ -28,12 +28,23 @@
|
||||||
android:layout_alignBottom="@+id/automation_enabled"
|
android:layout_alignBottom="@+id/automation_enabled"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_toStartOf="@+id/iconSort"
|
android:layout_toStartOf="@+id/iconTrash"
|
||||||
android:layout_toEndOf="@id/automation_enabled"
|
android:layout_toEndOf="@id/automation_enabled"
|
||||||
android:text="Title"
|
android:text="Title"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iconTrash"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_toStartOf="@+id/iconSort"
|
||||||
|
android:contentDescription="@string/remove_label"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:src="@drawable/ic_trash_outline" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iconSort"
|
android:id="@+id/iconSort"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Loading…
Reference in a new issue