Update getOwnersForDomain usage to SortedSet
From API feedback, the return type of this method was updated. Migrating was fairly simple. Bug: 184891031 Test: manual, launch settings screen on device Change-Id: Ic159093b5d3f592de0b3533cf26bf0c878e06a30
This commit is contained in:
@@ -44,6 +44,7 @@ import com.android.settingslib.utils.ThreadUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
|
||||
/** A customized {@link InstrumentedDialogFragment} with a progress bar. */
|
||||
public class ProgressDialogFragment extends InstrumentedDialogFragment {
|
||||
@@ -146,9 +147,9 @@ public class ProgressDialogFragment extends InstrumentedDialogFragment {
|
||||
int index = 0;
|
||||
mSupportedLinkWrapperList = new ArrayList<>();
|
||||
for (String host : links) {
|
||||
final List<DomainOwner> ownerList =
|
||||
final SortedSet<DomainOwner> ownerSet =
|
||||
mDomainVerificationManager.getOwnersForDomain(host);
|
||||
mSupportedLinkWrapperList.add(new SupportedLinkWrapper(getActivity(), host, ownerList));
|
||||
mSupportedLinkWrapperList.add(new SupportedLinkWrapper(getActivity(), host, ownerSet));
|
||||
index++;
|
||||
// The cancel was clicked while progressing to collect data.
|
||||
if (!mProgressAlertDialog.isShowing()) {
|
||||
@@ -167,7 +168,7 @@ public class ProgressDialogFragment extends InstrumentedDialogFragment {
|
||||
mProgressAlertDialog.getProgressBar().setProgress(progress);
|
||||
}
|
||||
});
|
||||
if (ownerList.size() == 0) {
|
||||
if (ownerSet.size() == 0) {
|
||||
SystemClock.sleep(PROGRESS_BAR_STEPPING_TIME);
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.util.Log;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -34,14 +35,14 @@ public class SupportedLinkWrapper implements Comparable {
|
||||
private static final String TAG = "SupportedLinkWrapper";
|
||||
|
||||
private String mHost;
|
||||
private List<DomainOwner> mOwnerList;
|
||||
private SortedSet<DomainOwner> mOwnerSet;
|
||||
private boolean mIsEnabled;
|
||||
private String mLastOwnerName;
|
||||
private boolean mIsChecked;
|
||||
|
||||
public SupportedLinkWrapper(Context context, String host, List<DomainOwner> ownerList) {
|
||||
public SupportedLinkWrapper(Context context, String host, SortedSet<DomainOwner> ownerSet) {
|
||||
mHost = host;
|
||||
mOwnerList = ownerList;
|
||||
mOwnerSet = ownerSet;
|
||||
mIsEnabled = true;
|
||||
mLastOwnerName = "";
|
||||
mIsChecked = false;
|
||||
@@ -49,8 +50,8 @@ public class SupportedLinkWrapper implements Comparable {
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
if (mOwnerList.size() > 0) {
|
||||
final long nonOverirideableNo = mOwnerList.stream()
|
||||
if (mOwnerSet.size() > 0) {
|
||||
final long nonOverirideableNo = mOwnerSet.stream()
|
||||
.filter(it -> !it.isOverrideable())
|
||||
.count();
|
||||
mIsEnabled = (nonOverirideableNo == 0L);
|
||||
@@ -63,7 +64,7 @@ public class SupportedLinkWrapper implements Comparable {
|
||||
}
|
||||
|
||||
private String getLastPackageLabel(Context context, boolean isOverrideable) {
|
||||
final List<String> labelList = mOwnerList.stream()
|
||||
final List<String> labelList = mOwnerSet.stream()
|
||||
.filter(it -> it.isOverrideable() == isOverrideable)
|
||||
.map(it -> getLabel(context, it.getPackageName()))
|
||||
.filter(label -> label != null)
|
||||
|
Reference in New Issue
Block a user