Add weakReference check for ShowRouteInfoDialogFragment
This commit is contained in:
parent
7b86c16cf8
commit
15be7a3316
1 changed files with 10 additions and 5 deletions
|
@ -106,6 +106,7 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -151,6 +152,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
private int routeId;
|
private int routeId;
|
||||||
private String destinationStreetStr = "";
|
private String destinationStreetStr = "";
|
||||||
|
private boolean paused;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private RoutingHelper routingHelper;
|
private RoutingHelper routingHelper;
|
||||||
|
@ -414,7 +416,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
private void updateCards() {
|
private void updateCards() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && view != null) {
|
if (mapActivity != null) {
|
||||||
LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
|
LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
|
||||||
cardsContainer.removeAllViews();
|
cardsContainer.removeAllViews();
|
||||||
if (routeId != -1) {
|
if (routeId != -1) {
|
||||||
|
@ -1068,12 +1070,14 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
|
|
||||||
protected void updateDestinationStreetName(LatLon latLon) {
|
protected void updateDestinationStreetName(LatLon latLon) {
|
||||||
|
final WeakReference<ShowRouteInfoDialogFragment> fragmentRef = new WeakReference<>(ShowRouteInfoDialogFragment.this);
|
||||||
GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() {
|
GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() {
|
||||||
@Override
|
@Override
|
||||||
public void geocodingDone(String address) {
|
public void geocodingDone(String address) {
|
||||||
if (!TextUtils.isEmpty(address)) {
|
ShowRouteInfoDialogFragment fragment = fragmentRef.get();
|
||||||
destinationStreetStr = address;
|
if (!TextUtils.isEmpty(address) && fragment != null && !fragment.paused) {
|
||||||
updateCards();
|
fragment.destinationStreetStr = address;
|
||||||
|
fragment.updateCards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -1874,7 +1878,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
paused = false;
|
||||||
ViewParent parent = view.getParent();
|
ViewParent parent = view.getParent();
|
||||||
if (parent != null && containerLayoutListener != null) {
|
if (parent != null && containerLayoutListener != null) {
|
||||||
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
|
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
|
||||||
|
@ -1892,6 +1896,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
paused = true;
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
ViewParent parent = view.getParent();
|
ViewParent parent = view.getParent();
|
||||||
if (parent != null && containerLayoutListener != null) {
|
if (parent != null && containerLayoutListener != null) {
|
||||||
|
|
Loading…
Reference in a new issue