ImaginAR/ImaginAR-master/app/src/main/java/com/vesit/imaginar/one/DemoUtils.java
/**
     * Creates and shows a Toast containing an error message. If there was an exception passed in it
     * will be appended to the toast. The error will also be written to the Log
     */
Creates and shows a Toast containing an error message. If there was an exception passed in it
will be appended to the toast. The error will also be written to the Log
Creates and shows a Toast containing an error message . If there was an exception passed in it will be appended to the toast . The error will also be written to the Log
public static void displayError(
            final Context context, final String errorMsg, @Nullable final Throwable problem) {
        final String tag = context.getClass().getSimpleName();
        final String toastText;
        if (problem != null && problem.getMessage() != null) {
            Log.e(tag, errorMsg, problem);
            toastText = errorMsg + ": " + problem.getMessage();
        } else if (problem != null) {
            Log.e(tag, errorMsg, problem);
            toastText = errorMsg;
        } else {
            Log.e(tag, errorMsg);
            toastText = errorMsg;
        }
        new Handler(Looper.getMainLooper())
                .post(
                        () -> {
                            Toast toast = Toast.makeText(context, toastText, Toast.LENGTH_LONG);
                            toast.setGravity(Gravity.CENTER, 0, 0);
                            toast.show();
                        });
    }
public static void displayError ( final Context context , final String errorMsg , @ Nullable final Throwable problem ) { final String tag = context . getClass ( ) . getSimpleName ( ) ; final String toastText ; if ( problem != null && problem . getMessage ( ) != null ) { Log . e ( tag , errorMsg , problem ) ; toastText = errorMsg + ": " + problem . getMessage ( ) ; } else if ( problem != null ) { Log . e ( tag , errorMsg , problem ) ; toastText = errorMsg ; } else { Log . e ( tag , errorMsg ) ; toastText = errorMsg ; } new Handler ( Looper . getMainLooper ( ) ) . post ( ( ) -> { Toast toast = Toast . makeText ( context , toastText , Toast . LENGTH_LONG ) ; toast . setGravity ( Gravity . CENTER , 0 , 0 ) ; toast . show ( ) ; } ) ; }
Creates and shows a Toast containing an error message.
Creates and shows a Toast containing an error message .