use of android.support.annotation.NonNull in project material-components-android by material-components.
the class Snackbar method setText.
/**
* Update the text in this {@link Snackbar}.
*
* @param message The new text for this {@link BaseTransientBottomBar}.
*/
@NonNull
public Snackbar setText(@NonNull CharSequence message) {
final SnackbarContentLayout contentLayout = (SnackbarContentLayout) mView.getChildAt(0);
final TextView tv = contentLayout.getMessageView();
tv.setText(message);
return this;
}
use of android.support.annotation.NonNull in project material-components-android by material-components.
the class Snackbar method make.
/**
* Make a Snackbar to display a message
*
* <p>Snackbar will try and find a parent view to hold Snackbar's view from the value given to
* {@code view}. Snackbar will walk up the view tree trying to find a suitable parent, which is
* defined as a {@link CoordinatorLayout} or the window decor's content view, whichever comes
* first.
*
* <p>Having a {@link CoordinatorLayout} in your view hierarchy allows Snackbar to enable certain
* features, such as swipe-to-dismiss and automatically moving of widgets like {@link
* FloatingActionButton}.
*
* @param view The view to find a parent from.
* @param text The text to show. Can be formatted text.
* @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link
* #LENGTH_LONG}
*/
@NonNull
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, @Duration int duration) {
final ViewGroup parent = findSuitableParent(view);
if (parent == null) {
throw new IllegalArgumentException("No suitable parent found from the given view. Please provide a valid view.");
}
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final SnackbarContentLayout content = (SnackbarContentLayout) inflater.inflate(R.layout.design_layout_snackbar_include, parent, false);
final Snackbar snackbar = new Snackbar(parent, content, content);
snackbar.setText(text);
snackbar.setDuration(duration);
return snackbar;
}
use of android.support.annotation.NonNull in project material-components-android by material-components.
the class Snackbar method setActionTextColor.
/**
* Sets the text color of the action specified in {@link #setAction(CharSequence,
* View.OnClickListener)}.
*/
@NonNull
public Snackbar setActionTextColor(@ColorInt int color) {
final SnackbarContentLayout contentLayout = (SnackbarContentLayout) mView.getChildAt(0);
final TextView tv = contentLayout.getActionView();
tv.setTextColor(color);
return this;
}
use of android.support.annotation.NonNull in project flow by square.
the class Installer method install.
@NonNull
public Context install() {
if (InternalLifecycleIntegration.find(activity) != null) {
throw new IllegalStateException("Flow is already installed in this Activity.");
}
Dispatcher dispatcher = this.dispatcher;
if (dispatcher == null) {
dispatcher = //
KeyDispatcher.configure(activity, new DefaultKeyChanger(activity)).build();
}
final Object defState = defaultKey == null ? "Hello, World!" : defaultKey;
final History defaultHistory = History.single(defState);
final Application app = (Application) baseContext.getApplicationContext();
final KeyManager keyManager = new KeyManager(contextFactories);
InternalLifecycleIntegration.install(app, activity, parceler, defaultHistory, dispatcher, keyManager);
return new InternalContextWrapper(baseContext, activity);
}
use of android.support.annotation.NonNull in project sqlbrite by square.
the class NewItemFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
View view = LayoutInflater.from(context).inflate(R.layout.new_item, null);
EditText name = findById(view, android.R.id.input);
Observable.combineLatest(createClicked, RxTextView.textChanges(name), new Func2<String, CharSequence, String>() {
@Override
public String call(String ignored, CharSequence text) {
return text.toString();
}
}).observeOn(Schedulers.io()).subscribe(new Action1<String>() {
@Override
public void call(String description) {
db.insert(TodoItem.TABLE, new TodoItem.Builder().listId(getListId()).description(description).build());
}
});
return //
new AlertDialog.Builder(context).setTitle(R.string.new_item).setView(view).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createClicked.onNext("clicked");
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(@NonNull DialogInterface dialog, int which) {
}
}).create();
}
Aggregations