Bugfixes. Add remove icon for actions.
This commit is contained in:
parent
c6766c972c
commit
236349a063
4 changed files with 52 additions and 24 deletions
|
@ -63,6 +63,7 @@ public class AutomationEvent {
|
|||
trigger = Trigger.instantiate(d.getString("trigger"));
|
||||
// actions
|
||||
JSONArray array = d.getJSONArray("actions");
|
||||
actions.clear();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
actions.add(Action.instantiate(new JSONObject(array.getString(i))));
|
||||
}
|
||||
|
|
|
@ -131,13 +131,13 @@ public class AutomationFragment extends SubscriberFragment {
|
|||
addImage(res, holder.context, holder.iconLayout);
|
||||
}
|
||||
|
||||
// action: remove
|
||||
// remove event
|
||||
holder.iconTrash.setOnClickListener(v -> {
|
||||
mEventList.remove(event);
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
|
||||
// action: edit
|
||||
// edit event
|
||||
holder.rootLayout.setOnClickListener(v -> {
|
||||
EditEventDialog dialog = EditEventDialog.newInstance(event, false);
|
||||
dialog.show(mFragmentManager, "EditEventDialog");
|
||||
|
@ -168,7 +168,7 @@ public class AutomationFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
/**
|
||||
* RecyclerViewAdapter to display event lists.
|
||||
* RecyclerViewAdapter to display action lists.
|
||||
*/
|
||||
public static class ActionListAdapter extends RecyclerView.Adapter<ActionListAdapter.ViewHolder> {
|
||||
private final List<Action> mActionList;
|
||||
|
@ -190,12 +190,16 @@ public class AutomationFragment extends SubscriberFragment {
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
final Action action = mActionList.get(position);
|
||||
holder.actionTitle.setText(action.friendlyName());
|
||||
holder.itemRoot.setOnClickListener(v -> {
|
||||
holder.layoutText.setOnClickListener(v -> {
|
||||
if (action.hasDialog()) {
|
||||
EditActionDialog dialog = EditActionDialog.newInstance(action);
|
||||
dialog.show(mFragmentManager, "EditActionDialog");
|
||||
}
|
||||
});
|
||||
holder.iconTrash.setOnClickListener(v -> {
|
||||
mActionList.remove(action);
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,13 +210,15 @@ public class AutomationFragment extends SubscriberFragment {
|
|||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView actionTitle;
|
||||
TextView actionDescription;
|
||||
LinearLayout itemRoot;
|
||||
LinearLayout layoutText;
|
||||
ImageView iconTrash;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
itemRoot = view.findViewById(R.id.itemRoot);
|
||||
layoutText = view.findViewById(R.id.layoutText);
|
||||
actionTitle = view.findViewById(R.id.viewActionTitle);
|
||||
actionDescription = view.findViewById(R.id.viewActionDescription);
|
||||
iconTrash = view.findViewById(R.id.iconTrash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ public class TriggerConnector extends Trigger {
|
|||
JSONObject d = new JSONObject(data);
|
||||
connectorType = Type.valueOf(JsonHelper.safeGetString(d, "connectorType"));
|
||||
JSONArray array = d.getJSONArray("triggerList");
|
||||
list.clear();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
Trigger newItem = instantiate(new JSONObject(array.getString(i)));
|
||||
add(newItem);
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/itemRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/ribbonDefault"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iconTrash"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_trash_outline"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/ribbonDefault">
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/iconTrash"
|
||||
android:layout_alignParentLeft="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/viewActionTitle"
|
||||
|
@ -29,4 +46,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue