Add possibility to move marker to history; add small changes
This commit is contained in:
parent
7bca3f2850
commit
0dcb35b8d3
7 changed files with 40 additions and 9 deletions
|
@ -102,12 +102,12 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|end"
|
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:background="?attr/selectableItemBackground"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingLeft="14dp"
|
||||||
|
android:paddingRight="14dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
tools:src="@drawable/ic_overflow_menu_white"/>
|
tools:src="@drawable/ic_overflow_menu_white"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -121,6 +121,12 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateAdapter() {
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateLocationUi() {
|
private void updateLocationUi() {
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
|
@ -78,11 +78,17 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.action_active:
|
case R.id.action_active:
|
||||||
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
|
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
|
||||||
|
if (viewPager.getCurrentItem() != 0) {
|
||||||
|
((MapMarkersActiveFragment) adapter.getItem(0)).updateAdapter();
|
||||||
|
}
|
||||||
viewPager.setCurrentItem(0);
|
viewPager.setCurrentItem(0);
|
||||||
optionsButton.setVisibility(View.VISIBLE);
|
optionsButton.setVisibility(View.VISIBLE);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_history:
|
case R.id.action_history:
|
||||||
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
|
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
|
||||||
|
if (viewPager.getCurrentItem() != 1) {
|
||||||
|
((MapMarkersHistoryFragment) adapter.getItem(1)).updateAdapter();
|
||||||
|
}
|
||||||
viewPager.setCurrentItem(1);
|
viewPager.setCurrentItem(1);
|
||||||
optionsButton.setVisibility(View.GONE);
|
optionsButton.setVisibility(View.GONE);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -14,6 +14,8 @@ import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
|
||||||
|
|
||||||
public class MapMarkersHistoryFragment extends Fragment {
|
public class MapMarkersHistoryFragment extends Fragment {
|
||||||
|
|
||||||
|
MapMarkersHistoryAdapter adapter;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -21,8 +23,15 @@ public class MapMarkersHistoryFragment extends Fragment {
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
|
|
||||||
recyclerView.setAdapter(new MapMarkersHistoryAdapter(mapActivity.getMyApplication()));
|
adapter = new MapMarkersHistoryAdapter(mapActivity.getMyApplication());
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
return recyclerView;
|
return recyclerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateAdapter() {
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
final TextView distance;
|
final TextView distance;
|
||||||
final TextView point;
|
final TextView point;
|
||||||
final TextView description;
|
final TextView description;
|
||||||
final ImageButton options;
|
final ImageButton optionsBtn;
|
||||||
|
|
||||||
public MapMarkerItemViewHolder(View view) {
|
public MapMarkerItemViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
|
@ -28,6 +28,6 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
distance = (TextView) view.findViewById(R.id.map_marker_distance);
|
distance = (TextView) view.findViewById(R.id.map_marker_distance);
|
||||||
point = (TextView) view.findViewById(R.id.map_marker_point_text_view);
|
point = (TextView) view.findViewById(R.id.map_marker_point_text_view);
|
||||||
description = (TextView) view.findViewById(R.id.map_marker_description);
|
description = (TextView) view.findViewById(R.id.map_marker_description);
|
||||||
options = (ImageButton) view.findViewById(R.id.map_marker_options_button);
|
optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,18 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
|
||||||
|
|
||||||
holder.description.setText(marker.creationDate + "");
|
holder.description.setText(marker.creationDate + "");
|
||||||
|
|
||||||
|
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
|
||||||
|
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
int position = holder.getAdapterPosition();
|
||||||
|
MapMarker marker = markers.get(position);
|
||||||
|
mapActivity.getMyApplication().getMapMarkersHelper().removeMapMarker(marker.index);
|
||||||
|
mapActivity.getMyApplication().getMapMarkersHelper().addMapMarkerHistory(marker);
|
||||||
|
notifyItemRemoved(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
DashLocationFragment.updateLocationView(useCenter, location,
|
DashLocationFragment.updateLocationView(useCenter, location,
|
||||||
heading, holder.iconDirection, holder.distance,
|
heading, holder.iconDirection, holder.distance,
|
||||||
marker.getLatitude(), marker.getLongitude(),
|
marker.getLatitude(), marker.getLongitude(),
|
||||||
|
|
|
@ -39,8 +39,6 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItem
|
||||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||||
|
|
||||||
holder.title.setText(marker.getName(app));
|
holder.title.setText(marker.getName(app));
|
||||||
|
|
||||||
holder.description.setText(marker.creationDate + "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue