From fff53929f0864595c2c4a1e3288d5fcfea01ec22 Mon Sep 17 00:00:00 2001 From: arpit-tbs Date: Thu, 27 Apr 2017 11:09:17 +0530 Subject: [PATCH] added delete Entity button added a button from which user can delete the text entity. --- .../team/uptech/motionviews/ui/MainActivity.java | 13 +++++++++++++ .../team/uptech/motionviews/widget/MotionView.java | 7 +++++++ app/src/main/res/drawable-anydpi/ic_mode_delete.xml | 9 +++++++++ app/src/main/res/layout/activity_main.xml | 8 ++++++++ 4 files changed, 37 insertions(+) create mode 100644 app/src/main/res/drawable-anydpi/ic_mode_delete.xml diff --git a/app/src/main/java/team/uptech/motionviews/ui/MainActivity.java b/app/src/main/java/team/uptech/motionviews/ui/MainActivity.java index d230d88..643a7ab 100644 --- a/app/src/main/java/team/uptech/motionviews/ui/MainActivity.java +++ b/app/src/main/java/team/uptech/motionviews/ui/MainActivity.java @@ -116,6 +116,19 @@ public void onClick(View view) { startTextEntityEditing(); } }); + findViewById(R.id.text_entity_delete).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + deleteTextEntity(); + } + }); + } + + private void deleteTextEntity() { + TextEntity textEntity = currentTextEntity(); + if (textEntity != null) { + motionView.deleteEntity(textEntity); + } } private void increaseTextEntitySize() { diff --git a/app/src/main/java/team/uptech/motionviews/widget/MotionView.java b/app/src/main/java/team/uptech/motionviews/widget/MotionView.java index 128477f..474adbf 100644 --- a/app/src/main/java/team/uptech/motionviews/widget/MotionView.java +++ b/app/src/main/java/team/uptech/motionviews/widget/MotionView.java @@ -123,6 +123,13 @@ public void addEntity(@Nullable MotionEntity entity) { } } + public void deleteEntity(@Nullable MotionEntity entity) { + if (entity != null) { + entities.remove(entity); + selectEntity(null, true); + } + } + public void addEntityAndPosition(@Nullable MotionEntity entity) { if (entity != null) { initEntityBorder(entity); diff --git a/app/src/main/res/drawable-anydpi/ic_mode_delete.xml b/app/src/main/res/drawable-anydpi/ic_mode_delete.xml new file mode 100644 index 0000000..1c71461 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_mode_delete.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index d9b1683..8908974 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -59,6 +59,14 @@ android:src="@drawable/ic_mode_edit" /> + +