From 13efa377b70fd36afd6ffcef298c11bed48a0100 Mon Sep 17 00:00:00 2001 From: Vyacheslav Litvinov Date: Sun, 21 Jan 2024 18:28:51 +0200 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/ContactsOrderTypeUi.java | 23 +++++++++++++++++++ .../filter/model/FilterContactTypeUi.java | 16 +++++-------- .../presentation/sort/SortTypeUI.java | 17 ++++---------- 3 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 app/src/main/java/ru/yandex/practicum/contacts/presentation/base/ContactsOrderTypeUi.java diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/base/ContactsOrderTypeUi.java b/app/src/main/java/ru/yandex/practicum/contacts/presentation/base/ContactsOrderTypeUi.java new file mode 100644 index 0000000..249f545 --- /dev/null +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/base/ContactsOrderTypeUi.java @@ -0,0 +1,23 @@ +package ru.yandex.practicum.contacts.presentation.base; + +import androidx.annotation.NonNull; + +abstract public class ContactsOrderTypeUi { + protected final String type; + protected final boolean isSelected; + + public ContactsOrderTypeUi(@NonNull String type, boolean isSelected) { + this.type = type; + this.isSelected = isSelected; + } + + public String getType() { + return type; + } + + public boolean isSelected() { + return isSelected; + } + + public abstract String createLogMessage(); +} diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/filter/model/FilterContactTypeUi.java b/app/src/main/java/ru/yandex/practicum/contacts/presentation/filter/model/FilterContactTypeUi.java index c4648b5..51ecd2c 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/filter/model/FilterContactTypeUi.java +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/filter/model/FilterContactTypeUi.java @@ -2,22 +2,17 @@ import androidx.annotation.NonNull; -public class FilterContactTypeUi { +import ru.yandex.practicum.contacts.presentation.base.ContactsOrderTypeUi; - private final String type; - private final boolean isSelected; +public class FilterContactTypeUi extends ContactsOrderTypeUi { public FilterContactTypeUi(@NonNull String type, boolean isSelected) { - this.type = type; - this.isSelected = isSelected; - } - - public String getType() { - return type; + super(type,isSelected); } + @Override public boolean isSelected() { - return isSelected; + return super.isSelected(); } public String createLogMessage() { @@ -42,3 +37,4 @@ public int hashCode() { return result; } } + diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/sort/SortTypeUI.java b/app/src/main/java/ru/yandex/practicum/contacts/presentation/sort/SortTypeUI.java index 2cb7c54..7aaadc5 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/sort/SortTypeUI.java +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/sort/SortTypeUI.java @@ -2,24 +2,15 @@ import androidx.annotation.NonNull; -public class SortTypeUI { +import ru.yandex.practicum.contacts.presentation.base.ContactsOrderTypeUi; - private final String type; - private final boolean isSelected; +public class SortTypeUI extends ContactsOrderTypeUi { public SortTypeUI(@NonNull String type, boolean isSelected) { - this.type = type; - this.isSelected = isSelected; - } - - public String getType() { - return type; - } - - public boolean isSelected() { - return isSelected; + super(type, isSelected); } + @Override public String createLogMessage() { return "Выбран тип сортировки: " + type; }