Search in sources :

Example 51 with NonNull

use of androidx.annotation.NonNull in project android-job by evernote.

the class JobCanceledTest method verifyOnCancelNotInvokedWhenFinished.

@Test
public void verifyOnCancelNotInvokedWhenFinished() {
    final AtomicInteger onCancelCalled = new AtomicInteger(0);
    final Job job = new Job() {

        @NonNull
        @Override
        protected Result onRunJob(@NonNull Params params) {
            return Result.SUCCESS;
        }

        @Override
        protected void onCancel() {
            onCancelCalled.incrementAndGet();
        }
    };
    manager().addJobCreator(new JobCreator() {

        @Override
        public Job create(@NonNull String tag) {
            return job;
        }
    });
    final String tag = "something";
    final int jobId = new JobRequest.Builder(tag).setExecutionWindow(200_000L, 400_000L).build().schedule();
    executeJob(jobId, Job.Result.SUCCESS);
    job.cancel();
    assertThat(manager().getAllJobRequestsForTag(tag)).isEmpty();
    assertThat(manager().getJobRequest(jobId)).isNull();
    assertThat(manager().getJobRequest(jobId, true)).isNull();
    assertThat(job.isCanceled()).isFalse();
    assertThat(onCancelCalled.get()).isEqualTo(0);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NonNull(androidx.annotation.NonNull) Test(org.junit.Test)

Example 52 with NonNull

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

the class NotificationBundleProcessor method bundleAsJSONObject.

@NonNull
static JSONObject bundleAsJSONObject(Bundle bundle) {
    JSONObject json = new JSONObject();
    Set<String> keys = bundle.keySet();
    for (String key : keys) {
        try {
            json.put(key, bundle.get(key));
        } catch (JSONException e) {
            OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "bundleAsJSONObject error for key: " + key, e);
        }
    }
    return json;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) NonNull(androidx.annotation.NonNull)

Example 53 with NonNull

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

the class InAppMessageRecyclerViewAdapter method onCreateViewHolder.

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View view = layoutInflater.inflate(R.layout.main_in_app_messages_recycler_view_item_layout, parent, false);
    view.setHasTransientState(true);
    return new InAppMessageViewHolder(view);
}
Also used : ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 54 with NonNull

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

the class PairRecyclerViewAdapter method onCreateViewHolder.

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int position) {
    View view = layoutInflater.inflate(R.layout.pair_recycler_view_item_layout, parent, false);
    view.setHasTransientState(true);
    return new PairViewHolder(view);
}
Also used : TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 55 with NonNull

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

the class OSViewUtils method getWindowVisibleDisplayFrame.

@NonNull
private static Rect getWindowVisibleDisplayFrame(@NonNull Activity activity) {
    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    return rect;
}
Also used : Rect(android.graphics.Rect) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1197 View (android.view.View)191 ArrayList (java.util.ArrayList)154 Context (android.content.Context)128 Nullable (androidx.annotation.Nullable)128 TextView (android.widget.TextView)117 Intent (android.content.Intent)115 List (java.util.List)110 Recipient (org.thoughtcrime.securesms.recipients.Recipient)109 IOException (java.io.IOException)103 Bundle (android.os.Bundle)102 WorkerThread (androidx.annotation.WorkerThread)94 LayoutInflater (android.view.LayoutInflater)89 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)82 AlertDialog (androidx.appcompat.app.AlertDialog)76 Log (org.signal.core.util.logging.Log)76 Cursor (android.database.Cursor)68 ViewGroup (android.view.ViewGroup)65 LinkedList (java.util.LinkedList)64 Stream (com.annimon.stream.Stream)62