some fixes;
This commit is contained in:
parent
63351ebf66
commit
81ce5a4372
3 changed files with 180 additions and 167 deletions
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -20,16 +19,16 @@
|
||||||
android:id="@+id/list_divider"
|
android:id="@+id/list_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/dashboard_divider"
|
android:layout_marginStart="@dimen/settings_divider_margin_start"
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_marginLeft="@dimen/settings_divider_margin_start"
|
android:layout_marginLeft="@dimen/settings_divider_margin_start"
|
||||||
android:layout_marginStart="@dimen/settings_divider_margin_start" />
|
android:background="?attr/dashboard_divider"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/favorites_list_item_height"
|
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/favorites_list_item_height"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="@dimen/favorites_my_places_icon_left_padding"
|
android:paddingStart="@dimen/favorites_my_places_icon_left_padding"
|
||||||
android:paddingLeft="@dimen/favorites_my_places_icon_left_padding"
|
android:paddingLeft="@dimen/favorites_my_places_icon_left_padding"
|
||||||
|
@ -63,12 +62,12 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginStart="@dimen/favorites_my_places_icon_right_padding"
|
android:layout_marginStart="@dimen/favorites_my_places_icon_right_padding"
|
||||||
android:layout_marginLeft="@dimen/favorites_my_places_icon_right_padding"
|
android:layout_marginLeft="@dimen/favorites_my_places_icon_right_padding"
|
||||||
android:layout_marginEnd="@dimen/favorites_my_places_icon_right_padding"
|
android:layout_marginEnd="@dimen/favorites_my_places_icon_right_padding"
|
||||||
android:layout_marginRight="@dimen/favorites_my_places_icon_right_padding"
|
android:layout_marginRight="@dimen/favorites_my_places_icon_right_padding"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
android:paddingTop="@dimen/context_menu_padding_margin_small"
|
android:paddingTop="@dimen/context_menu_padding_margin_small"
|
||||||
android:paddingBottom="@dimen/context_menu_padding_margin_small">
|
android:paddingBottom="@dimen/context_menu_padding_margin_small">
|
||||||
|
|
||||||
|
@ -76,10 +75,10 @@
|
||||||
android:id="@+id/favourite_label"
|
android:id="@+id/favourite_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/subHeaderPadding"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_marginBottom="@dimen/subHeaderPadding"
|
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="@string/lorem_ipsum" />
|
tools:text="@string/lorem_ipsum" />
|
||||||
|
|
||||||
|
@ -105,8 +104,8 @@
|
||||||
android:layout_marginLeft="@dimen/gpx_small_icon_margin"
|
android:layout_marginLeft="@dimen/gpx_small_icon_margin"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="100500 km" />
|
tools:text="100500 km" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
@ -142,8 +141,8 @@
|
||||||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||||
android:background="?attr/dashboard_button"
|
android:background="?attr/dashboard_button"
|
||||||
android:contentDescription="@string/context_menu_item_directions_to"
|
android:contentDescription="@string/context_menu_item_directions_to"
|
||||||
osmand:srcCompat="@drawable/ic_action_remove_dark"
|
android:visibility="gone"
|
||||||
android:visibility="gone" />
|
osmand:srcCompat="@drawable/ic_action_remove_dark" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/options"
|
android:id="@+id/options"
|
||||||
|
@ -152,8 +151,8 @@
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="?attr/dashboard_button"
|
android:background="?attr/dashboard_button"
|
||||||
android:contentDescription="@string/shared_string_more"
|
android:contentDescription="@string/shared_string_more"
|
||||||
osmand:srcCompat="@drawable/ic_overflow_menu_white"
|
android:visibility="gone"
|
||||||
android:visibility="gone" />
|
osmand:srcCompat="@drawable/ic_overflow_menu_white" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
@ -31,12 +32,17 @@ import net.osmand.plus.myplaces.SegmentActionsListener;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GpxBlockStatisticsBuilder {
|
public class GpxBlockStatisticsBuilder {
|
||||||
|
|
||||||
|
private static final Log log = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class);
|
||||||
|
private static final int GENERAL_UPDATE_INTERVAL = 1000;
|
||||||
|
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
private RecyclerView blocksView;
|
private RecyclerView blocksView;
|
||||||
private final SelectedGpxFile selectedGpxFile;
|
private final SelectedGpxFile selectedGpxFile;
|
||||||
|
@ -89,7 +95,11 @@ public class GpxBlockStatisticsBuilder {
|
||||||
updateRunning = false;
|
updateRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runUpdatingStatBlocks() {
|
public void runUpdatingStatBlocksIfNeeded() {
|
||||||
|
if (!isUpdateRunning()) {
|
||||||
|
if (handler.hasCallbacks(updatingItems)) {
|
||||||
|
stopUpdatingStatBlocks();
|
||||||
|
}
|
||||||
updatingItems = new Runnable() {
|
updatingItems = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -99,11 +109,12 @@ public class GpxBlockStatisticsBuilder {
|
||||||
}
|
}
|
||||||
AndroidUiHelper.updateVisibility(blocksView, !Algorithms.isEmpty(items));
|
AndroidUiHelper.updateVisibility(blocksView, !Algorithms.isEmpty(items));
|
||||||
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
||||||
handler.postDelayed(this, Math.max(1000, interval));
|
updateRunning = handler.postDelayed(this, Math.max(GENERAL_UPDATE_INTERVAL, interval));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
updateRunning = handler.post(updatingItems);
|
updateRunning = handler.post(updatingItems);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void initItems() {
|
public void initItems() {
|
||||||
GPXFile gpxFile = getGPXFile();
|
GPXFile gpxFile = getGPXFile();
|
||||||
|
@ -171,7 +182,7 @@ public class GpxBlockStatisticsBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatBlock {
|
public static class StatBlock {
|
||||||
private final String title;
|
private final String title;
|
||||||
private final String value;
|
private final String value;
|
||||||
private final int imageResId;
|
private final int imageResId;
|
||||||
|
@ -207,6 +218,9 @@ public class GpxBlockStatisticsBuilder {
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private final int activeColor;
|
private final int activeColor;
|
||||||
private final boolean nightMode;
|
private final boolean nightMode;
|
||||||
|
private final int minWidthPx;
|
||||||
|
private final int maxWidthPx;
|
||||||
|
private final int textSize;
|
||||||
|
|
||||||
public BlockStatisticsAdapter(GpxDisplayItem displayItem, SegmentActionsListener actionsListener,
|
public BlockStatisticsAdapter(GpxDisplayItem displayItem, SegmentActionsListener actionsListener,
|
||||||
@ColorInt int activeColor, boolean nightMode) {
|
@ColorInt int activeColor, boolean nightMode) {
|
||||||
|
@ -214,6 +228,9 @@ public class GpxBlockStatisticsBuilder {
|
||||||
this.actionsListener = actionsListener;
|
this.actionsListener = actionsListener;
|
||||||
this.activeColor = activeColor;
|
this.activeColor = activeColor;
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
|
minWidthPx = AndroidUtils.dpToPx(app, 60f);
|
||||||
|
maxWidthPx = AndroidUtils.dpToPx(app, 120f);
|
||||||
|
textSize = app.getResources().getDimensionPixelSize(R.dimen.default_desc_text_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -268,17 +285,14 @@ public class GpxBlockStatisticsBuilder {
|
||||||
this.items.addAll(items);
|
this.items.addAll(items);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int calculateWidthWithin(String... texts) {
|
public int calculateWidthWithin(String... texts) {
|
||||||
int textSize = app.getResources().getDimensionPixelSize(R.dimen.default_desc_text_size);
|
|
||||||
int textWidth = AndroidUtils.getTextMaxWidth(textSize, Arrays.asList(texts));
|
int textWidth = AndroidUtils.getTextMaxWidth(textSize, Arrays.asList(texts));
|
||||||
int minWidth = AndroidUtils.dpToPx(app, 60);
|
return Math.min(maxWidthPx, Math.max(minWidthPx, textWidth));
|
||||||
int maxWidth = AndroidUtils.dpToPx(app, 120);
|
}
|
||||||
return Math.min(maxWidth, Math.max(minWidth, textWidth));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BlockStatisticsViewHolder extends RecyclerView.ViewHolder {
|
private static class BlockStatisticsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private final TextViewEx valueText;
|
private final TextViewEx valueText;
|
||||||
private final TextView titleText;
|
private final TextView titleText;
|
||||||
|
|
|
@ -332,8 +332,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
headerContainer.addView(overviewCard.build(getMapActivity()));
|
headerContainer.addView(overviewCard.build(getMapActivity()));
|
||||||
}
|
}
|
||||||
GpxBlockStatisticsBuilder blocksBuilder = overviewCard.getBlockStatisticsBuilder();
|
GpxBlockStatisticsBuilder blocksBuilder = overviewCard.getBlockStatisticsBuilder();
|
||||||
if (isCurrentRecordingTrack() && !blocksBuilder.isUpdateRunning()) {
|
if (isCurrentRecordingTrack()) {
|
||||||
blocksBuilder.runUpdatingStatBlocks();
|
blocksBuilder.runUpdatingStatBlocksIfNeeded();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (overviewCard != null && overviewCard.getView() != null) {
|
if (overviewCard != null && overviewCard.getView() != null) {
|
||||||
|
@ -551,8 +551,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
updateControlsVisibility(true);
|
updateControlsVisibility(true);
|
||||||
startLocationUpdate();
|
startLocationUpdate();
|
||||||
GpxBlockStatisticsBuilder blockStats = overviewCard.getBlockStatisticsBuilder();
|
GpxBlockStatisticsBuilder blockStats = overviewCard.getBlockStatisticsBuilder();
|
||||||
if (menuType == TrackMenuType.OVERVIEW && isCurrentRecordingTrack() && !blockStats.isUpdateRunning()) {
|
if (menuType == TrackMenuType.OVERVIEW && isCurrentRecordingTrack()) {
|
||||||
blockStats.runUpdatingStatBlocks();
|
blockStats.runUpdatingStatBlocksIfNeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue