Search in sources :

Example 41 with Nullable

use of androidx.annotation.Nullable in project OneSignal-Android-SDK by OneSignal.

the class OneSignalPrefs method get.

// If type == Object then this is a contains check
@Nullable
private static Object get(String prefsName, String key, Class type, Object defValue) {
    HashMap<String, Object> pref = prefsToApply.get(prefsName);
    synchronized (pref) {
        if (type.equals(Object.class) && pref.containsKey(key))
            return true;
        Object cachedValue = pref.get(key);
        if (cachedValue != null || pref.containsKey(key))
            return cachedValue;
    }
    SharedPreferences prefs = getSharedPrefsByName(prefsName);
    if (prefs != null) {
        if (type.equals(String.class))
            return prefs.getString(key, (String) defValue);
        else if (type.equals(Boolean.class))
            return prefs.getBoolean(key, (Boolean) defValue);
        else if (type.equals(Integer.class))
            return prefs.getInt(key, (Integer) defValue);
        else if (type.equals(Long.class))
            return prefs.getLong(key, (Long) defValue);
        else if (type.equals(Set.class))
            return prefs.getStringSet(key, (Set<String>) defValue);
        else if (type.equals(Object.class))
            return prefs.contains(key);
        return null;
    }
    return defValue;
}
Also used : Set(java.util.Set) SharedPreferences(android.content.SharedPreferences) Nullable(androidx.annotation.Nullable)

Example 42 with Nullable

use of androidx.annotation.Nullable in project OneSignal-Android-SDK by OneSignal.

the class TestHelpers method getJob.

@Nullable
private static JobInfo getJob(int index) {
    JobScheduler jobScheduler = (JobScheduler) ApplicationProvider.getApplicationContext().getSystemService(Context.JOB_SCHEDULER_SERVICE);
    List<JobInfo> jobs = jobScheduler.getAllPendingJobs();
    if (jobs.size() == 0 || jobs.size() <= index)
        return null;
    else
        return jobs.get(index);
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) Nullable(androidx.annotation.Nullable)

Example 43 with Nullable

use of androidx.annotation.Nullable in project OneSignal-Android-SDK by OneSignal.

the class GenerateNotificationRunner method postNotificationWithOptionalGroup.

@Nullable
private Bundle postNotificationWithOptionalGroup(int notifCount, @Nullable String group) {
    Bundle bundle = null;
    for (int i = 0; i < notifCount; i++) {
        bundle = getBaseNotifBundle("UUID" + i);
        bundle.putString("grp", group);
        NotificationBundleProcessor_ProcessFromFCMIntentService(blankActivity, bundle);
    }
    return bundle;
}
Also used : Bundle(android.os.Bundle) FCMBroadcastReceiver_processBundle(com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_processBundle) OneSignalPackagePrivateHelper.createInternalPayloadBundle(com.onesignal.OneSignalPackagePrivateHelper.createInternalPayloadBundle) Nullable(androidx.annotation.Nullable)

Example 44 with Nullable

use of androidx.annotation.Nullable in project robolectric by robolectric.

the class ShadowLauncherApps method getShortcuts.

/**
 * This method is an incomplete implementation of this API that only supports querying for pinned
 * dynamic shortcuts. It also doesn't not support {@link ShortcutQuery#setChangedSince(long)}.
 */
