Skip to content

Commit

Permalink
Add some @nonnull annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Caryl committed Mar 15, 2017
1 parent 4676f6f commit 4c8398f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions shortbread/src/main/java/shortbread/Shortbread.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.pm.ShortcutManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
Expand Down Expand Up @@ -38,7 +39,7 @@ public final class Shortbread {
* @param context Any context, the implementation will use the application context.
*/
@TargetApi(25)
public static void create(Context context) {
public static void create(@NonNull Context context) {
if (Build.VERSION.SDK_INT < 25) {
return;
}
Expand Down Expand Up @@ -71,7 +72,7 @@ public static void create(Context context) {
}

@RequiresApi(25)
private static void setShortcuts(Context context) {
private static void setShortcuts(@NonNull Context context) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);

if (createShortcuts == null) {
Expand Down Expand Up @@ -100,7 +101,7 @@ private static void setShortcuts(Context context) {
}

@RequiresApi(14)
private static void setActivityLifecycleCallbacks(Context applicationContext) {
private static void setActivityLifecycleCallbacks(@NonNull Context applicationContext) {
((Application) applicationContext).registerActivityLifecycleCallbacks(new SimpleActivityLifecycleCallbacks() {

@Override
Expand All @@ -112,7 +113,7 @@ public void onActivityCreated(final Activity activity, final Bundle savedInstanc
activityLifecycleCallbacksSet = true;
}

private static void callMethodShortcut(Activity activity) {
private static void callMethodShortcut(@NonNull Activity activity) {
if (callMethodShortcut == null || !activity.getIntent().hasExtra("shortbread_method")) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion shortbread/src/main/java/shortbread/ShortcutUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;

class ShortcutUtils {

static CharSequence getActivityLabel(Context context, Class<? extends Activity> cls) {
static CharSequence getActivityLabel(@NonNull Context context, @NonNull Class<? extends Activity> cls) {
PackageManager packageManager = context.getPackageManager();
try {
return packageManager.getActivityInfo(new ComponentName(context, cls), 0).loadLabel(packageManager);
Expand Down

0 comments on commit 4c8398f

Please sign in to comment.