Add clickability setting to ContextMenuItem.ItemBuilder()
This commit is contained in:
parent
d537eea3df
commit
73f5c0d0cc
2 changed files with 20 additions and 3 deletions
|
@ -21,7 +21,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.activities.HelpActivity;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
|
@ -115,7 +114,7 @@ public class ContextMenuAdapter {
|
|||
public boolean isEnabled(int position) {
|
||||
final ContextMenuItem item = getItem(position);
|
||||
if (item != null) {
|
||||
return !item.isCategory() && item.getLayout() != R.layout.drawer_divider;
|
||||
return !item.isCategory() && item.isClickable() && item.getLayout() != R.layout.drawer_divider;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -335,6 +334,11 @@ public class ContextMenuAdapter {
|
|||
convertView.setClickable(false);
|
||||
}
|
||||
|
||||
if (!item.isClickable()) {
|
||||
convertView.setFocusable(false);
|
||||
convertView.setClickable(false);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class ContextMenuItem {
|
|||
private final int layout;
|
||||
private boolean loading;
|
||||
private final boolean category;
|
||||
private final boolean clickable;
|
||||
private final boolean skipPaintingWithoutColor;
|
||||
private final int pos;
|
||||
private String description;
|
||||
|
@ -47,6 +48,7 @@ public class ContextMenuItem {
|
|||
@LayoutRes int layout,
|
||||
boolean loading,
|
||||
boolean category,
|
||||
boolean clickable,
|
||||
boolean skipPaintingWithoutColor, int pos,
|
||||
String description,
|
||||
ContextMenuAdapter.ItemClickListener itemClickListener,
|
||||
|
@ -65,6 +67,7 @@ public class ContextMenuItem {
|
|||
this.layout = layout;
|
||||
this.loading = loading;
|
||||
this.category = category;
|
||||
this.clickable = clickable;
|
||||
this.skipPaintingWithoutColor = skipPaintingWithoutColor;
|
||||
this.pos = pos;
|
||||
this.description = description;
|
||||
|
@ -135,6 +138,10 @@ public class ContextMenuItem {
|
|||
return category;
|
||||
}
|
||||
|
||||
public boolean isClickable() {
|
||||
return clickable;
|
||||
}
|
||||
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
@ -223,6 +230,7 @@ public class ContextMenuItem {
|
|||
private int mLayout = INVALID_ID;
|
||||
private boolean mLoading = false;
|
||||
private boolean mIsCategory = false;
|
||||
private boolean mIsClickable = true;
|
||||
private int mPosition = -1;
|
||||
private String mDescription = null;
|
||||
private ContextMenuAdapter.ItemClickListener mItemClickListener = null;
|
||||
|
@ -287,6 +295,11 @@ public class ContextMenuItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setClickable(boolean clickable) {
|
||||
mIsClickable = clickable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setPosition(int position) {
|
||||
mPosition = position;
|
||||
return this;
|
||||
|
@ -338,7 +351,7 @@ public class ContextMenuItem {
|
|||
|
||||
public ContextMenuItem createItem() {
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
|
||||
mSelected, mProgress, mLayout, mLoading, mIsCategory, mSkipPaintingWithoutColor,
|
||||
mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor,
|
||||
mPosition, mDescription, mItemClickListener, mIntegerListener, mProgressListener,
|
||||
mHideDivider, mMinHeight, mTag);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue