Replace LinkedHashSet with List

This commit is contained in:
Alex Sytnyk 2018-07-31 13:54:20 +03:00
parent b9b4f55e48
commit 5139c9fe5a
4 changed files with 12 additions and 18 deletions

View file

@ -5,31 +5,29 @@ import android.os.Parcelable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
public class AddNavDrawerItemsParams implements Parcelable { public class AddNavDrawerItemsParams implements Parcelable {
private String appPackage; private String appPackage;
private LinkedHashSet<NavDrawerItem> items; private List<NavDrawerItem> items;
public AddNavDrawerItemsParams(@NonNull String appPackage, @NonNull LinkedHashSet<NavDrawerItem> items) { public AddNavDrawerItemsParams(@NonNull String appPackage, @NonNull List<NavDrawerItem> items) {
this.appPackage = appPackage; this.appPackage = appPackage;
this.items = items; this.items = items;
} }
protected AddNavDrawerItemsParams(Parcel in) { protected AddNavDrawerItemsParams(Parcel in) {
appPackage = in.readString(); appPackage = in.readString();
List<NavDrawerItem> list = new ArrayList<>(); items = new ArrayList<>();
in.readTypedList(list, NavDrawerItem.CREATOR); in.readTypedList(items, NavDrawerItem.CREATOR);
items = new LinkedHashSet<>(list);
} }
public String getAppPackage() { public String getAppPackage() {
return appPackage; return appPackage;
} }
public LinkedHashSet<NavDrawerItem> getItems() { public List<NavDrawerItem> getItems() {
return items; return items;
} }

View file

@ -43,7 +43,6 @@ import net.osmand.aidl.note.StopRecordingParams
import net.osmand.aidl.note.TakePhotoNoteParams import net.osmand.aidl.note.TakePhotoNoteParams
import java.io.File import java.io.File
import java.util.* import java.util.*
import kotlin.collections.LinkedHashSet
class OsmandAidlHelper(private val app: Application) { class OsmandAidlHelper(private val app: Application) {
@ -873,7 +872,7 @@ class OsmandAidlHelper(private val app: Application) {
fun addOpenAppNavDrawerItem(appPackage: String, names: List<String>, uris: List<String>, iconNames: List<String>, flags: List<Int>): Boolean { fun addOpenAppNavDrawerItem(appPackage: String, names: List<String>, uris: List<String>, iconNames: List<String>, flags: List<Int>): Boolean {
if (mIOsmAndAidlInterface != null) { if (mIOsmAndAidlInterface != null) {
try { try {
val items = LinkedHashSet<NavDrawerItem>() val items = mutableListOf<NavDrawerItem>()
for (i in names.indices) { for (i in names.indices) {
items.add(NavDrawerItem(names[i], uris[i], iconNames[i], flags[i])) items.add(NavDrawerItem(names[i], uris[i], iconNames[i], flags[i]))
} }

View file

@ -77,7 +77,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -1201,7 +1200,7 @@ public class OsmandAidlApi {
return true; return true;
} }
boolean addNavDrawerItems(String appPackage, Set<net.osmand.aidl.navdrawer.NavDrawerItem> items) { boolean addNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
if (!TextUtils.isEmpty(appPackage) && items != null && !items.isEmpty()) { if (!TextUtils.isEmpty(appPackage) && items != null && !items.isEmpty()) {
List<NavDrawerItem> existing = getNavDrawerItems(); List<NavDrawerItem> existing = getNavDrawerItems();
for (Iterator<NavDrawerItem> it = existing.iterator(); it.hasNext(); ) { for (Iterator<NavDrawerItem> it = existing.iterator(); it.hasNext(); ) {

View file

@ -5,31 +5,29 @@ import android.os.Parcelable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
public class AddNavDrawerItemsParams implements Parcelable { public class AddNavDrawerItemsParams implements Parcelable {
private String appPackage; private String appPackage;
private LinkedHashSet<NavDrawerItem> items; private List<NavDrawerItem> items;
public AddNavDrawerItemsParams(@NonNull String appPackage, @NonNull LinkedHashSet<NavDrawerItem> items) { public AddNavDrawerItemsParams(@NonNull String appPackage, @NonNull List<NavDrawerItem> items) {
this.appPackage = appPackage; this.appPackage = appPackage;
this.items = items; this.items = items;
} }
protected AddNavDrawerItemsParams(Parcel in) { protected AddNavDrawerItemsParams(Parcel in) {
appPackage = in.readString(); appPackage = in.readString();
List<NavDrawerItem> list = new ArrayList<>(); items = new ArrayList<>();
in.readTypedList(list, NavDrawerItem.CREATOR); in.readTypedList(items, NavDrawerItem.CREATOR);
items = new LinkedHashSet<>(list);
} }
public String getAppPackage() { public String getAppPackage() {
return appPackage; return appPackage;
} }
public LinkedHashSet<NavDrawerItem> getItems() { public List<NavDrawerItem> getItems() {
return items; return items;
} }