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;
}
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);
}
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;
}
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);
}
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);
}
Aggregations