From 5e3a6135b7dca3f3f7af057ba8dcfee8fa252921 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 26 Feb 2018 18:38:31 +0200 Subject: [PATCH] Create BaseBottomSheetItem and SimpleBottomSheetItem --- .../bottomsheetmenu/BaseBottomSheetItem.java | 86 +++++++++++++ .../SimpleBottomSheetItem.java | 119 ++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java create mode 100644 OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java new file mode 100644 index 0000000000..0c8d18c3cd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java @@ -0,0 +1,86 @@ +package net.osmand.plus.base.bottomsheetmenu; + +import android.support.annotation.LayoutRes; +import android.view.View; + +public class BaseBottomSheetItem { + + private View customView; + @LayoutRes + private int layoutResId; + private boolean clickable = true; + private View.OnClickListener onClickListener; + private int position = -1; + + public BaseBottomSheetItem(View customView, + @LayoutRes int layoutResId, + boolean clickable, + View.OnClickListener onClickListener, + int position) { + this.customView = customView; + this.layoutResId = layoutResId; + this.clickable = clickable; + this.onClickListener = onClickListener; + this.position = position; + } + + public View getCustomView() { + return customView; + } + + @LayoutRes + public int getLayoutResId() { + return layoutResId; + } + + public boolean isClickable() { + return clickable; + } + + public View.OnClickListener getOnClickListener() { + return onClickListener; + } + + public int getPosition() { + return position; + } + + public static class Builder { + + protected View customView; + @LayoutRes + protected int layoutResId; + protected boolean clickable; + protected View.OnClickListener onClickListener; + protected int position; + + public Builder setCustomView(View customView) { + this.customView = customView; + return this; + } + + public Builder setLayoutResId(@LayoutRes int layoutResId) { + this.layoutResId = layoutResId; + return this; + } + + public Builder setClickable(boolean clickable) { + this.clickable = clickable; + return this; + } + + public Builder setOnClickListener(View.OnClickListener onClickListener) { + this.onClickListener = onClickListener; + return this; + } + + public Builder setPosition(int position) { + this.position = position; + return this; + } + + public BaseBottomSheetItem create() { + return new BaseBottomSheetItem(customView, layoutResId, clickable, onClickListener, position); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java new file mode 100644 index 0000000000..f0fc76a28d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java @@ -0,0 +1,119 @@ +package net.osmand.plus.base.bottomsheetmenu; + +import android.graphics.drawable.Drawable; +import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; +import android.support.annotation.StringRes; +import android.view.View; + +public class SimpleBottomSheetItem extends BaseBottomSheetItem { + + private Drawable icon; + @DrawableRes + private int iconResId; + @ColorRes + private int iconColorResId; + private String title; + @StringRes + private int titleResId; + @ColorRes + private int titleColorResId; + + public SimpleBottomSheetItem(View customView, + int layoutResId, + boolean clickable, + View.OnClickListener onClickListener, + int position, + Drawable icon, + int iconResId, + int iconColorResId, + String title, + int titleResId, + int titleColorResId) { + super(customView, layoutResId, clickable, onClickListener, position); + this.icon = icon; + this.iconResId = iconResId; + this.iconColorResId = iconColorResId; + this.title = title; + this.titleResId = titleResId; + this.titleColorResId = titleColorResId; + } + + public Drawable getIcon() { + return icon; + } + + public int getIconResId() { + return iconResId; + } + + public int getIconColorResId() { + return iconColorResId; + } + + public String getTitle() { + return title; + } + + public int getTitleResId() { + return titleResId; + } + + public int getTitleColorResId() { + return titleColorResId; + } + + public static class Builder extends BaseBottomSheetItem.Builder { + + private Drawable icon; + private int iconResId; + private int iconColorResId; + private String title; + private int titleResId; + private int titleColorResId; + + public Builder setIcon(Drawable icon) { + this.icon = icon; + return this; + } + + public Builder setIconResId(int iconResId) { + this.iconResId = iconResId; + return this; + } + + public Builder setIconColorResId(int iconColorResId) { + this.iconColorResId = iconColorResId; + return this; + } + + public Builder setTitle(String title) { + this.title = title; + return this; + } + + public Builder setTitleResId(int titleResId) { + this.titleResId = titleResId; + return this; + } + + public Builder setTitleColorResId(int titleColorResId) { + this.titleColorResId = titleColorResId; + return this; + } + + public SimpleBottomSheetItem createSimpleBottomSheetItem() { + return new SimpleBottomSheetItem(customView, + layoutResId, + clickable, + onClickListener, + position, + icon, + iconResId, + iconColorResId, + title, + titleResId, + titleColorResId); + } + } +}