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