Introduce snackbar for toast messages (#352)

Merge branch 'master' into 302-snackbar

Added snackbar to login screen

Co-authored-by: 6543 <6543@noreply.gitea.io>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/352
This commit is contained in:
M M Arif
2020-04-04 19:19:44 +00:00
parent 36ebfff529
commit c402046699
5 changed files with 104 additions and 49 deletions

View File

@@ -0,0 +1,63 @@
package org.mian.gitnex.helpers;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import com.google.android.material.snackbar.Snackbar;
import org.mian.gitnex.R;
/**
* Author M M Arif
*/
public class SnackBar {
public static void info(Context context, View createRepository, String message) {
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text);
textView.setTextColor(context.getResources().getColor(R.color.lightBlue));
snackBar.show();
}
public static void success(Context context, View createRepository, String message) {
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text);
textView.setTextColor(context.getResources().getColor(R.color.white));
snackBar.show();
}
public static void warning(Context context, View createRepository, String message) {
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text);
textView.setTextColor(context.getResources().getColor(R.color.lightYellow));
snackBar.show();
}
public static void error(Context context, View createRepository, String message) {
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text);
textView.setTextColor(context.getResources().getColor(R.color.darkRed));
snackBar.show();
}
}