diff --git a/OsmAnd/res/layout/gpx_overview_fragment.xml b/OsmAnd/res/layout/gpx_overview_fragment.xml index d088caa167..cdea20a2be 100644 --- a/OsmAnd/res/layout/gpx_overview_fragment.xml +++ b/OsmAnd/res/layout/gpx_overview_fragment.xml @@ -15,7 +15,7 @@ android:orientation="horizontal" tools:itemCount="4" tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" - tools:listitem="@layout/item_gpx_action_segment" /> + tools:listitem="@layout/item_gpx_stat_block" /> diff --git a/OsmAnd/res/layout/item_gpx_action_segment.xml b/OsmAnd/res/layout/item_gpx_stat_block.xml similarity index 94% rename from OsmAnd/res/layout/item_gpx_action_segment.xml rename to OsmAnd/res/layout/item_gpx_stat_block.xml index 962941b95c..b7eedc1a9a 100644 --- a/OsmAnd/res/layout/item_gpx_action_segment.xml +++ b/OsmAnd/res/layout/item_gpx_stat_block.xml @@ -5,8 +5,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> - items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); - final SegmentItemAdapter siAdapter = new SegmentItemAdapter(items); + List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); + final StatBlockAdapter siAdapter = new StatBlockAdapter(items); rvOverview.setAdapter(siAdapter); rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); } @@ -225,45 +222,45 @@ public class OverviewCard extends BaseCard { }); } - private class SegmentItemAdapter extends RecyclerView.Adapter { - private final List segmentItems; + private class StatBlockAdapter extends RecyclerView.Adapter { + private final List StatBlocks; - public SegmentItemAdapter(List segmentItems) { - this.segmentItems = segmentItems; + public StatBlockAdapter(List StatBlocks) { + this.StatBlocks = StatBlocks; } @Override public int getItemCount() { - return segmentItems.size(); + return StatBlocks.size(); } @NonNull @Override - public SegmentItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public StatBlockViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_gpx_action_segment, parent, false); - return new SegmentItemViewHolder(itemView); + .inflate(R.layout.item_gpx_stat_block, parent, false); + return new StatBlockViewHolder(itemView); } @Override - public void onBindViewHolder(SegmentItemViewHolder holder, int position) { - SegmentItem item = segmentItems.get(position); + public void onBindViewHolder(StatBlockViewHolder holder, int position) { + StatBlock item = StatBlocks.get(position); holder.bind(item); } - class SegmentItemViewHolder extends RecyclerView.ViewHolder { + class StatBlockViewHolder extends RecyclerView.ViewHolder { private final TextViewEx valueText; private final TextView titleText; private final AppCompatImageView imageView; - SegmentItemViewHolder(View view) { + StatBlockViewHolder(View view) { super(view); valueText = view.findViewById(R.id.value); titleText = view.findViewById(R.id.title); imageView = view.findViewById(R.id.image); } - public void bind(final SegmentItem overviewItem) { + public void bind(final StatBlock overviewItem) { valueText.setText(overviewItem.value); valueText.setTextColor(app.getResources().getColor(R.color.active_color_primary_light)); titleText.setText(overviewItem.title); @@ -289,10 +286,10 @@ public class OverviewCard extends BaseCard { public HorizontalDividerDecoration(Context context) { int[] ATTRS = new int[]{android.R.attr.listDivider}; - final TypedArray a = context.obtainStyledAttributes(ATTRS); - divider = a.getDrawable(0); - a.recycle(); -// mDivider = getMyApplication().getUIUtilities().getIcon(R.drawable.divider_solid, R.color.divider_color_light); //todo change drawable + final TypedArray ta = context.obtainStyledAttributes(ATTRS); + divider = ta.getDrawable(0); +// DrawableCompat.setTint(divider, context.getResources().getColor(R.color.divider_color_light)); //todo change drawable color + ta.recycle(); } @Override @@ -323,7 +320,7 @@ public class OverviewCard extends BaseCard { } } - private class SegmentItem { + private static class StatBlock { private String title; private String value; private int imageResId; @@ -331,7 +328,7 @@ public class OverviewCard extends BaseCard { private LineGraphType firstType; private LineGraphType secondType; - public SegmentItem(String title, String value, @DrawableRes int imageResId, @ColorRes int imageColorId, LineGraphType firstType, LineGraphType secondType) { + public StatBlock(String title, String value, @DrawableRes int imageResId, @ColorRes int imageColorId, LineGraphType firstType, LineGraphType secondType) { this.title = title; this.value = value; this.imageResId = imageResId; @@ -340,53 +337,5 @@ public class OverviewCard extends BaseCard { this.secondType = secondType; } - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getImageResId() { - return imageResId; - } - - public void setImageResId(int imageResId) { - this.imageResId = imageResId; - } - - public int getImageColorId() { - return imageColorId; - } - - public void setImageColorId(int imageColorId) { - this.imageColorId = imageColorId; - } - - public LineGraphType getFirstType() { - return firstType; - } - - public void setFirstType(LineGraphType firstType) { - this.firstType = firstType; - } - - public LineGraphType getSecondType() { - return secondType; - } - - public void getSecondType(LineGraphType secondType) { - this.secondType = secondType; - } - } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index f102331bfc..6b93a6d166 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -221,6 +221,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } private void updateHeader() { + ViewGroup headerContainer = (ViewGroup) routeMenuTopShadowAll; + if (overviewCard != null && overviewCard.getView() != null) { + headerContainer.removeView(overviewCard.getView()); + } if (menuType == TrackMenuType.OPTIONS) { headerTitle.setText(menuType.titleId); AndroidUiHelper.updateVisibility(headerIcon, false); @@ -228,7 +232,27 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card String fileName = Algorithms.getFileWithoutDirs(getGpx().path); headerTitle.setText(GpxUiHelper.getGpxTitle(fileName)); AndroidUiHelper.updateVisibility(headerIcon, true); + if (menuType == TrackMenuType.OVERVIEW) { + if (overviewCard != null && overviewCard.getView() != null) { + ViewGroup parent = ((ViewGroup) overviewCard.getView().getParent()); + if (parent != null) { + parent.removeView(overviewCard.getView()); + } + headerContainer.addView(overviewCard.getView()); + } else { + overviewCard = new OverviewCard(getMapActivity(), displayHelper, this); + overviewCard.setListener(this); + headerContainer.addView(overviewCard.build(getMapActivity())); + } + } } + runLayoutListener(); + headerContainer.post(new Runnable() { + @Override + public void run() { + openMenuScreen(menuType == TrackMenuType.OVERVIEW ? MenuState.HEADER_ONLY : MenuState.HALF_SCREEN, false); + } + }); } private void setupCards() { @@ -236,19 +260,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null) { ViewGroup cardsContainer = getCardsContainer(); cardsContainer.removeAllViews(); - if (menuType == TrackMenuType.OVERVIEW) { - if (overviewCard != null && overviewCard.getView() != null) { - ViewGroup parent = (ViewGroup) overviewCard.getView().getParent(); - if (parent != null) { - parent.removeAllViews(); - } - cardsContainer.addView(overviewCard.getView()); - } else { - overviewCard = new OverviewCard(mapActivity, displayHelper, this); - overviewCard.setListener(this); - cardsContainer.addView(overviewCard.build(mapActivity)); - } - } else if (menuType == TrackMenuType.TRACK) { + if (menuType == TrackMenuType.TRACK) { if (segmentsCard != null && segmentsCard.getView() != null) { ViewGroup parent = (ViewGroup) segmentsCard.getView().getParent(); if (parent != null) {