项目:android_packages_apps_tv
文件:SetupUtils.java
private SetupUtils(TvApplication tvApplication) {
mTvApplication = tvApplication;
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(tvApplication);
mSetUpInputs = new ArraySet<>();
mSetUpInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_SET_UP_INPUTS,Collections.emptySet()));
mKNownInputs = new ArraySet<>();
mKNownInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_KNowN_INPUTS,Collections.emptySet()));
mRecognizedInputs = new ArraySet<>();
mRecognizedInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_RECOGNIZED_INPUTS,mKNownInputs));
mIsFirstTune = mSharedPreferences.getBoolean(PREF_KEY_IS_FirsT_TUNE,true);
mTunerInputId = TvContract.buildInputId(new ComponentName(tvApplication,TunerTvInputService.class));
}
项目:UseCases
文件:GenericRecyclerViewAdapter.java
@SuppressWarnings(UNUSED)
public void appendWithoutDuplicateIds(List<ItemInfo> itemInfoList) {
validateList(itemInfoList);
if (android.os.Build.VERSION.SDK_INT >= M) {
ArraySet<ItemInfo> arraySet = new ArraySet<>();
arraySet.addAll(itemInfoList);
itemInfoList.clear();
itemInfoList.addAll(arraySet);
} else {
Set<ItemInfo> set = new HashSet<>(itemInfoList);
itemInfoList.clear();
itemInfoList.addAll(set);
}
mDataList.addAll(itemInfoList);
ArrayList<Long> finalList = new ArrayList<>();
ItemInfo item;
for (int i = 0; i < mDataList.size(); i++) {
item = mDataList.get(i);
if (finalList.contains(item.getId())) {
mDataList.remove(item);
} else {
finalList.add(item.getId());
}
}
notifyDataSetChanged();
}
项目:OpenYOLO-Android
文件:CollectionConverter.java
@NonNull
private static <T> Set<T> createSet(int size) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return new ArraySet<>(size);
} else {
return new HashSet<>();
}
}
项目:zonebeacon
文件:ZoneBeaconRobolectricSuite.java
@SuppressLint("NewApi")
@After
public void resetwindowManager() throws Exception {
// https://github.com/robolectric/robolectric/pull/1741
final Class<?> btclass = Class.forName("com.android.internal.os.BackgroundThread");
Object backgroundThreadSingleton = ReflectionHelpers.getStaticField(btclass,"sInstance");
if (backgroundThreadSingleton!=null) {
btclass.getmethod("quit").invoke(backgroundThreadSingleton);
ReflectionHelpers.setStaticField(btclass,"sInstance",null);
ReflectionHelpers.setStaticField(btclass,"sHandler",null);
}
// https://github.com/robolectric/robolectric/issues/2068
Class clazz = ReflectionHelpers.loadClass(getClass().getClassLoader(),"android.view.WindowManagerGlobal");
Object instance = ReflectionHelpers.callStaticmethod(clazz,"getInstance");
// We essentially duplicate what's in {@link WindowManagerGlobal#closeAll} with what's below.
// The closeAll method has a bit of a bug where it's iterating through the "roots" but
// bases the number of objects to iterate through by the number of "views." This can result in
// an {@link java.lang.indexoutofboundsexception} being thrown.
Object lock = ReflectionHelpers.getField(instance,"mlock");
ArrayList<Object> roots = ReflectionHelpers.getField(instance,"mRoots");
//noinspection SynchronizationonlocalVariableOrMethodParameter
synchronized (lock) {
for (int i = 0; i < roots.size(); i++) {
ReflectionHelpers.callInstanceMethod(instance,"removeViewLocked",ReflectionHelpers.Classparameter.from(int.class,i),ReflectionHelpers.Classparameter.from(boolean.class,false));
}
}
// Views will still be held by this array. We need to clear it out to ensure
// everything is released.
ArraySet<View> dyingViews = ReflectionHelpers.getField(instance,"mDyingViews");
dyingViews.clear();
}
项目:android_packages_apps_tv
文件:MultiLongSparseArray.java
private Set<T> getEmptySet() {
if (mEmptyIndex < 0) {
return new ArraySet<>();
}
Set<T> emptySet = mEmptySets[mEmptyIndex];
mEmptySets[mEmptyIndex--] = null;
return emptySet;
}
项目:DownloadManager
文件:ArrayUtils.java
public static <T> ArraySet<T> add(ArraySet<T> cur,T val) {
if (cur == null) {
cur = new ArraySet<>();
}
cur.add(val);
return cur;
}
项目:DownloadManager
文件:ArrayUtils.java
public static <T> ArraySet<T> remove(ArraySet<T> cur,T val) {
if (cur == null) {
return null;
}
cur.remove(val);
if (cur.isEmpty()) {
return null;
} else {
return cur;
}
}
项目:j2objc
文件:Sets.java
/**
* Creates a {@code ArraySet} instance containing the given elements.
*/
public static <E> ArraySet<E> newArraySet(E... elements) {
int capacity = elements.length * 4 / 3 + 1;
ArraySet<E> set = new ArraySet<E>(capacity);
Collections.addAll(set,elements);
return set;
}
项目:android-AutofillFramework
文件:SharedPrefsAutofillRepository.java
private Set<String> getAllAutofillDataStringSet(Context context) {
return context.getApplicationContext()
.getSharedPreferences(SHARED_PREF_KEY,Context.MODE_PRIVATE)
.getStringSet(CLIENT_FORM_DATA_KEY,new ArraySet<String>());
}
项目:DownloadManager
文件:ArrayUtils.java
public static <T> boolean contains(ArraySet<T> cur,T val) {
return (cur != null) ? cur.contains(val) : false;
}
项目:j2objc
文件:Sets.java
/**
* Creates a {@code ArraySet} instance.
*/
public static <E> ArraySet<E> newArraySet() {
return new ArraySet<E>();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。