1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459 |
- package com.kongzue.dialogx.dialogs;
- import static android.view.View.OVER_SCROLL_NEVER;
- import android.graphics.Bitmap;
- import android.graphics.drawable.BitmapDrawable;
- import android.graphics.drawable.Drawable;
- import android.text.TextUtils;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.AdapterView;
- import android.widget.BaseAdapter;
- import androidx.annotation.ColorInt;
- import androidx.annotation.ColorRes;
- import com.kongzue.dialogx.DialogX;
- import com.kongzue.dialogx.R;
- import com.kongzue.dialogx.interfaces.BottomMenuListViewTouchEvent;
- import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
- import com.kongzue.dialogx.interfaces.DialogXAnimInterface;
- import com.kongzue.dialogx.interfaces.DialogXRunnable;
- import com.kongzue.dialogx.interfaces.DialogXStyle;
- import com.kongzue.dialogx.interfaces.MenuItemLayoutRefreshCallback;
- import com.kongzue.dialogx.interfaces.MenuItemTextInfoInterceptor;
- import com.kongzue.dialogx.interfaces.OnBackPressedListener;
- import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
- import com.kongzue.dialogx.interfaces.OnBindView;
- import com.kongzue.dialogx.interfaces.OnBottomMenuButtonClickListener;
- import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
- import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
- import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
- import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener;
- import com.kongzue.dialogx.util.BottomMenuArrayAdapter;
- import com.kongzue.dialogx.util.TextInfo;
- import com.kongzue.dialogx.util.views.BottomDialogListView;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- /**
- * @author: Kongzue
- * @github: https://github.com/kongzue/
- * @homepage: http://kongzue.com/
- * @mail: myzcxhh@live.cn
- * @createTime: 2020/10/6 23:48
- */
- public class BottomMenu extends BottomDialog {
- public enum SELECT_MODE {
- NONE,
- SINGLE,
- MULTIPLE
- }
- protected BottomMenu me = this;
- protected int selectionIndex = -1;
- protected SELECT_MODE selectMode = SELECT_MODE.NONE;
- protected ArrayList<Integer> selectionItems;
- protected boolean showSelectedBackgroundTips = false;
- protected MenuItemLayoutRefreshCallback<BottomMenu> menuMenuItemLayoutRefreshCallback;
- protected OnMenuItemClickListener<BottomMenu> onMenuItemClickListener;
- public static BottomMenu build() {
- return new BottomMenu();
- }
- public static BottomMenu build(DialogXStyle style) {
- return new BottomMenu().setStyle(style);
- }
- public static BottomMenu build(OnBindView<BottomDialog> onBindView) {
- return new BottomMenu().setCustomView(onBindView);
- }
- protected BottomMenu() {
- super();
- }
- protected OnIconChangeCallBack<BottomMenu> onIconChangeCallBack;
- protected MenuItemTextInfoInterceptor<BottomMenu> menuItemTextInfoInterceptor;
- protected BottomDialogListView listView;
- protected BaseAdapter menuListAdapter;
- protected List<CharSequence> menuList;
- protected List<Integer> iconResIds;
- protected boolean autoTintIconInLightOrDarkMode = true;
- public static BottomMenu show(List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(List<String> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(List<String> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String... menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(CharSequence title, CharSequence message, List<String> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(CharSequence title, CharSequence message, List<String> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, String[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence message, CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(String title, String message, List<String> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(String title, String message, List<String> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, String[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(String title, String message, CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.message = message;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, List<CharSequence> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(int titleResId, int messageResId, List<String> menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, String[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, List<CharSequence> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu showStringList(int titleResId, int messageResId, List<String> menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuStringList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, int messageResId, CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.message = bottomMenu.getString(messageResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, String[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(CharSequence title, String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = title;
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, CharSequence[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, String[] menuList) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, CharSequence[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- public static BottomMenu show(int titleResId, String[] menuList, OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- BottomMenu bottomMenu = new BottomMenu();
- bottomMenu.title = bottomMenu.getString(titleResId);
- bottomMenu.setMenuList(menuList);
- bottomMenu.setOnMenuItemClickListener(onMenuItemClickListener);
- bottomMenu.show();
- return bottomMenu;
- }
- private float touchDownY;
- public static final int ITEM_CLICK_DELAY = 100;
- private long lastClickTime = 0;
- private int[] resultArray;
- private CharSequence[] selectTextArray;
- @Override
- protected void onDialogShow() {
- if (getDialogImpl() != null) {
- getDialogImpl().boxList.setVisibility(View.VISIBLE);
- if (!isAllowInterceptTouch()) {
- getDialogImpl().bkg.setMaxHeight((int) bottomDialogMaxHeight);
- if (bottomDialogMaxHeight != 0) {
- dialogImpl.scrollView.lockScroll(true);
- }
- }
- int dividerDrawableResId = 0;
- int dividerHeight = 1;
- if (style.overrideBottomDialogRes() != null) {
- dividerDrawableResId = style.overrideBottomDialogRes().overrideMenuDividerDrawableRes(isLightTheme());
- dividerHeight = style.overrideBottomDialogRes().overrideMenuDividerHeight(isLightTheme());
- }
- if (dividerDrawableResId == 0) {
- dividerDrawableResId = isLightTheme() ? R.drawable.rect_dialogx_material_menu_split_divider : R.drawable.rect_dialogx_material_menu_split_divider_night;
- }
- if (!isLightTheme()) {
- listView = new BottomDialogListView(getDialogImpl(), getOwnActivity(), R.style.DialogXCompatThemeDark);
- } else {
- listView = new BottomDialogListView(getDialogImpl(), getOwnActivity());
- }
- listView.setOverScrollMode(OVER_SCROLL_NEVER);
- listView.setDivider(getResources().getDrawable(dividerDrawableResId));
- listView.setDividerHeight(dividerHeight);
- listView.setBottomMenuListViewTouchEvent(new BottomMenuListViewTouchEvent() {
- @Override
- public void down(MotionEvent event) {
- touchDownY = getDialogImpl().bkg.getY();
- }
- });
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- haptic(view);
- long currentTime = System.currentTimeMillis();
- if (currentTime - lastClickTime > ITEM_CLICK_DELAY) {
- lastClickTime = currentTime;
- float deltaY = Math.abs(touchDownY - getDialogImpl().bkg.getY());
- if (deltaY > dip2px(15)) {
- return;
- }
- selectionIndex = position;
- switch (selectMode) {
- case NONE:
- if (onMenuItemClickListener != null) {
- if (!onMenuItemClickListener.onClick(me, menuList.get(position), position)) {
- dismiss();
- }
- } else {
- dismiss();
- }
- break;
- case SINGLE:
- if (onMenuItemClickListener instanceof OnMenuItemSelectListener) {
- OnMenuItemSelectListener<BottomMenu> onMenuItemSelectListener = (OnMenuItemSelectListener<BottomMenu>) onMenuItemClickListener;
- if (!onMenuItemSelectListener.onClick(me, menuList.get(position), position)) {
- dismiss();
- } else {
- menuListAdapter.notifyDataSetInvalidated();
- onMenuItemSelectListener.onOneItemSelect(me, menuList.get(position), position, true);
- }
- } else {
- if (onMenuItemClickListener != null) {
- if (!onMenuItemClickListener.onClick(me, menuList.get(position), position)) {
- dismiss();
- }
- } else {
- dismiss();
- }
- }
- break;
- case MULTIPLE:
- if (onMenuItemClickListener instanceof OnMenuItemSelectListener) {
- OnMenuItemSelectListener<BottomMenu> onMenuItemSelectListener = (OnMenuItemSelectListener<BottomMenu>) onMenuItemClickListener;
- if (!onMenuItemSelectListener.onClick(me, menuList.get(position), position)) {
- dismiss();
- } else {
- if (selectionItems.contains(position)) {
- selectionItems.remove(new Integer(position));
- } else {
- selectionItems.add(position);
- }
- menuListAdapter.notifyDataSetInvalidated();
- resultArray = new int[selectionItems.size()];
- selectTextArray = new CharSequence[selectionItems.size()];
- for (int i = 0; i < selectionItems.size(); i++) {
- resultArray[i] = selectionItems.get(i);
- selectTextArray[i] = menuList.get(resultArray[i]);
- }
- onMenuItemSelectListener.onMultiItemSelect(me, selectTextArray, resultArray);
- }
- } else {
- if (onMenuItemClickListener != null) {
- if (!onMenuItemClickListener.onClick(me, menuList.get(position), position)) {
- dismiss();
- }
- } else {
- dismiss();
- }
- }
- break;
- }
- }
- }
- });
- if (style.overrideBottomDialogRes() != null) {
- if (style.overrideBottomDialogRes().overrideMenuItemLayout(true, 0, 0, false) != 0) {
- listView.setSelector(R.color.empty);
- }
- }
- ViewGroup.LayoutParams listViewLp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- getDialogImpl().boxList.addView(listView, listViewLp);
- refreshUI();
- }
- }
- @Override
- public void refreshUI() {
- if (getDialogImpl() == null) return;
- if (listView != null) {
- if (menuListAdapter == null) {
- menuListAdapter = new BottomMenuArrayAdapter(me, getOwnActivity(), menuList);
- }
- if (listView.getAdapter() == null) {
- listView.setAdapter(menuListAdapter);
- } else {
- if (listView.getAdapter() != menuListAdapter) {
- listView.setAdapter(menuListAdapter);
- } else {
- menuListAdapter.notifyDataSetChanged();
- }
- }
- }
- // 部分主题下选中项默认按下效果
- if (showSelectedBackgroundTips) {
- listView.post(new Runnable() {
- @Override
- public void run() {
- if (menuListAdapter instanceof BottomMenuArrayAdapter && showSelectedBackgroundTips) {
- BottomMenuArrayAdapter bottomMenuArrayAdapter = ((BottomMenuArrayAdapter) menuListAdapter);
- View selectItemView = listView.getChildAt(getSelection());
- if (selectItemView != null) {
- selectItemView.post(new Runnable() {
- @Override
- public void run() {
- selectItemView.setPressed(true);
- }
- });
- }
- }
- }
- });
- }
- super.refreshUI();
- }
- public void preRefreshUI() {
- if (getDialogImpl() == null) return;
- runOnMain(new Runnable() {
- @Override
- public void run() {
- refreshUI();
- }
- });
- }
- @Override
- public String dialogKey() {
- return getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")";
- }
- public List<CharSequence> getMenuList() {
- return menuList;
- }
- public BottomMenu setMenuList(List<CharSequence> menuList) {
- this.menuList = menuList;
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- private boolean isSameSize(int menuListSize) {
- if (this.menuList == null || this.menuList.size() == 0) {
- return true;
- }
- return this.menuList.size() == menuListSize;
- }
- public BottomMenu setMenuStringList(List<String> menuList) {
- this.menuList = new ArrayList<>();
- this.menuList.addAll(menuList);
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMenuList(String[] menuList) {
- this.menuList = new ArrayList<>();
- this.menuList.addAll(Arrays.asList(menuList));
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMenuList(CharSequence[] menuList) {
- this.menuList = Arrays.asList(menuList);
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMenus(CharSequence... menuList) {
- this.menuList = Arrays.asList(menuList);
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMenus(String... menuList) {
- this.menuList = Arrays.asList(menuList);
- this.menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public OnIconChangeCallBack<BottomMenu> getOnIconChangeCallBack() {
- return onIconChangeCallBack;
- }
- public BottomMenu setOnIconChangeCallBack(OnIconChangeCallBack<BottomMenu> onIconChangeCallBack) {
- this.onIconChangeCallBack = onIconChangeCallBack;
- return this;
- }
- public OnBackPressedListener<BottomDialog> getOnBackPressedListener() {
- return (OnBackPressedListener<BottomDialog>) onBackPressedListener;
- }
- public BottomMenu setOnBackPressedListener(OnBackPressedListener<BottomDialog> onBackPressedListener) {
- this.onBackPressedListener = onBackPressedListener;
- preRefreshUI();
- return this;
- }
- public BottomMenu setDialogLifecycleCallback(DialogLifecycleCallback<BottomDialog> dialogLifecycleCallback) {
- this.dialogLifecycleCallback = dialogLifecycleCallback;
- if (isShow) dialogLifecycleCallback.onShow(me);
- return this;
- }
- public BottomMenu setStyle(DialogXStyle style) {
- this.style = style;
- return this;
- }
- public BottomMenu setTheme(DialogX.THEME theme) {
- this.theme = theme;
- return this;
- }
- public boolean isCancelable() {
- if (privateCancelable != null) {
- return privateCancelable == BOOLEAN.TRUE;
- }
- if (overrideCancelable != null) {
- return overrideCancelable == BOOLEAN.TRUE;
- }
- return cancelable;
- }
- public BottomMenu setCancelable(boolean cancelable) {
- this.privateCancelable = cancelable ? BOOLEAN.TRUE : BOOLEAN.FALSE;
- preRefreshUI();
- return this;
- }
- public DialogImpl getDialogImpl() {
- return dialogImpl;
- }
- public CharSequence getTitle() {
- return title;
- }
- public BottomMenu setTitle(CharSequence title) {
- this.title = title;
- preRefreshUI();
- return this;
- }
- public BottomMenu setTitle(int titleResId) {
- this.title = getString(titleResId);
- preRefreshUI();
- return this;
- }
- public CharSequence getMessage() {
- return message;
- }
- public BottomMenu setMessage(CharSequence message) {
- this.message = message;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMessage(int messageResId) {
- this.message = getString(messageResId);
- preRefreshUI();
- return this;
- }
- public CharSequence getCancelButton() {
- return cancelText;
- }
- public BottomMenu setCancelButton(CharSequence cancelText) {
- this.cancelText = cancelText;
- preRefreshUI();
- return this;
- }
- public BottomMenu setCancelButton(int cancelTextResId) {
- this.cancelText = getString(cancelTextResId);
- preRefreshUI();
- return this;
- }
- public BottomMenu setCancelButton(OnBottomMenuButtonClickListener<BottomMenu> cancelButtonClickListener) {
- this.cancelButtonClickListener = cancelButtonClickListener;
- return this;
- }
- public BottomMenu setCancelButton(CharSequence cancelText, OnBottomMenuButtonClickListener<BottomMenu> cancelButtonClickListener) {
- this.cancelText = cancelText;
- this.cancelButtonClickListener = cancelButtonClickListener;
- preRefreshUI();
- return this;
- }
- public BottomMenu setCancelButton(int cancelTextResId, OnBottomMenuButtonClickListener<BottomMenu> cancelButtonClickListener) {
- this.cancelText = getString(cancelTextResId);
- this.cancelButtonClickListener = cancelButtonClickListener;
- preRefreshUI();
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setCancelButton(OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setCancelButton(OnDialogButtonClickListener<BottomDialog> cancelButtonClickListener) {
- this.cancelButtonClickListener = cancelButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setCancelButton(CharSequence cancelText, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setCancelButton(CharSequence cancelText, OnDialogButtonClickListener<BottomDialog> cancelButtonClickListener) {
- this.cancelText = cancelText;
- this.cancelButtonClickListener = cancelButtonClickListener;
- preRefreshUI();
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setCancelButton(int cancelTextResId, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setCancelButton(int cancelTextResId, OnDialogButtonClickListener<BottomDialog> cancelButtonClickListener) {
- this.cancelText = getString(cancelTextResId);
- this.cancelButtonClickListener = cancelButtonClickListener;
- preRefreshUI();
- return this;
- }
- public BottomMenu setCustomView(OnBindView<BottomDialog> onBindView) {
- this.onBindView = onBindView;
- preRefreshUI();
- return this;
- }
- public View getCustomView() {
- if (onBindView == null) return null;
- return onBindView.getCustomView();
- }
- public BottomMenu removeCustomView() {
- this.onBindView.clean();
- preRefreshUI();
- return this;
- }
- public boolean isAllowInterceptTouch() {
- return super.isAllowInterceptTouch();
- }
- public BottomMenu setAllowInterceptTouch(boolean allowInterceptTouch) {
- this.allowInterceptTouch = allowInterceptTouch;
- preRefreshUI();
- return this;
- }
- public float getBottomDialogMaxHeight() {
- return bottomDialogMaxHeight;
- }
- public BottomMenu setBottomDialogMaxHeight(float bottomDialogMaxHeight) {
- this.bottomDialogMaxHeight = bottomDialogMaxHeight;
- return this;
- }
- public OnMenuItemClickListener<BottomMenu> getOnMenuItemClickListener() {
- return onMenuItemClickListener;
- }
- public BottomMenu setOnMenuItemClickListener(OnMenuItemClickListener<BottomMenu> onMenuItemClickListener) {
- this.onMenuItemClickListener = onMenuItemClickListener;
- return this;
- }
- public BaseAdapter getMenuListAdapter() {
- return menuListAdapter;
- }
- public BottomMenu setMenuListAdapter(BaseAdapter menuListAdapter) {
- this.menuListAdapter = menuListAdapter;
- return this;
- }
- public OnBottomMenuButtonClickListener<BottomMenu> getBottomMenuCancelButtonClickListener() {
- return (OnBottomMenuButtonClickListener<BottomMenu>) cancelButtonClickListener;
- }
- public BottomMenu setCancelButtonClickListener(OnBottomMenuButtonClickListener<BottomMenu> cancelButtonClickListener) {
- this.cancelButtonClickListener = cancelButtonClickListener;
- return this;
- }
- public TextInfo getTitleTextInfo() {
- return titleTextInfo;
- }
- public BottomMenu setTitleTextInfo(TextInfo titleTextInfo) {
- this.titleTextInfo = titleTextInfo;
- preRefreshUI();
- return this;
- }
- public TextInfo getMessageTextInfo() {
- return messageTextInfo;
- }
- public BottomMenu setMessageTextInfo(TextInfo messageTextInfo) {
- this.messageTextInfo = messageTextInfo;
- preRefreshUI();
- return this;
- }
- public TextInfo getCancelTextInfo() {
- return cancelTextInfo;
- }
- public BottomMenu setCancelTextInfo(TextInfo cancelTextInfo) {
- this.cancelTextInfo = cancelTextInfo;
- preRefreshUI();
- return this;
- }
- public int getBackgroundColor() {
- return backgroundColor;
- }
- public BottomMenu setBackgroundColor(@ColorInt int backgroundColor) {
- this.backgroundColor = backgroundColor;
- preRefreshUI();
- return this;
- }
- public int getSelection() {
- return selectionIndex;
- }
- public ArrayList<Integer> getSelectionList() {
- return selectionItems;
- }
- public BottomMenu setSelection(int selectionIndex) {
- this.selectMode = SELECT_MODE.SINGLE;
- this.selectionIndex = selectionIndex;
- this.selectionItems = null;
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setSingleSelection() {
- this.selectMode = SELECT_MODE.SINGLE;
- this.selectionIndex = -1;
- this.selectionItems = null;
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setSelection(int[] selectionItems) {
- this.selectMode = SELECT_MODE.MULTIPLE;
- this.selectionIndex = -1;
- this.selectionItems = new ArrayList<>();
- if (selectionItems != null) {
- for (int itemIndex : selectionItems) {
- this.selectionItems.add(itemIndex);
- }
- }
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setMultiSelection() {
- this.selectMode = SELECT_MODE.MULTIPLE;
- this.selectionIndex = -1;
- this.selectionItems = new ArrayList<>();
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setSelection(List<Integer> selectionItems) {
- this.selectMode = SELECT_MODE.MULTIPLE;
- this.selectionIndex = -1;
- this.selectionItems = new ArrayList<>(selectionItems);
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setNoSelect() {
- this.selectMode = SELECT_MODE.NONE;
- this.selectionIndex = -1;
- this.selectionItems = null;
- menuListAdapter = null;
- preRefreshUI();
- return this;
- }
- public BottomMenu setBackgroundColorRes(@ColorRes int backgroundRes) {
- this.backgroundColor = getColor(backgroundRes);
- preRefreshUI();
- return this;
- }
- public CharSequence getOkButton() {
- return okText;
- }
- public BottomMenu setOkButton(CharSequence okText) {
- this.okText = okText;
- preRefreshUI();
- return this;
- }
- public BottomMenu setOkButton(int OkTextResId) {
- this.okText = getString(OkTextResId);
- preRefreshUI();
- return this;
- }
- public BottomMenu setOkButton(OnBottomMenuButtonClickListener<BottomMenu> okButtonClickListener) {
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- public BottomMenu setOkButton(CharSequence okText, OnBottomMenuButtonClickListener<BottomMenu> okButtonClickListener) {
- this.okText = okText;
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- public BottomMenu setOkButton(int okTextResId, OnBottomMenuButtonClickListener<BottomMenu> okButtonClickListener) {
- this.okText = getString(okTextResId);
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- public BottomMenu setHapticFeedbackEnabled(boolean isHapticFeedbackEnabled) {
- this.isHapticFeedbackEnabled = isHapticFeedbackEnabled ? 1 : 0;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOkButton(OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOkButton(OnDialogButtonClickListener<BottomDialog> okButtonClickListener) {
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOkButton(CharSequence okText, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOkButton(CharSequence okText, OnDialogButtonClickListener<BottomDialog> okButtonClickListener) {
- this.okText = okText;
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOkButton(int okTextResId, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOkButton(int okTextResId, OnDialogButtonClickListener<BottomDialog> okButtonClickListener) {
- this.okText = getString(okTextResId);
- this.okButtonClickListener = okButtonClickListener;
- return this;
- }
- public CharSequence getOtherButton() {
- return otherText;
- }
- public BottomMenu setOtherButton(CharSequence otherText) {
- this.otherText = otherText;
- preRefreshUI();
- return this;
- }
- public BottomMenu setOtherButton(int OtherTextResId) {
- this.otherText = getString(OtherTextResId);
- preRefreshUI();
- return this;
- }
- public BottomMenu setOtherButton(OnBottomMenuButtonClickListener<BottomMenu> otherButtonClickListener) {
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- public BottomMenu setOtherButton(CharSequence otherText, OnBottomMenuButtonClickListener<BottomMenu> otherButtonClickListener) {
- this.otherText = otherText;
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- public BottomMenu setOtherButton(int otherTextResId, OnBottomMenuButtonClickListener<BottomMenu> otherButtonClickListener) {
- this.otherText = getString(otherTextResId);
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOtherButton(OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOtherButton(OnDialogButtonClickListener<BottomDialog> otherButtonClickListener) {
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOtherButton(CharSequence otherText, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOtherButton(CharSequence otherText, OnDialogButtonClickListener<BottomDialog> otherButtonClickListener) {
- this.otherText = otherText;
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- /**
- * 建议使用 {@link com.kongzue.dialogx.dialogs.BottomMenu#setOtherButton(int otherTextResId, OnBottomMenuButtonClickListener<BottomMenu>)}
- */
- @Deprecated
- public BottomMenu setOtherButton(int otherTextResId, OnDialogButtonClickListener<BottomDialog> otherButtonClickListener) {
- this.otherText = getString(otherTextResId);
- this.otherButtonClickListener = otherButtonClickListener;
- return this;
- }
- public BottomMenu setMaskColor(@ColorInt int maskColor) {
- this.maskColor = maskColor;
- preRefreshUI();
- return this;
- }
- public long getEnterAnimDuration() {
- return enterAnimDuration;
- }
- public BottomMenu setEnterAnimDuration(long enterAnimDuration) {
- this.enterAnimDuration = enterAnimDuration;
- return this;
- }
- public long getExitAnimDuration() {
- return exitAnimDuration;
- }
- public BottomMenu setExitAnimDuration(long exitAnimDuration) {
- this.exitAnimDuration = exitAnimDuration;
- return this;
- }
- public SELECT_MODE getSelectMode() {
- return selectMode;
- }
- @Override
- protected void shutdown() {
- dismiss();
- }
- public BottomMenu setMaxWidth(int maxWidth) {
- this.maxWidth = maxWidth;
- refreshUI();
- return this;
- }
- public BottomMenu setMaxHeight(int maxHeight) {
- this.maxHeight = maxHeight;
- refreshUI();
- return this;
- }
- public BottomMenu setMinHeight(int minHeight) {
- this.minHeight = minHeight;
- refreshUI();
- return this;
- }
- public BottomMenu setMinWidth(int minWidth) {
- this.minWidth = minWidth;
- refreshUI();
- return this;
- }
- public BottomMenu setDialogImplMode(DialogX.IMPL_MODE dialogImplMode) {
- this.dialogImplMode = dialogImplMode;
- return this;
- }
- public TextInfo getMenuTextInfo() {
- if (menuTextInfo == null) return DialogX.menuTextInfo;
- return menuTextInfo;
- }
- public BottomMenu setMenuTextInfo(TextInfo menuTextInfo) {
- this.menuTextInfo = menuTextInfo;
- return this;
- }
- public MenuItemTextInfoInterceptor<BottomMenu> getMenuItemTextInfoInterceptor() {
- return menuItemTextInfoInterceptor;
- }
- public BottomMenu setMenuItemTextInfoInterceptor(MenuItemTextInfoInterceptor<BottomMenu> menuItemTextInfoInterceptor) {
- this.menuItemTextInfoInterceptor = menuItemTextInfoInterceptor;
- return this;
- }
- public boolean isBkgInterceptTouch() {
- return bkgInterceptTouch;
- }
- public BottomMenu setBkgInterceptTouch(boolean bkgInterceptTouch) {
- this.bkgInterceptTouch = bkgInterceptTouch;
- return this;
- }
- public OnBackgroundMaskClickListener<BottomDialog> getOnBackgroundMaskClickListener() {
- return onBackgroundMaskClickListener;
- }
- public BottomMenu setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<BottomDialog> onBackgroundMaskClickListener) {
- this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
- return this;
- }
- public BottomMenu setRadius(float radiusPx) {
- backgroundRadius = radiusPx;
- refreshUI();
- return this;
- }
- public float getRadius() {
- return backgroundRadius;
- }
- public BottomMenu setTitleIcon(Bitmap titleIcon) {
- this.titleIcon = new BitmapDrawable(getResources(), titleIcon);
- refreshUI();
- return this;
- }
- public BottomMenu setTitleIcon(int titleIconResId) {
- this.titleIcon = getResources().getDrawable(titleIconResId);
- refreshUI();
- return this;
- }
- public BottomMenu setTitleIcon(Drawable titleIcon) {
- this.titleIcon = titleIcon;
- refreshUI();
- return this;
- }
- public DialogXAnimInterface<BottomDialog> getDialogXAnimImpl() {
- return dialogXAnimImpl;
- }
- public BottomMenu setDialogXAnimImpl(DialogXAnimInterface<BottomDialog> dialogXAnimImpl) {
- this.dialogXAnimImpl = dialogXAnimImpl;
- return this;
- }
- public BottomMenu setRootPadding(int padding) {
- this.screenPaddings = new int[]{padding, padding, padding, padding};
- refreshUI();
- return this;
- }
- public BottomMenu setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
- this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
- refreshUI();
- return this;
- }
- public boolean isShowSelectedBackgroundTips() {
- return showSelectedBackgroundTips;
- }
- public BottomMenu setShowSelectedBackgroundTips(boolean showSelectedBackgroundTips) {
- this.showSelectedBackgroundTips = showSelectedBackgroundTips;
- refreshUI();
- return this;
- }
- // 返回点击的菜单索引
- public int getSelectionIndex() {
- return selectionIndex;
- }
- // 返回多选时,选择的菜单索引集合
- public int[] getSelectionIndexArray() {
- return resultArray;
- }
- // 返回多选时,选择的菜单文本集合
- public CharSequence[] getSelectTextArray() {
- return selectTextArray;
- }
- public MenuItemLayoutRefreshCallback<BottomMenu> getMenuMenuItemLayoutRefreshCallback() {
- return menuMenuItemLayoutRefreshCallback;
- }
- public BottomMenu setMenuMenuItemLayoutRefreshCallback(MenuItemLayoutRefreshCallback<BottomMenu> menuMenuItemLayoutRefreshCallback) {
- this.menuMenuItemLayoutRefreshCallback = menuMenuItemLayoutRefreshCallback;
- return this;
- }
- public TextInfo getOkTextInfo() {
- return okTextInfo;
- }
- public BottomMenu setOkTextInfo(TextInfo okTextInfo) {
- this.okTextInfo = okTextInfo;
- return this;
- }
- public TextInfo getOtherTextInfo() {
- return otherTextInfo;
- }
- public BottomMenu setOtherTextInfo(TextInfo otherTextInfo) {
- this.otherTextInfo = otherTextInfo;
- return this;
- }
- public BottomMenu setScrollableWhenContentLargeThanVisibleRange(boolean scrollableWhenContentLargeThanVisibleRange) {
- this.scrollableWhenContentLargeThanVisibleRange = scrollableWhenContentLargeThanVisibleRange;
- return this;
- }
- public BottomMenu setData(String key, Object obj) {
- if (data == null) data = new HashMap<>();
- data.put(key, obj);
- return this;
- }
- public BottomMenu onShow(DialogXRunnable<BottomDialog> dialogXRunnable) {
- onShowRunnable = dialogXRunnable;
- if (isShow() && onShowRunnable != null) {
- onShowRunnable.run(this);
- }
- return this;
- }
- public BottomMenu onDismiss(DialogXRunnable<BottomDialog> dialogXRunnable) {
- onDismissRunnable = dialogXRunnable;
- return this;
- }
- public BottomMenu setEnableImmersiveMode(boolean enableImmersiveMode) {
- this.enableImmersiveMode = enableImmersiveMode;
- refreshUI();
- return this;
- }
- public List<Integer> getIconResIds() {
- return iconResIds;
- }
- public int getIconResIds(int position) {
- if (iconResIds != null && position >= 0 && position < iconResIds.size()) {
- return iconResIds.get(position);
- }
- return 0;
- }
- public BottomMenu setIconResIds(List<Integer> iconResIds) {
- this.iconResIds = iconResIds;
- refreshUI();
- return this;
- }
- public BottomMenu setIconResIds(int... resIds) {
- if (iconResIds == null) {
- iconResIds = new ArrayList<>();
- }
- for (int id : resIds) {
- iconResIds.add(id);
- }
- refreshUI();
- return this;
- }
- public boolean isAutoTintIconInLightOrDarkMode() {
- return autoTintIconInLightOrDarkMode;
- }
- public BottomMenu setAutoTintIconInLightOrDarkMode(boolean autoTintIconInLightOrDarkMode) {
- this.autoTintIconInLightOrDarkMode = autoTintIconInLightOrDarkMode;
- refreshUI();
- return this;
- }
- public BottomMenu appendMessage(CharSequence message){
- this.message = TextUtils.concat(this.message, message);
- refreshUI();
- return this;
- }
- }
|