public class AppsDiffUtil extends DiffUtil.Callback {
private final List<AppsItem> oldList;
private final List<AppsItem> newList;
public AppsDiffUtil(List<AppsItem> oldList, List<AppsItem> newList) {
this.oldList = oldList;
this.newList = newList;
}
@Override
public int getOldListSize() {
return oldList.size();
}
@Override
public int getNewListSize() {
return newList.size();
}
@Override
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
AppsItem oldAppsItem = oldList.get(oldItemPosition);
AppsItem newAppsItem = newList.get(newItemPosition);
return oldAppsItem.getPackageName().equals(newAppsItem.getPackageName());
}
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
AppsItem oldAppsItem = oldList.get(oldItemPosition);
AppsItem newAppsItem = newList.get(newItemPosition);
return oldAppsItem.getName().equals(newAppsItem.getName())
&& oldAppsItem.getPackageName().equals(newAppsItem.getPackageName())
&& oldAppsItem.getDate() == newAppsItem.getDate()
&& oldAppsItem.getSize() == newAppsItem.getSize()
&& oldAppsItem.isChecked() == newAppsItem.isChecked()
&& oldAppsItem.getTotalTimeForeground() == newAppsItem.getTotalTimeForeground();
}
Моя цель -это вывести пользователю статистику, а именно сколько каждое приложение потребляет энергии.