Show snackbar when activate marker from history
This commit is contained in:
parent
546c6c18a8
commit
ae2ef2a107
2 changed files with 27 additions and 0 deletions
|
@ -212,6 +212,9 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
|
|||
if (snackbar != null && snackbar.isShown()) {
|
||||
snackbar.dismiss();
|
||||
}
|
||||
if (adapter != null) {
|
||||
adapter.hideSnackbar();
|
||||
}
|
||||
}
|
||||
|
||||
private HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener createHistoryMarkerMenuListener() {
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -30,6 +34,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
private OsmandApplication app;
|
||||
private List<Object> items = new ArrayList<>();
|
||||
private MapMarkersHistoryAdapterListener listener;
|
||||
private Snackbar snackbar;
|
||||
|
||||
public MapMarkersHistoryAdapter(OsmandApplication app) {
|
||||
this.app = app;
|
||||
|
@ -130,6 +135,19 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
}
|
||||
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
||||
notifyItemRemoved(position);
|
||||
|
||||
snackbar = Snackbar.make(itemViewHolder.itemView, app.getString(R.string.marker_moved_to_active), Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
View snackBarView = snackbar.getView();
|
||||
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
|
||||
tv.setTextColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||
snackbar.show();
|
||||
}
|
||||
});
|
||||
itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
|
||||
|
@ -165,6 +183,12 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
}
|
||||
}
|
||||
|
||||
public void hideSnackbar() {
|
||||
if (snackbar != null && snackbar.isShown()) {
|
||||
snackbar.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Object item = items.get(position);
|
||||
|
|
Loading…
Reference in a new issue