Merge pull request #4361 from osmandapp/sasha_pasha_branch

Sasha pasha branch
This commit is contained in:
Alexey 2017-08-31 14:09:09 +03:00 committed by GitHub
commit db41c2ebad
13 changed files with 606 additions and 85 deletions

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:color="@color/dashboard_blue" android:state_checked="true"/>
<item android:color="@color/icon_color" android:state_checked="false"/>
</selector>

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/map_markers_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="@color/osmand_orange"
android:minHeight="@dimen/dashboard_map_toolbar"
android:theme="?attr/toolbar_theme"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/map_markers"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size_large"/>
<ImageButton
android:id="@+id/options_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<net.osmand.plus.LockableViewPager
android:id="@+id/map_markers_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_gravity="bottom"
android:alpha="0.5"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_onmap"/>
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/map_markers_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
app:itemBackground="?attr/bg_color"
app:itemIconTint="@color/bottom_navigation_color_selector"
app:itemTextColor="@color/bottom_navigation_color_selector"
app:menu="@menu/map_markers_bottom_navigation"/>
</LinearLayout>

View file

@ -4,62 +4,44 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?attr/bg_color"
android:descendantFocusability="blocksDescendants">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color">
android:background="?attr/selectableItemBackground">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/marker_reorder_icon"
android:id="@+id/map_marker_reorder_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:padding="16dp"
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_action_reorder"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/marker_icon"
android:id="@+id/map_marker_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toEndOf="@id/marker_reorder_icon"
android:layout_toRightOf="@id/marker_reorder_icon"
tools:src="@drawable/ic_action_flag_dark"/>
<ImageButton
android:id="@+id/marker_options_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="16dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="16dp"
android:background="?attr/selectableItemBackground"
android:focusableInTouchMode="true"
tools:src="@drawable/ic_overflow_menu_white"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/marker_icon"
android:layout_toLeftOf="@id/marker_options_button"
android:layout_toRightOf="@+id/marker_icon"
android:layout_toStartOf="@id/marker_options_button"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/measure_point_title"
android:id="@+id/map_marker_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
@ -71,36 +53,41 @@
android:layout_height="wrap_content">
<ImageView
android:id="@+id/direction_icon"
android:id="@+id/map_marker_direction_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_direction_arrow"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/marker_distance"
android:id="@+id/map_marker_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:maxLines="1"
android:textColor="@color/marker_blue"
android:textSize="@dimen/default_sub_text_size"
tools:text="213 m"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/point_icon_text_view"
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_sub_text_size"/>
android:textSize="@dimen/default_sub_text_size"
android:visibility="gone"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/marker_description"
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="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
@ -109,14 +96,27 @@
</LinearLayout>
<ImageButton
android:id="@+id/map_marker_options_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginBottom="16dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="16dp"
android:background="?attr/selectableItemBackground"
android:focusableInTouchMode="true"
tools:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
<View
android:id="@+id/points_divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/marker_reorder_icon"
android:layout_toRightOf="@+id/marker_reorder_icon"
android:layout_gravity="bottom"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp"
android:background="?attr/dashboard_divider"/>
</RelativeLayout>
</FrameLayout>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_active"
android:icon="@drawable/ic_map"
android:title="@string/osm_live_active"/>
<item
android:id="@+id/action_history"
android:icon="@drawable/ic_action_history2"
android:title="@string/shared_string_history"/>
</menu>

View file

