Java Code Examples for android.support.design.widget.Snackbar#setText()

The following examples show how to use android.support.design.widget.Snackbar#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShadowSnackbar.java    From fyber_mobile_offers with MIT License 5 votes vote down vote up
@Implementation
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, int duration) {
    Snackbar snackbar = null;

    try {
        Constructor<Snackbar> constructor = Snackbar.class.getDeclaredConstructor(ViewGroup.class);

        //just in case, maybe they'll change the method signature in the future
        if (null == constructor)
            throw new IllegalArgumentException("Seems like the constructor was not found!");


        if (Modifier.isPrivate(constructor.getModifiers())) {
            constructor.setAccessible(true);
        }

        snackbar = constructor.newInstance(findSuitableParent(view));
        snackbar.setText(text);
        snackbar.setDuration(duration);
    } catch (Exception e) {
        e.printStackTrace();
    }

    shadowOf(snackbar).text = text.toString();

    shadowSnackbars.add(shadowOf(snackbar));

    return snackbar;
}
 
Example 2
Source File: MyElectricMainFragment.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void showMessage(String message) {
    isMessage = true;
    if (myElectricSettings != null) {
        Log.d("me", "showing message " + myElectricSettings.getName() + " - " + message);
    }
    Snackbar snackbar = getSnackbar();
    if (snackbar != null) {
        snackbar.setText(message);
        if (isVisibleInPager) {
            getSnackbar().show();
        }
    }
}
 
Example 3
Source File: MyElectricMainFragment.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void showMessage(int message) {
    isMessage = true;
    if (myElectricSettings != null) {
        Log.d("me", "showing message " + myElectricSettings.getName() + " - " + message);
    }

    Snackbar snackbar = getSnackbar();
    if (snackbar != null) {
        snackbar.setText(message);
        if (isVisibleInPager) {
            getSnackbar().show();
        }
    }
}