Package org.daiitech.naftah.utils
Class ConsoleLoader
java.lang.Object
org.daiitech.naftah.utils.ConsoleLoader
Utility class for displaying a console-based loading spinner animation.
The spinner runs on a separate thread and can be started/stopped using static methods. It uses ANSI escape codes to clear the terminal screen for visual effect.
Example usage:
ConsoleLoader.startLoader("Loading...");
// do work
ConsoleLoader.stopLoader();
- Author:
- Chakib Daii
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ThreadBackground thread responsible for rendering the spinner animation.private static final char[]Characters used to animate the spinner. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstartLoader(String text) Starts the loader spinner in a separate thread.static voidStops the loader spinner if running and clears the screen.
-
Field Details
-
SPINNER
private static final char[] SPINNERCharacters used to animate the spinner. -
LOADER_THREAD
Background thread responsible for rendering the spinner animation.
-
-
Constructor Details
-
ConsoleLoader
private ConsoleLoader()Private constructor to prevent instantiation. Always throws aNaftahBugErrorwhen called.
-
-
Method Details
-
startLoader
Starts the loader spinner in a separate thread.- Parameters:
text- the message to display alongside the spinner
-
stopLoader
public static void stopLoader()Stops the loader spinner if running and clears the screen.
-