AppList : Remove duplicate search results due to ads

This commit is contained in:
Mr. Dragon
2019-07-31 00:10:20 +05:30
parent 05b55f0e15
commit 2fb655a74f
2 changed files with 18 additions and 0 deletions

View File

@@ -45,7 +45,9 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -95,6 +97,9 @@ public class InstalledAppsAdapter extends RecyclerView.Adapter<InstalledAppsAdap
public void addData(List<App> appList) {
this.appList.clear();
this.appList = appList;
final Set<App> appSet = new LinkedHashSet<>(appList);
appList.clear();
appList.addAll(appSet);
if (listType == ListType.INSTALLED || listType == ListType.UPDATES)
Collections.sort(appList, (App1, App2) ->
App1.getDisplayName().compareToIgnoreCase(App2.getDisplayName()));

View File

@@ -410,6 +410,19 @@ public class App implements Comparable<App> {
return getDisplayName().compareToIgnoreCase(o.getDisplayName());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof App))
return false;
return getPackageName().equals(((App) obj).getPackageName());
}
@Override
public int hashCode() {
return (getPackageName().isEmpty()) ? 0 : getPackageName().hashCode();
}
public enum Restriction {
GENERIC(-1),