Merge pull request #4517 from osmandapp/sasha_pasha_branch

Sasha pasha branch
This commit is contained in:
Alexey 2017-10-03 11:26:26 +03:00 committed by GitHub
commit 850881d562

View file

@ -78,6 +78,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
private boolean portrait; private boolean portrait;
private boolean markersListOpened; private boolean markersListOpened;
private boolean wasCollapseButtonVisible; private boolean wasCollapseButtonVisible;
private boolean uiUpdateAllowed = true;
private View mainView; private View mainView;
private RecyclerView markersRv; private RecyclerView markersRv;
@ -234,6 +235,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override @Override
public void onDragStarted(RecyclerView.ViewHolder holder) { public void onDragStarted(RecyclerView.ViewHolder holder) {
uiUpdateAllowed = false;
fromPosition = holder.getAdapterPosition(); fromPosition = holder.getAdapterPosition();
touchHelper.startDrag(holder); touchHelper.startDrag(holder);
} }
@ -251,7 +253,10 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
// to avoid crash because of: // to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling // java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
} }
updateText();
showMarkersRouteOnMap();
} }
uiUpdateAllowed = true;
} }
}); });
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600; boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
@ -259,6 +264,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
markersRv.setClipToPadding(false); markersRv.setClipToPadding(false);
markersRv.setLayoutManager(new LinearLayoutManager(getContext())); markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
markersRv.setAdapter(adapter); markersRv.setAdapter(adapter);
markersRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
uiUpdateAllowed = newState == RecyclerView.SCROLL_STATE_IDLE;
}
});
final int screenH = AndroidUtils.getScreenHeight(mapActivity); final int screenH = AndroidUtils.getScreenHeight(mapActivity);
final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity); final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
@ -520,6 +532,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
private void updateLocationUi() { private void updateLocationUi() {
if (!uiUpdateAllowed) {
return;
}
final MapActivity mapActivity = (MapActivity) getActivity(); final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null && adapter != null) { if (mapActivity != null && adapter != null) {
mapActivity.getMyApplication().runInUIThread(new Runnable() { mapActivity.getMyApplication().runInUIThread(new Runnable() {
@ -747,8 +762,8 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
if (i == 0 && startFromLoc) { if (i == 0 && startFromLoc) {
continue; continue;
} }
int index = sequence[startFromLoc ? i - 1 : i]; int index = sequence[i];
res.add(selectedMarkers.get(index)); res.add(selectedMarkers.get(startFromLoc ? index - 1 : index));
} }
return res; return res;
@ -771,8 +786,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res); mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
updateText();
showMarkersRouteOnMap();
} }
}.execute(); }.execute();
} }