Move inner classes to upper level
This commit is contained in:
parent
fbccdfd659
commit
fd84daf722
8 changed files with 154 additions and 137 deletions
|
@ -0,0 +1,65 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
|
||||
|
||||
public class CollapsableView {
|
||||
|
||||
private View contentView;
|
||||
private MenuBuilder menuBuilder;
|
||||
|
||||
private OsmandPreference<Boolean> collapsedPref;
|
||||
private CollapseExpandListener collapseExpandListener;
|
||||
private boolean collapsed;
|
||||
|
||||
public CollapsableView(@NonNull View contentView, MenuBuilder menuBuilder,
|
||||
@NonNull OsmandPreference<Boolean> collapsedPref) {
|
||||
this.contentView = contentView;
|
||||
this.menuBuilder = menuBuilder;
|
||||
this.collapsedPref = collapsedPref;
|
||||
}
|
||||
|
||||
public CollapsableView(@NonNull View contentView, MenuBuilder menuBuilder, boolean collapsed) {
|
||||
this.contentView = contentView;
|
||||
this.collapsed = collapsed;
|
||||
this.menuBuilder = menuBuilder;
|
||||
}
|
||||
|
||||
public View getContentView() {
|
||||
return contentView;
|
||||
}
|
||||
|
||||
public boolean isCollapsed() {
|
||||
if (collapsedPref != null) {
|
||||
return collapsedPref.get();
|
||||
} else {
|
||||
return collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollapsed(boolean collapsed) {
|
||||
if (collapsedPref != null) {
|
||||
collapsedPref.set(collapsed);
|
||||
} else {
|
||||
this.collapsed = collapsed;
|
||||
}
|
||||
if (collapseExpandListener != null) {
|
||||
collapseExpandListener.onCollapseExpand(collapsed);
|
||||
}
|
||||
if (menuBuilder != null && menuBuilder.getCollapseExpandListener() != null) {
|
||||
menuBuilder.getCollapseExpandListener().onCollapseExpand(collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
public CollapseExpandListener getCollapseExpandListener() {
|
||||
return collapseExpandListener;
|
||||
}
|
||||
|
||||
public void setCollapseExpandListener(MenuBuilder.CollapseExpandListener collapseExpandListener) {
|
||||
this.collapseExpandListener = collapseExpandListener;
|
||||
}
|
||||
}
|
|
@ -45,7 +45,6 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -109,118 +108,6 @@ public class MenuBuilder {
|
|||
void onCollapseExpand(boolean collapsed);
|
||||
}
|
||||
|
||||
public class PlainMenuItem {
|
||||
private int iconId;
|
||||
private String buttonText;
|
||||
private String text;
|
||||
private boolean needLinks;
|
||||
private boolean url;
|
||||
private boolean collapsable;
|
||||
private CollapsableView collapsableView;
|
||||
private OnClickListener onClickListener;
|
||||
|
||||
public PlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean url,
|
||||
boolean collapsable, CollapsableView collapsableView,
|
||||
OnClickListener onClickListener) {
|
||||
this.iconId = iconId;
|
||||
this.buttonText = buttonText;
|
||||
this.text = text;
|
||||
this.needLinks = needLinks;
|
||||
this.url = url;
|
||||
this.collapsable = collapsable;
|
||||
this.collapsableView = collapsableView;
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getButtonText() {
|
||||
return buttonText;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public boolean isNeedLinks() {
|
||||
return needLinks;
|
||||
}
|
||||
|
||||
public boolean isUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean isCollapsable() {
|
||||
return collapsable;
|
||||
}
|
||||
|
||||
public CollapsableView getCollapsableView() {
|
||||
return collapsableView;
|
||||
}
|
||||
|
||||
public OnClickListener getOnClickListener() {
|
||||
return onClickListener;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CollapsableView {
|
||||
|
||||
private View contenView;
|
||||
private MenuBuilder menuBuilder;
|
||||
private OsmandPreference<Boolean> collapsedPref;
|
||||
private boolean collapsed;
|
||||
private CollapseExpandListener collapseExpandListener;
|
||||
|
||||
public CollapsableView(@NonNull View contenView, MenuBuilder menuBuilder,
|
||||
@NonNull OsmandPreference<Boolean> collapsedPref) {
|
||||
this.contenView = contenView;
|
||||
this.menuBuilder = menuBuilder;
|
||||
this.collapsedPref = collapsedPref;
|
||||
}
|
||||
|
||||
public CollapsableView(@NonNull View contenView, MenuBuilder menuBuilder, boolean collapsed) {
|
||||
this.contenView = contenView;
|
||||
this.collapsed = collapsed;
|
||||
this.menuBuilder = menuBuilder;
|
||||
}
|
||||
|
||||
public View getContenView() {
|
||||
return contenView;
|
||||
}
|
||||
|
||||
public boolean isCollapsed() {
|
||||
if (collapsedPref != null) {
|
||||
return collapsedPref.get();
|
||||
} else {
|
||||
return collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollapsed(boolean collapsed) {
|
||||
if (collapsedPref != null) {
|
||||
collapsedPref.set(collapsed);
|
||||
} else {
|
||||
this.collapsed = collapsed;
|
||||
}
|
||||
if (collapseExpandListener != null) {
|
||||
collapseExpandListener.onCollapseExpand(collapsed);
|
||||
}
|
||||
if (menuBuilder != null && menuBuilder.collapseExpandListener != null) {
|
||||
menuBuilder.collapseExpandListener.onCollapseExpand(collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
public CollapseExpandListener getCollapseExpandListener() {
|
||||
return collapseExpandListener;
|
||||
}
|
||||
|
||||
public void setCollapseExpandListener(CollapseExpandListener collapseExpandListener) {
|
||||
this.collapseExpandListener = collapseExpandListener;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuBuilder(@NonNull MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
|
@ -234,6 +121,10 @@ public class MenuBuilder {
|
|||
transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
|
||||
}
|
||||
|
||||
public CollapseExpandListener getCollapseExpandListener() {
|
||||
return collapseExpandListener;
|
||||
}
|
||||
|
||||
public void setCollapseExpandListener(CollapseExpandListener collapseExpandListener) {
|
||||
this.collapseExpandListener = collapseExpandListener;
|
||||
}
|
||||
|
@ -355,7 +246,7 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildPlainMenuItems(View view) {
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getButtonText(), item.getText(), 0, item.collapsable, item.collapsableView,
|
||||
buildRow(view, item.getIconId(), item.getButtonText(), item.getText(), 0, item.isCollapsable(), item.getCollapsableView(),
|
||||
item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener(), false);
|
||||
}
|
||||
}
|
||||
|
@ -668,31 +559,31 @@ public class MenuBuilder {
|
|||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE));
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContentView().getVisibility() == View.GONE));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
|
||||
collapsableView.getContenView().setVisibility(View.GONE);
|
||||
if (collapsableView.getContentView().getVisibility() == View.VISIBLE) {
|
||||
collapsableView.getContentView().setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
collapsableView.setCollapsed(true);
|
||||
} else {
|
||||
collapsableView.getContenView().setVisibility(View.VISIBLE);
|
||||
collapsableView.getContentView().setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(false));
|
||||
collapsableView.setCollapsed(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (collapsableView.isCollapsed()) {
|
||||
collapsableView.getContenView().setVisibility(View.GONE);
|
||||
collapsableView.getContentView().setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
}
|
||||
if (collapsableView.getContenView().getParent() != null) {
|
||||
((ViewGroup) collapsableView.getContenView().getParent())
|
||||
.removeView(collapsableView.getContenView());
|
||||
if (collapsableView.getContentView().getParent() != null) {
|
||||
((ViewGroup) collapsableView.getContentView().getParent())
|
||||
.removeView(collapsableView.getContentView());
|
||||
}
|
||||
baseView.addView(collapsableView.getContenView());
|
||||
baseView.addView(collapsableView.getContentView());
|
||||
}
|
||||
|
||||
if (onClickListener != null) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import androidx.annotation.DrawableRes;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -48,7 +47,6 @@ import net.osmand.plus.download.DownloadValidationManager;
|
|||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
|
||||
|
|
60
OsmAnd/src/net/osmand/plus/mapcontextmenu/PlainMenuItem.java
Normal file
60
OsmAnd/src/net/osmand/plus/mapcontextmenu/PlainMenuItem.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public class PlainMenuItem {
|
||||
|
||||
private int iconId;
|
||||
private String buttonText;
|
||||
private String text;
|
||||
private boolean needLinks;
|
||||
private boolean url;
|
||||
private boolean collapsable;
|
||||
private CollapsableView collapsableView;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
public PlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean url,
|
||||
boolean collapsable, CollapsableView collapsableView,
|
||||
View.OnClickListener onClickListener) {
|
||||
this.iconId = iconId;
|
||||
this.buttonText = buttonText;
|
||||
this.text = text;
|
||||
this.needLinks = needLinks;
|
||||
this.url = url;
|
||||
this.collapsable = collapsable;
|
||||
this.collapsableView = collapsableView;
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getButtonText() {
|
||||
return buttonText;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public boolean isNeedLinks() {
|
||||
return needLinks;
|
||||
}
|
||||
|
||||
public boolean isUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean isCollapsable() {
|
||||
return collapsable;
|
||||
}
|
||||
|
||||
public CollapsableView getCollapsableView() {
|
||||
return collapsableView;
|
||||
}
|
||||
|
||||
public View.OnClickListener getOnClickListener() {
|
||||
return onClickListener;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
|
@ -223,27 +224,27 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE));
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContentView().getVisibility() == View.GONE));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
|
||||
collapsableView.getContenView().setVisibility(View.GONE);
|
||||
if (collapsableView.getContentView().getVisibility() == View.VISIBLE) {
|
||||
collapsableView.getContentView().setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
collapsableView.setCollapsed(true);
|
||||
} else {
|
||||
collapsableView.getContenView().setVisibility(View.VISIBLE);
|
||||
collapsableView.getContentView().setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(false));
|
||||
collapsableView.setCollapsed(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (collapsableView.isCollapsed()) {
|
||||
collapsableView.getContenView().setVisibility(View.GONE);
|
||||
collapsableView.getContentView().setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
}
|
||||
baseView.addView(collapsableView.getContenView());
|
||||
baseView.addView(collapsableView.getContentView());
|
||||
}
|
||||
|
||||
if (isWiki) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
|
|
@ -68,7 +68,7 @@ import net.osmand.plus.helpers.GpxUiHelper;
|
|||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||
import net.osmand.plus.mapcontextmenu.InterceptorLinearLayout;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
|
@ -870,12 +870,12 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
|||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL|Gravity.START;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE));
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContentView().getVisibility() == View.GONE));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
ll.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinearLayout contentView = (LinearLayout) collapsableView.getContenView();
|
||||
LinearLayout contentView = (LinearLayout) collapsableView.getContentView();
|
||||
if (contentView.getVisibility() == View.VISIBLE) {
|
||||
contentView.setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
|
@ -890,10 +890,10 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
|||
}
|
||||
});
|
||||
if (collapsableView.isCollapsed()) {
|
||||
collapsableView.getContenView().setVisibility(View.GONE);
|
||||
collapsableView.getContentView().setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(getCollapseIcon(true));
|
||||
}
|
||||
baseView.addView(collapsableView.getContenView());
|
||||
baseView.addView(collapsableView.getContentView());
|
||||
}
|
||||
|
||||
if (onClickListener != null) {
|
||||
|
|
Loading…
Reference in a new issue