Fix displaying markers in landscape
This commit is contained in:
parent
44e15244fa
commit
7eb1f932cd
4 changed files with 74 additions and 14 deletions
|
@ -107,11 +107,44 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/markers_recycler_view"
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_weight="0.55"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_markers_layout"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"/>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
osmand:cardUseCompatPadding="true"
|
||||
osmand:cardCornerRadius="8dp">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:id="@+id/markers_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_weight="0.45"
|
||||
|
|
|
@ -144,6 +144,11 @@
|
|||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/map_markers_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="72dp"
|
||||
|
@ -152,6 +157,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -201,9 +201,18 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
|
||||
changeKeyboardInBoxes();
|
||||
|
||||
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView) mainView.findViewById(R.id.markers_recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
adapter = new CoordinateInputAdapter(mapActivity, mapMarkers);
|
||||
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||
@Override
|
||||
public void onChanged() {
|
||||
super.onChanged();
|
||||
mapMarkersLayout.setVisibility(adapter.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
|
@ -304,8 +313,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (getDialog() != null && getRetainInstance()) {
|
||||
getDialog().setDismissMessage(null);
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null && getRetainInstance()) {
|
||||
dialog.setDismissMessage(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,11 +30,13 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
private Float heading;
|
||||
private boolean useCenter;
|
||||
private int screenOrientation;
|
||||
private boolean portrait;
|
||||
|
||||
public CoordinateInputAdapter (MapActivity mapActivity, List<MapMarker> mapMarkers) {
|
||||
this.mapActivity = mapActivity;
|
||||
nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
this.mapMarkers = mapMarkers;
|
||||
}
|
||||
|
||||
|
@ -86,11 +89,14 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
}
|
||||
});
|
||||
|
||||
boolean singleItem = getItemCount() == 1;
|
||||
boolean fistItem = position == 0;
|
||||
boolean lastItem = position == getItemCount() - 1;
|
||||
if (portrait) {
|
||||
holder.topDivider.setVisibility(fistItem ? View.VISIBLE : View.GONE);
|
||||
holder.divider.setVisibility((getItemCount() > 1 && !lastItem) ? View.VISIBLE : View.GONE);
|
||||
holder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
holder.divider.setVisibility((!singleItem && !lastItem) ? View.VISIBLE : View.GONE);
|
||||
|
||||
holder.title.setText(mapMarker.getName(mapActivity));
|
||||
|
||||
|
@ -105,6 +111,10 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
return mapMarkers.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getItemCount() == 0;
|
||||
}
|
||||
|
||||
public MapMarker getItem(int position) {
|
||||
return mapMarkers.get(position);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue