@@ -580,31 +580,53 @@ public static String getData(InputStream inputStream) {
580580 // region snackbar
581581 public static void showSnackMessage (Fragment fragment , @ StringRes int messageResource ) {
582582 if (fragment == null ) {
583+ Log_OC .e (TAG , "snackbar cannot be shown fragment is null" );
583584 return ;
584585 }
585586
586587 final var activity = fragment .getActivity ();
587588 if (activity == null ) {
589+ Log_OC .e (TAG , "snackbar cannot be shown activity is null" );
588590 return ;
589591 }
590592
591593 showSnackMessage (activity , messageResource );
592594 }
593595
594596 public static void showSnackMessage (Activity activity , @ StringRes int messageResource ) {
597+ if (activity == null ) {
598+ Log_OC .e (TAG , "snackbar cannot be shown activity is null" );
599+ return ;
600+ }
601+
595602 showSnackMessage (activity .findViewById (android .R .id .content ), messageResource );
596603 }
597604
598605 public static void showSnackMessage (Activity activity , @ StringRes int messageResource , Object ... formatArgs ) {
606+ if (activity == null ) {
607+ Log_OC .e (TAG , "snackbar cannot be shown activity is null" );
608+ return ;
609+ }
610+
599611 showSnackMessage (activity , activity .findViewById (android .R .id .content ), messageResource , formatArgs );
600612 }
601613
602614 public static void showSnackMessage (Context context , View view , @ StringRes int messageResource , Object ... formatArgs ) {
615+ if (context == null || view == null ) {
616+ Log_OC .e (TAG , "snackbar cannot be shown view is null" );
617+ return ;
618+ }
619+
603620 final var snackbar = Snackbar .make (view , String .format (context .getString (messageResource , formatArgs )), Snackbar .LENGTH_LONG );
604621 snackbar .show ();
605622 }
606623
607624 public static void showSnackMessage (Activity activity , String message ) {
625+ if (activity == null ) {
626+ Log_OC .e (TAG , "snackbar cannot be shown activity is null" );
627+ return ;
628+ }
629+
608630 activity .runOnUiThread (() -> {
609631 final var snackbar = Snackbar .make (activity .findViewById (android .R .id .content ), message , Snackbar .LENGTH_LONG );
610632 var fab = findFABView (activity );
@@ -616,6 +638,11 @@ public static void showSnackMessage(Activity activity, String message) {
616638 }
617639
618640 public static void showSnackMessage (View view , @ StringRes int messageResource ) {
641+ if (view == null ) {
642+ Log_OC .e (TAG , "snackbar cannot be shown view is null" );
643+ return ;
644+ }
645+
619646 mainLooper .post (() -> {
620647 final var snackbar = Snackbar .make (view , messageResource , Snackbar .LENGTH_LONG );
621648 var fab = findFABView (view .getRootView ());
@@ -627,6 +654,11 @@ public static void showSnackMessage(View view, @StringRes int messageResource) {
627654 }
628655
629656 public static void showSnackMessage (View view , String message ) {
657+ if (view == null ) {
658+ Log_OC .e (TAG , "snackbar cannot be shown view is null" );
659+ return ;
660+ }
661+
630662 mainLooper .post (() -> {
631663 final Snackbar snackbar = Snackbar .make (view , message , Snackbar .LENGTH_LONG );
632664 snackbar .show ();
0 commit comments