use of android.support.design.widget.FloatingActionButton in project todo-mvp-rxjava by albertizzy.
the class TaskDetailFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.taskdetail_frag, container, false);
setHasOptionsMenu(true);
mDetailTitle = root.findViewById(R.id.task_detail_title);
mDetailDescription = root.findViewById(R.id.task_detail_description);
mDetailCompleteStatus = root.findViewById(R.id.task_detail_complete);
// Set up floating action button
FloatingActionButton fab = getActivity().findViewById(R.id.fab_edit_task);
fab.setOnClickListener(__ -> mPresenter.editTask());
return root;
}
use of android.support.design.widget.FloatingActionButton in project todo-mvp-rxjava by albertizzy.
the class TasksFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.tasks_frag, container, false);
// Set up tasks view
ListView listView = root.findViewById(R.id.tasks_list);
listView.setAdapter(mListAdapter);
mFilteringLabelView = root.findViewById(R.id.filteringLabel);
mTasksView = root.findViewById(R.id.tasksLL);
// Set up no tasks view
mNoTasksView = root.findViewById(R.id.noTasks);
mNoTaskIcon = root.findViewById(R.id.noTasksIcon);
mNoTaskMainView = root.findViewById(R.id.noTasksMain);
mNoTaskAddView = root.findViewById(R.id.noTasksAdd);
mNoTaskAddView.setOnClickListener(__ -> showAddTask());
// TODO lambda
// mNoTaskAddView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View __) {
// showAddTask();
// }
// });
// Set up floating action button
FloatingActionButton fab = getActivity().findViewById(R.id.fab_add_task);
fab.setImageResource(R.drawable.ic_add);
fab.setOnClickListener(__ -> mPresenter.addNewTask());
// TODO lambda
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View __) {
// mPresenter.addNewTask();
// }
// });
// Set up progress indicator
final ScrollChildSwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.refresh_layout);
swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getActivity(), R.color.colorPrimary), ContextCompat.getColor(getActivity(), R.color.colorAccent), ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
// Set the scrolling view in the custom SwipeRefreshLayout.
swipeRefreshLayout.setScrollUpChild(listView);
swipeRefreshLayout.setOnRefreshListener(() -> mPresenter.loadTasks(false));
// TODO lambda
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mPresenter.loadTasks(false);
// }
// });
setHasOptionsMenu(true);
return root;
}
use of android.support.design.widget.FloatingActionButton in project Shuttle by timusus.
the class TintHelper method setTintAuto.
@SuppressWarnings("deprecation")
@SuppressLint("PrivateResource")
static void setTintAuto(@NonNull final View view, @ColorInt final int color, boolean background, final boolean isDark) {
if (!background) {
if (view instanceof RadioButton) {
setTint((RadioButton) view, color, isDark);
} else if (view instanceof SeekBar) {
setTint((SeekBar) view, color, isDark);
} else if (view instanceof ProgressBar) {
setTint((ProgressBar) view, color);
} else if (view instanceof EditText) {
setTint((EditText) view, color, isDark);
} else if (view instanceof CheckBox) {
setTint((CheckBox) view, color, isDark);
} else if (view instanceof ImageView) {
setTint((ImageView) view, color);
} else if (view instanceof Switch) {
setTint((Switch) view, color, isDark);
} else if (view instanceof SwitchCompat) {
setTint((SwitchCompat) view, color, isDark);
} else {
background = true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !background && view.getBackground() instanceof RippleDrawable) {
// Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
RippleDrawable rd = (RippleDrawable) view.getBackground();
final int unchecked = ContextCompat.getColor(view.getContext(), isDark ? R.color.ripple_material_dark : R.color.ripple_material_light);
final int checked = Util.adjustAlpha(color, 0.4f);
final ColorStateList sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_activated, -android.R.attr.state_checked }, new int[] { android.R.attr.state_activated }, new int[] { android.R.attr.state_checked } }, new int[] { unchecked, checked, checked });
rd.setColor(sl);
}
}
if (background) {
// Need to tint the background of a view
if (view instanceof FloatingActionButton || view instanceof Button) {
setTintSelector(view, color, false, isDark);
} else if (view.getBackground() != null) {
Drawable drawable = view.getBackground();
if (drawable != null) {
if (view instanceof TextInputEditText) {
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
} else {
drawable = createTintedDrawable(drawable, color);
Util.setBackgroundCompat(view, drawable);
}
}
}
}
}
use of android.support.design.widget.FloatingActionButton in project Shuttle by timusus.
the class TintHelper method setTintSelector.
@SuppressWarnings("deprecation")
private static void setTintSelector(@NonNull View view, @ColorInt final int color, final boolean darker, final boolean useDarkTheme) {
final boolean isColorLight = Util.isColorLight(color);
final int disabled = ContextCompat.getColor(view.getContext(), useDarkTheme ? R.color.ate_button_disabled_dark : R.color.ate_button_disabled_light);
final int pressed = Util.shiftColor(color, darker ? 0.9f : 1.1f);
final int activated = Util.shiftColor(color, darker ? 1.1f : 0.9f);
final int rippleColor = getDefaultRippleColor(view.getContext(), isColorLight);
final int textColor = ContextCompat.getColor(view.getContext(), isColorLight ? R.color.ate_primary_text_light : R.color.ate_primary_text_dark);
final ColorStateList sl;
if (view instanceof Button) {
sl = getDisabledColorStateList(color, disabled);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view.getBackground() instanceof RippleDrawable) {
RippleDrawable rd = (RippleDrawable) view.getBackground();
rd.setColor(ColorStateList.valueOf(rippleColor));
}
// Disabled text color state for buttons, may get overridden later by ATE tags
final Button button = (Button) view;
button.setTextColor(getDisabledColorStateList(textColor, ContextCompat.getColor(view.getContext(), useDarkTheme ? R.color.ate_button_text_disabled_dark : R.color.ate_button_text_disabled_light)));
} else if (view instanceof FloatingActionButton) {
// FloatingActionButton doesn't support disabled state?
sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_pressed }, new int[] { android.R.attr.state_pressed } }, new int[] { color, pressed });
final FloatingActionButton fab = (FloatingActionButton) view;
fab.setRippleColor(rippleColor);
fab.setBackgroundTintList(sl);
if (fab.getDrawable() != null)
fab.setImageDrawable(createTintedDrawable(fab.getDrawable(), textColor));
return;
} else {
sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed }, new int[] { android.R.attr.state_enabled, android.R.attr.state_activated }, new int[] { android.R.attr.state_enabled, android.R.attr.state_checked } }, new int[] { disabled, color, pressed, activated, activated });
}
Drawable drawable = view.getBackground();
if (drawable != null) {
drawable = createTintedDrawable(drawable, sl);
Util.setBackgroundCompat(view, drawable);
}
if (view instanceof TextView && !(view instanceof Button)) {
final TextView tv = (TextView) view;
tv.setTextColor(getDisabledColorStateList(textColor, ContextCompat.getColor(view.getContext(), isColorLight ? R.color.ate_text_disabled_light : R.color.ate_text_disabled_dark)));
}
}
use of android.support.design.widget.FloatingActionButton in project react-native-navigation by wix.
the class FloatingActionButtonCoordinator method removeAllViews.
private void removeAllViews() {
parent.removeView(collapsedFab);
parent.removeView(expendedFab);
collapsedFab = null;
expendedFab = null;
for (FloatingActionButton action : actions) {
((CoordinatorLayout.LayoutParams) action.getLayoutParams()).setBehavior(null);
parent.removeView(action);
}
actions.clear();
}
Aggregations