Hide snackbar when open history tab

This commit is contained in:
Alexander Sytnyk 2017-09-07 13:20:37 +03:00
parent 23749c1088
commit cb81896166
3 changed files with 15 additions and 2 deletions

View file

@ -127,6 +127,10 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
}
}
void hideSnackbar() {
adapter.hideSnackbar();
}
private void updateLocationUi() {
final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {

View file

@ -88,6 +88,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
if (viewPager.getCurrentItem() != 1) {
((MapMarkersHistoryFragment) adapter.getItem(1)).updateAdapter();
((MapMarkersActiveFragment) adapter.getItem(0)).hideSnackbar();
}
viewPager.setCurrentItem(1);
optionsButton.setVisibility(View.GONE);

View file

@ -24,6 +24,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
private MapActivity mapActivity;
private List<MapMarker> markers;
private MapMarkersActiveAdapterListener listener;
private Snackbar snackbar;
private LatLon location;
private Float heading;
@ -103,14 +104,15 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory(marker);
notifyItemRemoved(position);
Snackbar.make(holder.itemView, R.string.item_removed, Snackbar.LENGTH_LONG)
snackbar = Snackbar.make(holder.itemView, R.string.item_removed, Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, position);
notifyItemInserted(position);
}
}).show();
});
snackbar.show();
}
});
@ -133,6 +135,12 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
return markers;
}
public void hideSnackbar() {
if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss();
}
}
@Override
public boolean onItemMove(int from, int to) {
Collections.swap(markers, from, to);