reduce connectivity
This commit is contained in:
parent
9fdfa1270b
commit
d9bea4ecd4
5 changed files with 56 additions and 43 deletions
|
@ -27,9 +27,8 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
|||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||
import net.osmand.plus.routing.RouteLineDrawInfo;
|
||||
import net.osmand.plus.settings.backend.ListStringPreference;
|
||||
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment;
|
||||
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderInfo;
|
||||
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderUiAdapter;
|
||||
import net.osmand.plus.settings.fragments.HeaderInfo;
|
||||
import net.osmand.plus.settings.fragments.HeaderUiAdapter;
|
||||
import net.osmand.plus.track.AppearanceViewHolder;
|
||||
import net.osmand.plus.track.ColorsCard;
|
||||
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||
|
@ -159,8 +158,8 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
}
|
||||
|
||||
private void changeMapTheme(DayNightMode mapTheme) {
|
||||
if (targetFragment instanceof RouteLineAppearanceFragment) {
|
||||
((RouteLineAppearanceFragment) targetFragment).onMapThemeUpdated(mapTheme);
|
||||
if (targetFragment instanceof OnMapThemeUpdateListener) {
|
||||
((OnMapThemeUpdateListener) targetFragment).onMapThemeUpdated(mapTheme);
|
||||
}
|
||||
if (selectedMode == ColorMode.CUSTOM) {
|
||||
Integer color = getRouteLineColor();
|
||||
|
@ -219,14 +218,14 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
}
|
||||
|
||||
private void updateColorItems() {
|
||||
if (targetFragment instanceof RouteLineAppearanceFragment) {
|
||||
((RouteLineAppearanceFragment) targetFragment).onSelectedColorChanged();
|
||||
if (targetFragment instanceof OnSelectedColorChangeListener) {
|
||||
((OnSelectedColorChangeListener) targetFragment).onSelectedColorChanged();
|
||||
}
|
||||
updateColorName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeedHeaderUpdate() {
|
||||
public void onNeedUpdateHeader() {
|
||||
updateColorName();
|
||||
}
|
||||
|
||||
|
@ -239,7 +238,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
int colorNameId = ColorDialogs.getColorName(getRouteLineColor());
|
||||
colorName = app.getString(colorNameId);
|
||||
}
|
||||
headerUiAdapter.onHeaderUpdate(this, title, colorName);
|
||||
headerUiAdapter.onUpdateHeader(this, title, colorName);
|
||||
}
|
||||
|
||||
private void updateDescription() {
|
||||
|
@ -360,4 +359,12 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
}
|
||||
}
|
||||
|
||||
public interface OnSelectedColorChangeListener {
|
||||
void onSelectedColorChanged();
|
||||
}
|
||||
|
||||
public interface OnMapThemeUpdateListener {
|
||||
void onMapThemeUpdated(@NonNull DayNightMode mapTheme);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.routing.RouteLineDrawInfo;
|
||||
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderInfo;
|
||||
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderUiAdapter;
|
||||
import net.osmand.plus.settings.fragments.HeaderInfo;
|
||||
import net.osmand.plus.settings.fragments.HeaderUiAdapter;
|
||||
import net.osmand.plus.track.AppearanceViewHolder;
|
||||
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -129,7 +129,7 @@ public class RouteLineWidthCard extends BaseCard implements HeaderInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNeedHeaderUpdate() {
|
||||
public void onNeedUpdateHeader() {
|
||||
updateHeader();
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class RouteLineWidthCard extends BaseCard implements HeaderInfo {
|
|||
String title = app.getString(R.string.select_track_width);
|
||||
String description = app.getString(selectedMode.titleId);
|
||||
tvSelectedType.setText(description);
|
||||
headerUiAdapter.onHeaderUpdate(this, title, description);
|
||||
headerUiAdapter.onUpdateHeader(this, title, description);
|
||||
}
|
||||
|
||||
private void updateDescription() {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package net.osmand.plus.settings.fragments;
|
||||
|
||||
public interface HeaderInfo {
|
||||
|
||||
void onNeedUpdateHeader();
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package net.osmand.plus.settings.fragments;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface HeaderUiAdapter {
|
||||
|
||||
void onUpdateHeader(@NonNull HeaderInfo headerInfo,
|
||||
@NonNull String title,
|
||||
@NonNull String description);
|
||||
|
||||
}
|
|
@ -31,13 +31,17 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.helpers.enums.DayNightMode;
|
||||
import net.osmand.plus.routing.RouteLineDrawInfo;
|
||||
import net.osmand.plus.routing.cards.RouteLineColorCard;
|
||||
import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener;
|
||||
import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener;
|
||||
import net.osmand.plus.routing.cards.RouteLineWidthCard;
|
||||
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
|
||||
|
||||
import static net.osmand.util.Algorithms.objectEquals;
|
||||
|
||||
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment implements ColorPickerListener {
|
||||
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment
|
||||
implements ColorPickerListener, OnMapThemeUpdateListener, OnSelectedColorChangeListener,
|
||||
HeaderUiAdapter {
|
||||
|
||||
public static final String TAG = RouteLineAppearanceFragment.class.getName();
|
||||
|
||||
|
@ -172,31 +176,24 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
ViewGroup cardsContainer = getCardsContainer();
|
||||
cardsContainer.removeAllViews();
|
||||
|
||||
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme, getHeaderUiAdapter());
|
||||
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme, this);
|
||||
cardsContainer.addView(colorCard.build(mapActivity));
|
||||
|
||||
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener(), getHeaderUiAdapter());
|
||||
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener(), this);
|
||||
cardsContainer.addView(widthCard.build(mapActivity));
|
||||
}
|
||||
|
||||
private HeaderUiAdapter getHeaderUiAdapter() {
|
||||
if (headerUiAdapter == null) {
|
||||
headerUiAdapter = new HeaderUiAdapter() {
|
||||
@Override
|
||||
public void onHeaderUpdate(@NonNull HeaderInfo headerInfo,
|
||||
@NonNull String title,
|
||||
@NonNull String description) {
|
||||
if (selectedHeader == null) {
|
||||
selectedHeader = headerInfo;
|
||||
}
|
||||
if (objectEquals(selectedHeader, headerInfo)) {
|
||||
headerTitle.setText(title);
|
||||
headerDescr.setText(description);
|
||||
}
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onUpdateHeader(@NonNull HeaderInfo headerInfo,
|
||||
@NonNull String title,
|
||||
@NonNull String description) {
|
||||
if (selectedHeader == null) {
|
||||
selectedHeader = headerInfo;
|
||||
}
|
||||
if (objectEquals(selectedHeader, headerInfo)) {
|
||||
headerTitle.setText(title);
|
||||
headerDescr.setText(description);
|
||||
}
|
||||
return headerUiAdapter;
|
||||
}
|
||||
|
||||
private OnNeedScrollListener createScrollListener() {
|
||||
|
@ -319,7 +316,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
} else {
|
||||
selectedHeader = colorCard;
|
||||
}
|
||||
selectedHeader.onNeedHeaderUpdate();
|
||||
selectedHeader.onNeedUpdateHeader();
|
||||
}
|
||||
|
||||
private void initVisibleRect() {
|
||||
|
@ -473,13 +470,4 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo);
|
||||
}
|
||||
|
||||
public interface HeaderUiAdapter {
|
||||
void onHeaderUpdate(@NonNull HeaderInfo headerInfo,
|
||||
@NonNull String title,
|
||||
@NonNull String description);
|
||||
}
|
||||
|
||||
public interface HeaderInfo {
|
||||
void onNeedHeaderUpdate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue