use of androidx.annotation.Nullable in project android-job by evernote.
the class PlatformWorkManagerTest method testExecution.
@Test
public void testExecution() {
final AtomicBoolean executed = new AtomicBoolean(false);
final Job job = new Job() {
@NonNull
@Override
protected Result onRunJob(@NonNull Params params) {
executed.set(true);
return Result.SUCCESS;
}
};
mWorkManagerRule.getManager().addJobCreator(new JobCreator() {
@Nullable
@Override
public Job create(@NonNull String tag) {
if (tag.equals(TAG)) {
return job;
} else {
return null;
}
}
});
int jobId = new JobRequest.Builder(TAG).setExecutionWindow(TimeUnit.HOURS.toMillis(4), TimeUnit.HOURS.toMillis(5)).build().schedule();
String tag = JobProxyWorkManager.createTag(jobId);
mWorkManagerRule.runJob(tag);
WorkInfo.State state = mWorkManagerRule.getWorkStatus(tag).get(0).getState();
assertThat(executed.get()).isTrue();
assertThat(state).isEqualTo(WorkInfo.State.SUCCEEDED);
}
use of androidx.annotation.Nullable in project android-job by evernote.
the class WakeLockUtil method acquireWakeLock.
@SuppressWarnings("SameParameterValue")
@Nullable
static PowerManager.WakeLock acquireWakeLock(@NonNull Context context, @NonNull String tag, long timeoutMillis) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag);
wakeLock.setReferenceCounted(false);
return acquireWakeLock(context, wakeLock, timeoutMillis) ? wakeLock : null;
}
use of androidx.annotation.Nullable in project PagerBottomTabStrip by tyzlmjj.
the class AFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
String content = getArguments().getString(ARG_C);
TextView textView = new TextView(getContext());
textView.setTextSize(30);
textView.setGravity(Gravity.CENTER);
textView.setText(String.format("Test\n\n%s", content));
textView.setBackgroundColor(0xFFececec);
return textView;
}
use of androidx.annotation.Nullable in project OneSignal-Android-SDK by OneSignal.
the class ADMMessageHandler method onMessage.
@Override
protected void onMessage(Intent intent) {
final Context context = getApplicationContext();
final Bundle bundle = intent.getExtras();
NotificationBundleProcessor.ProcessBundleReceiverCallback bundleReceiverCallback = new NotificationBundleProcessor.ProcessBundleReceiverCallback() {
@Override
public void onBundleProcessed(@Nullable NotificationBundleProcessor.ProcessedBundleResult processedResult) {
if (processedResult.processed())
return;
JSONObject payload = NotificationBundleProcessor.bundleAsJSONObject(bundle);
OSNotification notification = new OSNotification(payload);
OSNotificationGenerationJob notificationJob = new OSNotificationGenerationJob(context);
notificationJob.setJsonPayload(payload);
notificationJob.setContext(context);
notificationJob.setNotification(notification);
NotificationBundleProcessor.processJobForDisplay(notificationJob, true);
}
};
NotificationBundleProcessor.processBundleFromReceiver(context, bundle, bundleReceiverCallback);
}
use of androidx.annotation.Nullable in project OneSignal-Android-SDK by OneSignal.
the class FCMBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
// Do not process token update messages here.
// They are also non-ordered broadcasts.
Bundle bundle = intent.getExtras();
if (bundle == null || "google.com/iid".equals(bundle.getString("from")))
return;
OneSignal.initWithContext(context);
NotificationBundleProcessor.ProcessBundleReceiverCallback bundleReceiverCallback = new NotificationBundleProcessor.ProcessBundleReceiverCallback() {
@Override
public void onBundleProcessed(@Nullable ProcessedBundleResult processedResult) {
// Null means this isn't a FCM message
if (processedResult == null) {
setSuccessfulResultCode();
return;
}
// 2. OR work manager is processing the notification
if (processedResult.isDup() || processedResult.isWorkManagerProcessing()) {
// Abort to prevent other FCM receivers from process this Intent.
setAbort();
return;
}
setSuccessfulResultCode();
}
};
processOrderBroadcast(context, intent, bundle, bundleReceiverCallback);
}
Aggregations