Fix context menu crash
This commit is contained in:
parent
8043cfdad9
commit
c5dea0bc13
1 changed files with 53 additions and 41 deletions
|
@ -708,7 +708,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
private void buildHeader() {
|
||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
|
||||
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
|
||||
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
|
||||
|
@ -726,6 +728,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
setAddressLocation();
|
||||
}
|
||||
}
|
||||
|
||||
private void buildBottomView() {
|
||||
View bottomView = view.findViewById(R.id.context_menu_bottom_view);
|
||||
|
@ -785,7 +788,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
public void rebuildMenu() {
|
||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
|
||||
buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(),
|
||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
|
@ -799,6 +804,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
private void runLayoutListener() {
|
||||
|
@ -961,8 +967,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
private void updateCompassVisibility() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
View compassView = view.findViewById(R.id.compass_layout);
|
||||
Location ll = getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
Location ll = app.getLocationProvider().getLastKnownLocation();
|
||||
boolean gpsFixed = ll != null && System.currentTimeMillis() - ll.getTime() < 1000 * 60 * 60 * 20;
|
||||
if (gpsFixed && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||
updateDistanceDirection();
|
||||
|
@ -975,14 +983,18 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistanceDirection() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
FragmentActivity activity = getActivity();
|
||||
if (app != null && activity != null) {
|
||||
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
||||
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
||||
|
||||
float myHeading = menu.getHeading() == null ? 0f : menu.getHeading();
|
||||
DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, distanceText,
|
||||
menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, getMyApplication(), getActivity());
|
||||
menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
|
||||
}
|
||||
}
|
||||
|
||||
private int getPosY() {
|
||||
|
|
Loading…
Reference in a new issue