Проектная работа N2. Цабут Ян#3
Conversation
SeveNChaK
left a comment
There was a problem hiding this comment.
В некоторых файлах, где были внесены изменения, немного едет код, стоит отрефакторить. Если ты используешь IDE от JetBrains, то можешь пройтись по всем нужным файлам и нажать комбинацию (Windows: Shift + Ctrl + Alt + L, MacOS: Shift + Option + Command + L), затем выбрать какую часть кода хочешь изменить и выполнить команду. Среда разработки автоматически сделает нужные отступы и переносы (как она это делает можно изменить в настройках, но дефолтные значения вполне нормальные).
| public static String[] getContactTypes() { | ||
| // метод должен возвращать массив строк, перечисленных выше | ||
| String[] contacts = {TELEGRAM, WHATS_APP, VIBER, SIGNAL, THREEMA, PHONE, EMAIL}; | ||
| return contacts; |
There was a problem hiding this comment.
⏫ Можно сразу вернуть return new String[]{TELEGRAM, WHATS_APP, VIBER, SIGNAL, THREEMA, PHONE, EMAIL};
| import androidx.recyclerview.widget.DiffUtil; | ||
|
|
||
| public class BaseListDiffCallback <T extends ListDiffInterface<T>> extends DiffUtil.ItemCallback<T> { | ||
| public BaseListDiffCallback() { |
There was a problem hiding this comment.
⏫ Так как конструктор пустой, можно убрать его описание отсюда
|
|
||
| @Override | ||
| public boolean areContentsTheSame(@NonNull T oldItem, @NonNull T newItem) { | ||
| return false; |
There was a problem hiding this comment.
oldItem.equals(newItem);
| @Nullable | ||
| @Override | ||
| public Object getChangePayload(@NonNull T oldItem, @NonNull T newItem) { | ||
| return super.getChangePayload(oldItem, newItem); |
There was a problem hiding this comment.
return newItem
| package ru.yandex.practicum.contacts.presentation.base; | ||
|
|
||
| public interface ListDiffInterface<T> { | ||
| boolean theSameAs(ListDiffInterface<T> listDiffInterface); |
There was a problem hiding this comment.
T. Поэтому необходимо правильно описать метод: boolean theSameAs(T listDiffInterface);
|
|
||
| @Override | ||
| public boolean theSameAs(ListDiffInterface<FilterContactTypeUi> listDiffInterface) { | ||
| return this.getContactType() == ((FilterContactTypeUi) listDiffInterface).getContactType(); |
There was a problem hiding this comment.
return this.getContactType() == listDiffInterface.getContactType();
| private final String phone; | ||
| private final String photo; | ||
| private final List<String> types; | ||
| private final List<ContactType> types; |
There was a problem hiding this comment.
⏫ ContactType содержит в себе существующие типы в строковом виде. Так что здесь по смыслу должен быть список строк, как и было изначально.
|
|
||
| @Override | ||
| public boolean theSameAs(ListDiffInterface<ContactUi> listDiffInterface) { | ||
| return this.hashCode() == ((ContactUi)listDiffInterface).hashCode(); |
There was a problem hiding this comment.
return this.hashCode() == listDiffInterface.hashCode();
| @Override | ||
| @Override | ||
| public boolean theSameAs(ListDiffInterface<SortTypeUI> listDiffInterface) { | ||
| return this.getSortType() == ((SortTypeUI)listDiffInterface).getSortType(); |
There was a problem hiding this comment.
return this.getSortType() == listDiffInterface.getSortType();
No description provided.