@ -105,6 +105,36 @@ public class MapMarkersHelper {
result = 31 * result + colorIndex;
return result;
}
public static int getColorId(int colorIndex) {
int colorId;
switch (colorIndex) {
case 0:
colorId = R.color.marker_blue;
break;
case 1:
colorId = R.color.marker_green;
break;
case 2:
colorId = R.color.marker_orange;
break;
case 3:
colorId = R.color.marker_red;
break;
case 4:
colorId = R.color.marker_yellow;
break;
case 5:
colorId = R.color.marker_teal;
break;
case 6:
colorId = R.color.marker_purple;
break;
default:
colorId = R.color.marker_blue;
}
return colorId;
}
}
public MapMarkersHelper(OsmandApplication ctx) {

View file

@ -48,6 +48,7 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
@ -623,6 +624,18 @@ public class MapActivityActions implements DialogProvider {
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitle("New map markers")
.setIcon(R.drawable.ic_action_flag_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
app.logEvent(mapActivity, "drawer_markers_open");
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
return true;
}
}).createItem());
} else {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
.setIcon(R.drawable.ic_action_intermediate)

View file

@ -43,7 +43,6 @@ import net.osmand.plus.views.DirectionDrawable;
import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.ListDividerShape;
import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.io.File;
@ -784,37 +783,7 @@ public class MapMarkerDialogHelper {
}
public static Drawable getMapMarkerIcon(OsmandApplication app, int colorIndex) {
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, getMapMarkerColorId(colorIndex));
}
public static int getMapMarkerColorId(int colorIndex) {
int colorId;
switch (colorIndex) {
case 0:
colorId = R.color.marker_blue;
break;
case 1:
colorId = R.color.marker_green;
break;
case 2:
colorId = R.color.marker_orange;
break;
case 3:
colorId = R.color.marker_red;
break;
case 4:
colorId = R.color.marker_yellow;
break;
case 5:
colorId = R.color.marker_teal;
break;
case 6:
colorId = R.color.marker_purple;
break;
default:
colorId = R.color.marker_blue;
}
return colorId;
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(colorIndex));
}
public void updateLocation(ListView listView, boolean compassChanged) {
@ -896,7 +865,7 @@ public class MapMarkerDialogHelper {
WptPt wpt = new WptPt();
wpt.lat = marker.getLatitude();
wpt.lon = marker.getLongitude();
wpt.setColor(mapActivity.getResources().getColor(getMapMarkerColorId(marker.colorIndex)));
wpt.setColor(mapActivity.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
wpt.name = marker.getOnlyName();
//wpt.link = r.getFileName();
//wpt.time = r.getFile().lastModified();

View file

@ -0,0 +1,143 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.adapters.MapMarkersActiveAdapter;
import net.osmand.plus.mapmarkers.adapters.MapMarkersActiveAdapter.MapMarkersActiveAdapterListener;
import net.osmand.util.MapUtils;
public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
private MapMarkersActiveAdapter adapter;
private Location location;
private Float heading;
private boolean locationUpdateStarted;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final RecyclerView recyclerView = new RecyclerView(getContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
final MapActivity mapActivity = (MapActivity) getActivity();
adapter = new MapMarkersActiveAdapter(mapActivity);
adapter.setAdapterListener(new MapMarkersActiveAdapterListener() {
@Override
public void onItemClick(View view) {
int pos = recyclerView.indexOfChild(view);
MapMarker marker = adapter.getItem(pos);
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
15, marker.getPointDescription(mapActivity), true, marker);
MapActivity.launchMapActivityMoveToTop(mapActivity);
((DialogFragment) getParentFragment()).dismiss();
}
});
recyclerView.setAdapter(adapter);
return recyclerView;
}
@Override
public void onResume() {
super.onResume();
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
startLocationUpdate();
}
@Override
public void onPause() {
super.onPause();
stopLocationUpdate();
}
@Override
public void updateLocation(Location location) {
boolean newLocation = this.location == null && location != null;
boolean locationChanged = this.location != null && location != null
&& this.location.getLatitude() != location.getLatitude()
&& this.location.getLongitude() != location.getLongitude();
if (newLocation || locationChanged) {
this.location = location;
updateLocationUi();
}
}
@Override
public void updateCompassValue(float value) {
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction)
// on non-compass devices
float lastHeading = heading != null ? heading : 99;
heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
updateLocationUi();
} else {
heading = lastHeading;
}
}
private OsmandApplication getMyApplication() {
if (getActivity() != null) {
return ((MapActivity) getActivity()).getMyApplication();
}
return null;
}
private void updateLocationUi() {
final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
if (location == null) {
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
}
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
adapter.setUseCenter(useCenter);
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading);
adapter.notifyDataSetChanged();
}
});
}
}
void startLocationUpdate() {
OsmandApplication app = getMyApplication();
if (app != null && !locationUpdateStarted) {
locationUpdateStarted = true;
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
app.getLocationProvider().addCompassListener(this);
app.getLocationProvider().addLocationListener(this);
updateLocationUi();
}
}
void stopLocationUpdate() {
OsmandApplication app = getMyApplication();
if (app != null && locationUpdateStarted) {
locationUpdateStarted = false;
app.getLocationProvider().removeLocationListener(this);
app.getLocationProvider().removeCompassListener(this);
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
}
}
}

