Search in sources :

Example 1 with ArraySet

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))));
    }
}
Also used : ArraySet(android.support.v4.util.ArraySet) HttpCookie(java.net.HttpCookie)

Example 2 with ArraySet

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();
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ArraySet(android.util.ArraySet) DialerCall(com.android.incallui.call.DialerCall) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map)

Example 3 with ArraySet

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();
}
Also used : ArraySet(android.support.v4.util.ArraySet) NotificationEvent(forpdateam.ru.forpda.api.events.models.NotificationEvent)

Example 4 with ArraySet

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;
}
Also used : Area(org.infobip.mobile.messaging.geo.Area) ArraySet(android.support.v4.util.ArraySet)

Example 5 with ArraySet

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()));
}
Also used : ArraySet(android.support.v4.util.ArraySet) GeoLatLng(org.infobip.mobile.messaging.geo.GeoLatLng) GeoEventType(org.infobip.mobile.messaging.geo.GeoEventType) GeofencingEvent(com.google.android.gms.location.GeofencingEvent) Geofence(com.google.android.gms.location.Geofence) Location(android.location.Location)

Aggregations

ArraySet (android.support.v4.util.ArraySet)6 Intent (android.content.Intent)1 ProviderInfo (android.content.pm.ProviderInfo)1 Location (android.location.Location)1 NonNull (android.support.annotation.NonNull)1 ArrayMap (android.support.v4.util.ArrayMap)1 ArraySet (android.util.ArraySet)1 ContactCacheEntry (com.android.incallui.ContactInfoCache.ContactCacheEntry)1 DialerCall (com.android.incallui.call.DialerCall)1 Predicate (com.android.internal.util.Predicate)1 Geofence (com.google.android.gms.location.Geofence)1 GeofencingEvent (com.google.android.gms.location.GeofencingEvent)1 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)1 NotificationEvent (forpdateam.ru.forpda.api.events.models.NotificationEvent)1 Field (java.lang.reflect.Field)1 HttpCookie (java.net.HttpCookie)1 List (java.util.List)1 Map (java.util.Map)1 Area (org.infobip.mobile.messaging.geo.Area)1 GeoEventType (org.infobip.mobile.messaging.geo.GeoEventType)1