Search in sources :

Example 36 with Nullable

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);
}
Also used : JobCreator(com.evernote.android.job.JobCreator) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) JobRequest(com.evernote.android.job.JobRequest) WorkInfo(androidx.work.WorkInfo) NonNull(androidx.annotation.NonNull) Job(com.evernote.android.job.Job) Nullable(androidx.annotation.Nullable) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 37 with Nullable

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;
}
Also used : PowerManager(android.os.PowerManager) Nullable(androidx.annotation.Nullable)

Example 38 with Nullable

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;
}
Also used : TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable)

Example 39 with Nullable

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);
}
Also used : Context(android.content.Context) JSONObject(org.json.JSONObject) Bundle(android.os.Bundle) Nullable(androidx.annotation.Nullable)

Example 40 with Nullable

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);
}
Also used : Bundle(android.os.Bundle) ProcessedBundleResult(com.onesignal.NotificationBundleProcessor.ProcessedBundleResult) 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