From 2eb10ce57dfac161e65ceb3514be2ec6afd101c4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 20 Oct 2014 21:43:15 +0200 Subject: [PATCH] Fix NPE Conflicts: OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java --- .../plus/helpers/WaypointDialogHelper.java | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index f7053535f8..91e9ad5b38 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -3,7 +3,6 @@ package net.osmand.plus.helpers; import java.util.ArrayList; import java.util.List; -import android.widget.*; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; @@ -35,6 +34,15 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.CompoundButton; +import android.widget.FrameLayout; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; /** */ @@ -84,29 +92,16 @@ public class WaypointDialogHelper implements OsmAndLocationListener { removeDialog(); } else { boolean created = false; - if (closePointDialog == null) { + View dlg = closePointDialog; + if (dlg == null) { created = true; final LayoutInflater vi = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - closePointDialog = vi.inflate(R.layout.waypoint_reached, null); + dlg = vi.inflate(R.layout.waypoint_reached, null); } - updatePointInfoView(app, mapActivity, closePointDialog, point, null); - View all = closePointDialog.findViewById(R.id.all_points); + updatePointInfoView(app, mapActivity, dlg, point, null); + View all = dlg.findViewById(R.id.all_points); all.setVisibility(/*many.size() <= 1 ? View.GONE : */View.VISIBLE); - if (created) { - closePointDialog.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.view_black_selection)); - ((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE); - all.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - showWaypointsDialog(mapActivity); - } - }); - - - mainLayout.addView(closePointDialog, getDialogLayoutParams()); - waitBeforeLayoutIsResized(closePointDialog); - } - View btnN = closePointDialog.findViewById(R.id.info_close); + View btnN = dlg.findViewById(R.id.info_close); btnN.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -114,6 +109,21 @@ public class WaypointDialogHelper implements OsmAndLocationListener { updateDialog(); } }); + if (created) { + dlg.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.view_black_selection)); + ((TextView) dlg.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE); + all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showWaypointsDialog(mapActivity); + } + }); + + closePointDialog = dlg; + mainLayout.addView(closePointDialog, getDialogLayoutParams()); + waitBeforeLayoutIsResized(dlg); + } + } }