View file

@ -0,0 +1,121 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import java.util.Arrays;
import java.util.List;
public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment {
public static final String TAG = "MapMarkersDialogFragment";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OsmandApplication app = getMyApplication();
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getContext(), "Options", Toast.LENGTH_SHORT).show();
}
});
final LockableViewPager viewPager = mainView.findViewById(R.id.map_markers_view_pager);
viewPager.setSwipeLocked(true);
final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager());
viewPager.setAdapter(adapter);
BottomNavigationView bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation);
bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_active:
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
viewPager.setCurrentItem(0);
return true;
case R.id.action_history:
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
viewPager.setCurrentItem(1);
return true;
}
return false;
}
});
return mainView;
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public static boolean showInstance(@NonNull MapActivity mapActivity) {
try {
if (mapActivity.isActivityDestroyed()) {
return false;
}
MapMarkersDialogFragment fragment = new MapMarkersDialogFragment();
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
private class MapMarkersViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> fragments;
MapMarkersViewPagerAdapter(FragmentManager fm) {
super(fm);
fragments = Arrays.asList(new MapMarkersActiveFragment(), new MapMarkersHistoryFragment());
}
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}
@Override
public int getCount() {
return fragments.size();
}
}
}

View file

@ -0,0 +1,20 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class MapMarkersHistoryFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
TextView textView = new TextView(getContext());
textView.setText("history fragment");
return textView;
}
}

View file

@ -0,0 +1,33 @@
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 MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
final ImageView iconDirection;
final ImageView iconReorder;
final ImageView icon;
final TextView title;
final TextView distance;
final TextView point;
final TextView description;
final ImageButton options;
public MapMarkerItemViewHolder(View view) {
super(view);
iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon);
iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon);
icon = (ImageView) view.findViewById(R.id.map_marker_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);
options = (ImageButton) view.findViewById(R.id.map_marker_options_button);
}
}

View file

@ -0,0 +1,103 @@
package net.osmand.plus.mapmarkers.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import java.util.List;
public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
private MapActivity mapActivity;
private List<MapMarker> markers;
private MapMarkersActiveAdapterListener listener;
private LatLon location;
private Float heading;
private boolean useCenter;
private int screenOrientation;
public MapMarkersActiveAdapter(MapActivity mapActivity) {
this.mapActivity = mapActivity;
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
}
public void setAdapterListener(MapMarkersActiveAdapterListener listener) {
this.listener = listener;
}
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
@Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listener.onItemClick(view);
}
});
return new MapMarkerItemViewHolder(view);
}
@Override
public void onBindViewHolder(MapMarkerItemViewHolder holder, int pos) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
MapMarker marker = markers.get(pos);
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
});
int color = MapMarker.getColorId(marker.colorIndex);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
holder.title.setText(marker.getName(mapActivity));
DashLocationFragment.updateLocationView(useCenter, location,
heading, holder.iconDirection, holder.distance,
marker.getLatitude(), marker.getLongitude(),
screenOrientation, mapActivity.getMyApplication(), mapActivity);
}
@Override
public int getItemCount() {
return markers.size();
}
public MapMarker getItem(int position) {
return markers.get(position);
}
public interface MapMarkersActiveAdapterListener {
void onItemClick(View view);
}
}

View file

@ -17,7 +17,6 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.DirectionDrawable;
@ -251,7 +250,7 @@ public class MapMarkersWidgetsFactory {
} else {
dd = (DirectionDrawable) arrowImg.getDrawable();
}
dd.setImage(R.drawable.ic_arrow_marker_diretion, MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex));
dd.setImage(R.drawable.ic_arrow_marker_diretion, MapMarker.getColorId(marker.colorIndex));
if (heading != null && loc != null) {
dd.setAngle(mes[1] - heading + 180 + screenOrientation);
}
@ -365,7 +364,7 @@ public class MapMarkersWidgetsFactory {
setImageDrawable(map.getMyApplication().getIconsCache()
.getIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
R.drawable.widget_marker_triangle,
MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex)));
MapMarker.getColorId(marker.colorIndex)));
cachedMarkerColorIndex = marker.colorIndex;
cachedNightMode = isNight();
res = true;