本文整理汇总了Java中android.support.v4.util.ArraySet类的典型用法代码示例。如果您正苦于以下问题:Java ArraySet类的具体用法?Java ArraySet怎么用?Java ArraySet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArraySet类属于android.support.v4.util包,在下文中一共展示了ArraySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelections
import android.support.v4.util.ArraySet; //导入依赖的package包/类
/**
* @return a set with the global positions of all selected items
*/
public Set<Integer> getSelections() {
if (mPositionBasedStateManagement) {
return mSelections;
} else {
Set<Integer> selections = new ArraySet<>();
Item item;
for (int i = 0, size = getItemCount(); i < size; i++) {
item = getItem(i);
if (item.isSelected()) {
selections.add(i);
}
}
return selections;
}
}
示例2: addOnSharedPreferenceListener
import android.support.v4.util.ArraySet; //导入依赖的package包/类
public void addOnSharedPreferenceListener(@NonNull OnSharedPreferenceListener listener, @NonNull String... preferenceKeysToListen) {
ArraySet<String> preferenceKeysListened = mSharedPreferenceListeners.get(listener);
// One listener can listen to multiple keys changes
if (preferenceKeysListened == null) {
preferenceKeysListened = new ArraySet<>();
}
for (String key : preferenceKeysToListen) {
if (key != null) { // varArgs accepts null values...
preferenceKeysListened.add(key);
}
}
mSharedPreferenceListeners.put(listener, preferenceKeysListened);
mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
示例3: removeOnSharedPreferenceListener
import android.support.v4.util.ArraySet; //导入依赖的package包/类
/**
* Stop listening for said preference keys for this listener
*
* @param listener the listener that stops listening these preference keys
* @param preferenceKeysToStopListening the keys to unregister from the listener
*/
public void removeOnSharedPreferenceListener(@NonNull OnSharedPreferenceListener listener, @NonNull String... preferenceKeysToStopListening) {
ArraySet<String> preferenceKeysListened = mSharedPreferenceListeners.get(listener);
if (preferenceKeysListened != null) {
for (String key : preferenceKeysToStopListening) {
if (key != null) {
preferenceKeysListened.remove(key);
}
}
if (preferenceKeysListened.isEmpty()) {
mSharedPreferenceListeners.remove(listener);
}
}
if (mSharedPreferenceListeners.isEmpty()) {
mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
}
}
示例4: onSharedPreferenceChanged
import android.support.v4.util.ArraySet; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
for (OnSharedPreferenceListener onSharedPreferenceListener : mSharedPreferenceListeners.keySet()) { // Check if every listener...
ArraySet<String> preferenceKeysListened = mSharedPreferenceListeners.get(onSharedPreferenceListener);
if (preferenceKeysListened != null) {
for (String preferenceKey : preferenceKeysListened) { // ... wants to listen to this key in particular
if (preferenceKey.equalsIgnoreCase(key)) {
onSharedPreferenceListener.onSharedPreferenceChanged(key, sharedPreferences.getAll().get(key));
break;
}
}
}
}
}
示例5: getListFile
import android.support.v4.util.ArraySet; //导入依赖的package包/类
public Set<File> getListFile() {
ArraySet<File> files = new android.support.v4.util.ArraySet<>();
try {
SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();
String query = "SELECT * FROM " + TABLE_FILE_TAB;
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
if (cursor.moveToFirst()) {
do {
String result = cursor.getString(cursor.getColumnIndex(KEY_FILE_PATH));
File file = new File(result);
if (file.isFile())
files.add(file);
else
removeFile(result);
} while (cursor.moveToNext());
}
cursor.close();
} catch (Exception ignored) {
}
return files;
}
示例6: checkPurchased
import android.support.v4.util.ArraySet; //导入依赖的package包/类
static Collection<String> checkPurchased(String tag, BigInteger modulus,
List<String> data, List<String> sigs) {
Collection<String> purchased = new ArraySet<>();
if (isEmpty(data) || isEmpty(sigs)) {
return purchased;
}
int size = data.size();
if (size > sigs.size()) {
size = sigs.size();
}
for (int i = 0; i < size; ++i) {
String datum = data.get(i);
if (verify(tag, modulus, datum, sigs.get(i))) {
checkProductId(purchased, tag, datum);
}
}
return purchased;
}
示例7: updateBrevent
import android.support.v4.util.ArraySet; //导入依赖的package包/类
private boolean updateBrevent(boolean brevent) {
AppsFragment fragment = getFragment();
Collection<String> selected = new ArraySet<>(fragment.getSelected());
if (brevent) {
Iterator it = selected.iterator();
while (it.hasNext()) {
if (mImportant.containsKey(it.next())) {
it.remove();
}
}
}
if (!selected.isEmpty()) {
BreventPackages breventPackages = new BreventPackages(brevent, selected);
breventPackages.undoable = true;
mHandler.obtainMessage(MESSAGE_BREVENT_REQUEST, breventPackages).sendToTarget();
}
clearSelected();
return false;
}
示例8: resolveGcmPackages
import android.support.v4.util.ArraySet; //导入依赖的package包/类
private void resolveGcmPackages(Set<String> packageNames) {
// gcm
List<PackageInfo> packageInfos = getPackageManager().getPackagesHoldingPermissions(
new String[] {"com.google.android.c2dm.permission.RECEIVE"}, 0);
if (packageInfos != null) {
Set<String> gcm = new ArraySet<>();
for (PackageInfo packageInfo : packageInfos) {
gcm.add(packageInfo.packageName);
}
gcm.retainAll(checkReceiver(new Intent("com.google.android.c2dm.intent.RECEIVE")));
packageNames.addAll(gcm);
}
if (Log.isLoggable(UILog.TAG, Log.DEBUG)) {
UILog.d("gcm: " + packageNames);
}
}
示例9: build
import android.support.v4.util.ArraySet; //导入依赖的package包/类
public SimpleImageSelector build() {
SimpleImageSelector simpleImageSelector = new SimpleImageSelector(activityWeakReference);
simpleImageSelector.needCrop = false;
if (itemTypes == null) {
itemTypes = new ArraySet<>();
itemTypes.add(SelectorItemType.CAMERA);
itemTypes.add(SelectorItemType.ALBUM);
itemTypes.add(SelectorItemType.CANCEL);
}
simpleImageSelector.itemTypes = itemTypes;
simpleImageSelector.photoPathCallback = photoPathCallback;
simpleImageSelector.selectorCallback = selectorCallback;
return simpleImageSelector.build();
}
示例10: getSavedEvents
import android.support.v4.util.ArraySet; //导入依赖的package包/类
private List<NotificationEvent> getSavedEvents(NotificationEvent.Source source) {
String prefKey = "";
if (NotificationEvent.fromQms(source)) {
prefKey = Preferences.Notifications.Data.QMS_EVENTS;
} else if (NotificationEvent.fromTheme(source)) {
prefKey = Preferences.Notifications.Data.FAVORITES_EVENTS;
}
Set<String> savedEvents = App.get().getPreferences().getStringSet(prefKey, new ArraySet<>());
StringBuilder responseBuilder = new StringBuilder();
for (String saved : savedEvents) {
responseBuilder.append(saved).append('\n');
}
String response = responseBuilder.toString();
if (NotificationEvent.fromQms(source)) {
return Api.UniversalEvents().getQmsEvents(response);
} else if (NotificationEvent.fromTheme(source)) {
return Api.UniversalEvents().getFavoritesEvents(response);
}
return new ArrayList<>();
}
示例11: cleanTimes
import android.support.v4.util.ArraySet; //导入依赖的package包/类
private void cleanTimes() {
Set<String> keys = new ArraySet<>();
keys.addAll(times.keySet());
LocalDate date = LocalDate.now();
int y = date.getYear();
int m = date.getMonthOfYear();
List<String> remove = new ArrayList<>();
for (String key : keys) {
if (key == null) continue;
int year = FastParser.parseInt(key.substring(0, 4));
if (year < y) keys.remove(key);
else if (year == y) {
int month = FastParser.parseInt(key.substring(5, 7));
if (month < m) remove.add(key);
}
}
times.removeAll(remove);
}
示例12: getAndUpdateInactiveCampaigns
import android.support.v4.util.ArraySet; //导入依赖的package包/类
/**
* Returns list of inactive campaign ids based on reporting result
*
* @param result response from the server
* @return set of inactive campaign ids
*/
public static Set<String> getAndUpdateInactiveCampaigns(Context context, GeoReportingResult result) {
Set<String> inactiveCampaigns = new ArraySet<>();
if (result == null || result.hasError()) {
inactiveCampaigns.addAll(GeofencingHelper.getSuspendedCampaignIds(context));
inactiveCampaigns.addAll(GeofencingHelper.getFinishedCampaignIds(context));
return inactiveCampaigns;
}
GeofencingHelper.addCampaignStatus(context, result.getFinishedCampaignIds(), result.getSuspendedCampaignIds());
if (result.getFinishedCampaignIds() != null) {
inactiveCampaigns.addAll(result.getFinishedCampaignIds());
}
if (result.getSuspendedCampaignIds() != null) {
inactiveCampaigns.addAll(result.getSuspendedCampaignIds());
}
return inactiveCampaigns;
}
示例13: adjustPosition
import android.support.v4.util.ArraySet; //导入依赖的package包/类
/**
* internal method to handle the selections if items are added / removed
*
* @param positions the positions map which should be adjusted
* @param startPosition the global index of the first element modified
* @param endPosition the global index up to which the modification changed the indices (should be MAX_INT if we check til the end)
* @param adjustBy the value by which the data was shifted
* @return the adjusted set
*/
public static Set<Integer> adjustPosition(Set<Integer> positions, int startPosition, int endPosition, int adjustBy) {
Set<Integer> newPositions = new ArraySet<>();
for (Integer entry : positions) {
int position = entry;
//if our current position is not within the bounds to check for we can add it
if (position < startPosition || position > endPosition) {
newPositions.add(position);
} else if (adjustBy > 0) {
//if we added items and we are within the bounds we can simply add the adjustBy to our entry
newPositions.add(position + adjustBy);
} else if (adjustBy < 0) {
//if we removed items and we are within the bounds we have to check if the item was removed
//adjustBy is negative in this case
if (position > startPosition + adjustBy && position <= startPosition) {
;//we are within the removed items range we don't add this item anymore
} else {
//otherwise we adjust our position
newPositions.add(position + adjustBy);
}
}
}
return newPositions;
}
示例14: getSelectedItems
import android.support.v4.util.ArraySet; //导入依赖的package包/类
/**
* @return a set with the items which are currently selected
*/
public Set<Item> getSelectedItems() {
Set<Integer> selections = getSelections();
Set<Item> items = new ArraySet<>(selections.size());
for (Integer position : selections) {
items.add(getItem(position));
}
return items;
}
示例15: FavoriteModel
import android.support.v4.util.ArraySet; //导入依赖的package包/类
public FavoriteModel(AppCompatActivity context) {
this.gson = new Gson();
this.favoritesType = new TypeToken<ArraySet<FavoriteModelItem>>() {}.getType();
this.context = context;
preferences = context.getSharedPreferences(context.getString(R.string.setting_name), MODE_PRIVATE);
loadFromSettings();
}