Highlight first two items in active

This commit is contained in:
PavelRatushny 2017-09-11 19:26:51 +03:00
parent 03018fd538
commit dbe9d66e8d
10 changed files with 206 additions and 11 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/marker_circle_background_light_p_with_inset" android:state_pressed="true"/>
<item android:drawable="@drawable/marker_circle_background_p_with_inset" android:state_pressed="true"/>
<item android:drawable="@drawable/marker_circle_background_light_n_with_inset"/>
</selector>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/map_markers_on_map_color"/>
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/marker_circle_background_on_map_n"
android:insetBottom="14dp"
android:insetLeft="14dp"
android:insetRight="14dp"
android:insetTop="14dp"/>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/marker_circle_background_p_with_inset" android:state_pressed="true"/>
<item android:drawable="@drawable/marker_circle_background_on_map_n_with_inset"/>
</selector>

View file

@ -4,5 +4,5 @@
android:shape="oval">
<solid
android:color="@color/color_white"/>
android:color="@color/map_widget_blue"/>
</shape>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/marker_circle_background_light_p"
android:drawable="@drawable/marker_circle_background_p"
android:insetBottom="14dp"
android:insetLeft="14dp"
android:insetRight="14dp"

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/markers_top_bar_background"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?attr/selectableItemBackground">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_reorder_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:tint="?attr/secondary_icon_color"
tools:src="@drawable/ic_arrow_marker_diretion"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_direction_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:src="@drawable/ic_direction_arrow"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size"
tools:text="Van Gogh Museum"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:maxLines="1"
android:textSize="@dimen/default_desc_text_size"
tools:text="213 m"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_point_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="•"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
tools:visibility="visible"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/dashboard_subheader_text_dark"
android:textSize="@dimen/default_desc_text_size"
tools:text="Amsterdam Weekend"/>
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/map_marker_options_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="@drawable/marker_circle_background_on_map_with_inset"
android:focusableInTouchMode="true"
tools:src="@drawable/ic_action_marker_passed"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp"
android:background="@color/map_markers_divider_color"/>
</LinearLayout>

View file

@ -258,5 +258,7 @@
<color name="map_background_color_dark">#101821</color>
<color name="fab_green">#46bd2a</color>
<color name="map_markers_divider_color">#0d464a</color>
<color name="map_markers_on_map_color">#17828a</color>
</resources>

View file

@ -0,0 +1,31 @@
package net.osmand.plus.mapmarkers.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.plus.R;
public class MapMarkerItemOnMapViewHolder extends MapMarkerItemViewHolder {
final ImageView iconDirection;
final ImageView iconReorder;
final TextView title;
final TextView distance;
final TextView point;
final TextView description;
final ImageButton optionsBtn;
public MapMarkerItemOnMapViewHolder(View view) {
super(view);
iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon);
iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon);
title = (TextView) view.findViewById(R.id.map_marker_title);
distance = (TextView) view.findViewById(R.id.map_marker_distance);
point = (TextView) view.findViewById(R.id.map_marker_point_text_view);
description = (TextView) view.findViewById(R.id.map_marker_description);
optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button);
}
}

View file

@ -24,6 +24,9 @@ import java.util.Locale;
public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
private static final int ON_MAP_TYPE = 1;
private static final int GENERAL_TYPE = 2;
private MapActivity mapActivity;
private List<MapMarker> markers;
private MapMarkersActiveAdapterListener listener;
@ -60,15 +63,23 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
}
@Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view;
MapMarkerItemViewHolder holder;
if (viewType == ON_MAP_TYPE) {
view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_on_map, viewGroup, false);
holder = new MapMarkerItemOnMapViewHolder(view);
} else {
view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
holder = new MapMarkerItemViewHolder(view);
}
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listener.onItemClick(view);
}
});
return new MapMarkerItemViewHolder(view);
return holder;
}
@Override
@ -76,7 +87,20 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
MapMarker marker = markers.get(pos);
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
int color = MapMarker.getColorId(marker.colorIndex);
if (holder instanceof MapMarkerItemOnMapViewHolder) {
((MapMarkerItemOnMapViewHolder) holder).iconDirection.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, color));
holder.optionsBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_marker_passed, R.color.color_white));
holder.iconReorder.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_reorder, R.color.map_markers_on_map_color));
} else {
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_marker_passed));
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
}
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
@ -87,9 +111,6 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
}
});
int color = MapMarker.getColorId(marker.colorIndex);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
holder.title.setText(marker.getName(mapActivity));
String descr;
@ -103,7 +124,6 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
}
holder.description.setText(descr);
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_marker_passed));
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -134,6 +154,15 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
screenOrientation, mapActivity.getMyApplication(), mapActivity);
}
@Override
public int getItemViewType(int position) {
if (position < 2) {
return ON_MAP_TYPE;
} else {
return GENERAL_TYPE;
}
}
@Override
public int getItemCount() {
return markers.size();