use of android.support.v4.util.ArraySet in project apps-android-wikipedia by wikimedia.
the class SharedPreferenceCookieManager method put.
@Override
public synchronized void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException {
// pre-condition check
if (uri == null || responseHeaders == null) {
throw new IllegalArgumentException("Argument is null");
}
ArraySet<String> domainsModified = new ArraySet<>();
for (String headerKey : responseHeaders.keySet()) {
if (headerKey == null || !headerKey.equalsIgnoreCase("Set-Cookie")) {
continue;
}
for (String headerValue : responseHeaders.get(headerKey)) {
try {
List<HttpCookie> cookies = HttpCookie.parse(headerValue);
for (HttpCookie cookie : cookies) {
// Default to the URI's domain if domain is not explicitly set
String domainSpec = cookie.getDomain() == null ? uri.getAuthority() : cookie.getDomain();
if (!cookieJar.containsKey(domainSpec)) {
cookieJar.put(domainSpec, new HashMap<String, String>());
}
if (cookie.hasExpired() || "deleted".equals(cookie.getValue())) {
cookieJar.get(domainSpec).remove(cookie.getName());
} else {
cookieJar.get(domainSpec).put(cookie.getName(), cookie.getValue());
}
domainsModified.add(domainSpec);
}
} catch (IllegalArgumentException e) {
// invalid set-cookie header string
// no-op
}
}
}
Prefs.setCookieDomains(makeString(cookieJar.keySet()));
for (String domain : domainsModified) {
Prefs.setCookiesForDomain(domain, makeString(makeCookieList(cookieJar.get(domain))));
}
}
use of android.support.v4.util.ArraySet in project android_packages_apps_Dialer by LineageOS.
the class ConferenceParticipantListAdapter method updateParticipantInfo.
/**
* Updates the participant info list which is bound to the ListView. Stores the call and contact
* info for all entries. The list is sorted alphabetically by participant name.
*
* @param conferenceParticipants The calls which make up the conference participants.
*/
private void updateParticipantInfo(List<DialerCall> conferenceParticipants) {
final ContactInfoCache cache = ContactInfoCache.getInstance(getContext());
boolean newParticipantAdded = false;
Set<String> newCallIds = new ArraySet<>(conferenceParticipants.size());
// Update or add conference participant info.
for (DialerCall call : conferenceParticipants) {
String callId = call.getId();
newCallIds.add(callId);
ContactCacheEntry contactCache = cache.getInfo(callId);
if (contactCache == null) {
contactCache = ContactInfoCache.buildCacheEntryFromCall(getContext(), call, call.getState() == DialerCall.State.INCOMING);
}
if (mParticipantsByCallId.containsKey(callId)) {
ParticipantInfo participantInfo = mParticipantsByCallId.get(callId);
participantInfo.setCall(call);
participantInfo.setContactCacheEntry(contactCache);
} else {
newParticipantAdded = true;
ParticipantInfo participantInfo = new ParticipantInfo(call, contactCache);
mConferenceParticipants.add(participantInfo);
mParticipantsByCallId.put(call.getId(), participantInfo);
}
}
// Remove any participants that no longer exist.
Iterator<Map.Entry<String, ParticipantInfo>> it = mParticipantsByCallId.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, ParticipantInfo> entry = it.next();
String existingCallId = entry.getKey();
if (!newCallIds.contains(existingCallId)) {
ParticipantInfo existingInfo = entry.getValue();
mConferenceParticipants.remove(existingInfo);
it.remove();
}
}
if (newParticipantAdded) {
// Sort the list of participants by contact name.
sortParticipantList();
}
notifyDataSetChanged();
}
use of android.support.v4.util.ArraySet in project ForPDA by RadiationX.
the class NotificationsService method saveEvents.
private void saveEvents(List<NotificationEvent> loadedEvents, 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 = new ArraySet<>();
for (NotificationEvent event : loadedEvents) {
savedEvents.add(event.getSourceEventText());
}
App.get().getPreferences().edit().putStringSet(prefKey, savedEvents).apply();
}
use of android.support.v4.util.ArraySet in project mobile-messaging-sdk-android by infobip.
the class GeoReportHelper method createReports.
/**
* Generates set of geofencing reports
*
* @param context context
* @param signalingMessage original signaling message
* @param areas list of areas that triggered this geofencing event
* @param event transition type
* @return set of geofencing reports to send to server
*/
private static Set<GeoReport> createReports(Context context, Message signalingMessage, List<Area> areas, @NonNull GeoEventType event, @NonNull GeoLatLng triggeringLocation) {
Set<GeoReport> reports = new ArraySet<>();
for (Area area : areas) {
GeoReport report = createReport(signalingMessage, area, event, triggeringLocation);
reports.add(report);
MobileMessagingCore.getInstance(context).addGeneratedMessageIds(report.getMessageId());
}
return reports;
}
use of android.support.v4.util.ArraySet in project mobile-messaging-sdk-android by infobip.
the class GeoTransitionHelper method resolveTransitionFromIntent.
/**
* Resolves transition information from geofencing intent
*
* @param intent geofencing intent
* @return transition information
* @throws RuntimeException if information cannot be resolved
*/
static GeoTransition resolveTransitionFromIntent(Intent intent) throws RuntimeException {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent == null) {
throw new RuntimeException("Geofencing event is null, cannot process");
}
if (geofencingEvent.hasError()) {
if (geofencingEvent.getErrorCode() == GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE) {
throw new GeofenceNotAvailableException();
}
throw new RuntimeException("ERROR: " + GeofenceStatusCodes.getStatusCodeString(geofencingEvent.getErrorCode()));
}
GeoEventType event = supportedTransitionEvents.get(geofencingEvent.getGeofenceTransition());
if (event == null) {
throw new RuntimeException("Transition is not supported: " + geofencingEvent.getGeofenceTransition());
}
Set<String> triggeringRequestIds = new ArraySet<>();
for (Geofence geofence : geofencingEvent.getTriggeringGeofences()) {
triggeringRequestIds.add(geofence.getRequestId());
}
Location location = geofencingEvent.getTriggeringLocation();
return new GeoTransition(event, triggeringRequestIds, new GeoLatLng(location.getLatitude(), location.getLongitude()));
}
Aggregations