Fix possible npe after new wpt point was added
This commit is contained in:
parent
95cc20b022
commit
638489fcdf
2 changed files with 23 additions and 5 deletions
|
@ -61,6 +61,13 @@
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/amenity_type_finance"/>
|
android:text="@string/amenity_type_finance"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/context_menu_custom_address_line"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -58,6 +58,7 @@ import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.LockableScrollView;
|
import net.osmand.plus.LockableScrollView;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.settings.backend.MainContextMenuItemsSettings;
|
import net.osmand.plus.settings.backend.MainContextMenuItemsSettings;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -1674,6 +1675,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
line2MeasuredHeight = line2.getMeasuredHeight();
|
line2MeasuredHeight = line2.getMeasuredHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int customAddressLineHeight = 0;
|
||||||
|
View customAddressLine = view.findViewById(R.id.context_menu_custom_address_line);
|
||||||
|
if (customAddressLine.getVisibility() == View.VISIBLE) {
|
||||||
|
customAddressLineHeight = customAddressLine.getMeasuredHeight();
|
||||||
|
}
|
||||||
|
|
||||||
int line3Height = 0;
|
int line3Height = 0;
|
||||||
View line3Container = view.findViewById(R.id.additional_info_row_container);
|
View line3Container = view.findViewById(R.id.additional_info_row_container);
|
||||||
if (line3Container.getVisibility() == View.VISIBLE) {
|
if (line3Container.getVisibility() == View.VISIBLE) {
|
||||||
|
@ -1717,12 +1724,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
|
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
|
||||||
}
|
}
|
||||||
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight
|
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight
|
||||||
+ titleButtonHeight + downloadButtonsHeight
|
+ titleButtonHeight + customAddressLineHeight + downloadButtonsHeight
|
||||||
+ titleBottomButtonHeight + additionalButtonsHeight + titleProgressHeight + line3Height;
|
+ titleBottomButtonHeight + additionalButtonsHeight + titleProgressHeight + line3Height;
|
||||||
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight
|
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight
|
||||||
- (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
|
- (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
|
||||||
} else {
|
} else {
|
||||||
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight
|
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - customAddressLineHeight
|
||||||
- titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height;
|
- titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height;
|
||||||
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
|
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
|
||||||
+ (line2MeasuredHeight - line2LineCount * line2LineHeight);
|
+ (line2MeasuredHeight - line2LineCount * line2LineHeight);
|
||||||
|
@ -1818,12 +1825,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
line1.setText(menu.getTitleStr());
|
line1.setText(menu.getTitleStr());
|
||||||
toolbarTextView.setText(menu.getTitleStr());
|
toolbarTextView.setText(menu.getTitleStr());
|
||||||
// Text line 2
|
// Text line 2
|
||||||
LinearLayout line2layout = view.findViewById(R.id.context_menu_line2_layout);
|
|
||||||
TextView line2 = view.findViewById(R.id.context_menu_line2);
|
TextView line2 = view.findViewById(R.id.context_menu_line2);
|
||||||
|
LinearLayout customAddressLine = view.findViewById(R.id.context_menu_custom_address_line);
|
||||||
|
customAddressLine.removeAllViews();
|
||||||
if (menu.hasCustomAddressLine()) {
|
if (menu.hasCustomAddressLine()) {
|
||||||
line2layout.removeAllViews();
|
menu.buildCustomAddressLine(customAddressLine);
|
||||||
menu.buildCustomAddressLine(line2layout);
|
AndroidUiHelper.updateVisibility(line2, false);
|
||||||
|
AndroidUiHelper.updateVisibility(customAddressLine, true);
|
||||||
} else {
|
} else {
|
||||||
|
AndroidUiHelper.updateVisibility(line2, true);
|
||||||
|
AndroidUiHelper.updateVisibility(customAddressLine, false);
|
||||||
String typeStr = menu.getTypeStr();
|
String typeStr = menu.getTypeStr();
|
||||||
String streetStr = menu.getStreetStr();
|
String streetStr = menu.getStreetStr();
|
||||||
StringBuilder line2Str = new StringBuilder();
|
StringBuilder line2Str = new StringBuilder();
|
||||||
|
|
Loading…
Reference in a new issue