@Implementation(minSdk = N_MR1)
@Nullable
protected List<ShortcutInfo> getShortcuts(@NonNull ShortcutQuery query, @NonNull UserHandle user) {
    if (reflector(ReflectorShortcutQuery.class, query).getChangedSince() != 0) {
        throw new UnsupportedOperationException("Robolectric does not currently support ShortcutQueries that filter on time since" + " change.");
    }
    int flags = reflector(ReflectorShortcutQuery.class, query).getQueryFlags();
    if ((flags & ShortcutQuery.FLAG_MATCH_PINNED) == 0 || (flags & ShortcutQuery.FLAG_MATCH_DYNAMIC) == 0) {
        throw new UnsupportedOperationException("Robolectric does not currently support ShortcutQueries that match non-dynamic" + " Shortcuts.");
    }
    Iterable<ShortcutInfo> shortcutsItr = shortcuts;
    List<String> ids = reflector(ReflectorShortcutQuery.class, query).getShortcutIds();
    if (ids != null) {
        shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> ids.contains(shortcut.getId()));
    }
    ComponentName activity = reflector(ReflectorShortcutQuery.class, query).getActivity();
    if (activity != null) {
        shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> shortcut.getActivity().equals(activity));
    }
    String packageName = reflector(ReflectorShortcutQuery.class, query).getPackage();
    if (packageName != null && !packageName.isEmpty()) {
        shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> shortcut.getPackage().equals(packageName));
    }
    return Lists.newArrayList(shortcutsItr);
}
Also used : Rect(android.graphics.Rect) Iterables(com.google.common.collect.Iterables) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Pair(android.util.Pair) Multimap(com.google.common.collect.Multimap) Process(android.os.Process) LOLLIPOP(android.os.Build.VERSION_CODES.LOLLIPOP) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) ArrayList(java.util.ArrayList) Implements(org.robolectric.annotation.Implements) IntentSender(android.content.IntentSender) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Accessor(org.robolectric.util.reflector.Accessor) ForType(org.robolectric.util.reflector.ForType) Handler(android.os.Handler) Looper(android.os.Looper) UserHandle(android.os.UserHandle) L(android.os.Build.VERSION_CODES.L) O(android.os.Build.VERSION_CODES.O) N(android.os.Build.VERSION_CODES.N) Executor(java.util.concurrent.Executor) Q(android.os.Build.VERSION_CODES.Q) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) Predicate(java.util.function.Predicate) P(android.os.Build.VERSION_CODES.P) Collectors(java.util.stream.Collectors) Implementation(org.robolectric.annotation.Implementation) SessionCallback(android.content.pm.PackageInstaller.SessionCallback) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) Nullable(androidx.annotation.Nullable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Reflector.reflector(org.robolectric.util.reflector.Reflector.reflector) ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery) N_MR1(android.os.Build.VERSION_CODES.N_MR1) ShortcutInfo(android.content.pm.ShortcutInfo) ComponentName(android.content.ComponentName) Implementation(org.robolectric.annotation.Implementation) Nullable(androidx.annotation.Nullable)

Example 45 with Nullable

use of androidx.annotation.Nullable in project robolectric by robolectric.

the class ShadowTelecomManager method allowOutgoingCall.

/**
 * Allows an {@link OutgoingCallRecord} created via {@link TelecomManager#placeCall}.
 *
 * <p>Specifically, this method sets up the relevant {@link ConnectionService} and returns the
 * result of {@link ConnectionService#onCreateOutgoingConnection}.
 */
@TargetApi(M)
@Nullable
public Connection allowOutgoingCall(OutgoingCallRecord call) {
    if (call.isHandled) {
        throw new IllegalStateException("Call has already been allowed or denied.");
    }
    call.isHandled = true;
    PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
    ConnectionRequest request = buildConnectionRequestForOutgoingCall(call);
    ConnectionService service = setupConnectionService(phoneAccount);
    return service.onCreateOutgoingConnection(phoneAccount, request);
}
Also used : ConnectionService(android.telecom.ConnectionService) ConnectionRequest(android.telecom.ConnectionRequest) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TargetApi(android.annotation.TargetApi) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1206 View (android.view.View)207 Bundle (android.os.Bundle)118 IOException (java.io.IOException)106 ArrayList (java.util.ArrayList)104 TextView (android.widget.TextView)102 NonNull (androidx.annotation.NonNull)101 Context (android.content.Context)95 Cursor (android.database.Cursor)78 SuppressLint (android.annotation.SuppressLint)74 Uri (android.net.Uri)69 RecyclerView (androidx.recyclerview.widget.RecyclerView)64 List (java.util.List)63 ViewGroup (android.view.ViewGroup)60 Intent (android.content.Intent)58 Test (org.junit.Test)55 Recipient (org.thoughtcrime.securesms.recipients.Recipient)52 LayoutInflater (android.view.LayoutInflater)48 R (org.thoughtcrime.securesms.R)46 ImageView (android.widget.ImageView)45