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