mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix view util methods to always execute on UI thread (#1728)
This commit is contained in:
parent
7b5b9169db
commit
5cfe709281
1 changed files with 10 additions and 3 deletions
|
|
@ -15,12 +15,19 @@ public class ViewUtil {
|
||||||
public static final String SHOWCASE_VIEW_ID_3 = "SHOWCASE_VIEW_ID_3";
|
public static final String SHOWCASE_VIEW_ID_3 = "SHOWCASE_VIEW_ID_3";
|
||||||
|
|
||||||
public static void showSnackbar(View view, int messageResourceId) {
|
public static void showSnackbar(View view, int messageResourceId) {
|
||||||
Snackbar.make(view, messageResourceId, Snackbar.LENGTH_SHORT).show();
|
if(view.getContext() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecutorUtils.uiExecutor().execute(() -> Snackbar.make(view, messageResourceId, Snackbar.LENGTH_SHORT).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showLongToast(Context context, String text) {
|
public static void showLongToast(Context context, String text) {
|
||||||
Toast.makeText(context, text,
|
if (context == null) {
|
||||||
Toast.LENGTH_LONG).show();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecutorUtils.uiExecutor().execute(() -> Toast.makeText(context, text, Toast.LENGTH_LONG).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPortrait(Context context) {
|
public static boolean isPortrait(Context context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue