Merge pull request #4517 from osmandapp/sasha_pasha_branch
Sasha pasha branch
This commit is contained in:
commit
850881d562
1 changed files with 19 additions and 3 deletions
|
@ -78,6 +78,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
private boolean portrait;
|
||||
private boolean markersListOpened;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean uiUpdateAllowed = true;
|
||||
|
||||
private View mainView;
|
||||
private RecyclerView markersRv;
|
||||
|
@ -234,6 +235,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
|
||||
@Override
|
||||
public void onDragStarted(RecyclerView.ViewHolder holder) {
|
||||
uiUpdateAllowed = false;
|
||||
fromPosition = holder.getAdapterPosition();
|
||||
touchHelper.startDrag(holder);
|
||||
}
|
||||
|
@ -251,7 +253,10 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
// to avoid crash because of:
|
||||
// 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;
|
||||
|
@ -259,6 +264,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
markersRv.setClipToPadding(false);
|
||||
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
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 statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
|
@ -520,6 +532,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
}
|
||||
|
||||
private void updateLocationUi() {
|
||||
if (!uiUpdateAllowed) {
|
||||
return;
|
||||
}
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null && adapter != null) {
|
||||
mapActivity.getMyApplication().runInUIThread(new Runnable() {
|
||||
|
@ -747,8 +762,8 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
if (i == 0 && startFromLoc) {
|
||||
continue;
|
||||
}
|
||||
int index = sequence[startFromLoc ? i - 1 : i];
|
||||
res.add(selectedMarkers.get(index));
|
||||
int index = sequence[i];
|
||||
res.add(selectedMarkers.get(startFromLoc ? index - 1 : index));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -771,8 +786,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
|||
}
|
||||
|
||||
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
updateText();
|
||||
showMarkersRouteOnMap();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue