Last active
December 4, 2019 22:19
-
-
Save ketzalv/9b1ad0d8f5a8b488c53e97a98235664a to your computer and use it in GitHub Desktop.
A simple class that list the methods to show messages in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.view.View; | |
import android.widget.Toast; | |
import com.google.android.material.snackbar.Snackbar; | |
public class UiUtils { | |
public static void showToast(String message, Context context) { | |
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); | |
} | |
public static void showSnackBar(View coordinatorLayout, String message, String actionName, View.OnClickListener listener) { | |
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG).setAction(actionName, listener).show(); | |
} | |
public static void showSnackBar(View coordinatorLayout, String message) { | |
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG).show(); | |
} | |
public static void showSnackBar(View coordinatorLayout, String message, String actionName, int duration, View.OnClickListener listener) { | |
Snackbar.make(coordinatorLayout, message, duration).setAction(actionName, listener).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment