Show target points in dashboard waypoints fragment
This commit is contained in:
parent
c2eb1bb585
commit
b1535477af
1 changed files with 1 additions and 52 deletions
|
@ -3,7 +3,6 @@ package net.osmand.plus.dashboard;
|
|||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -24,10 +23,6 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -62,54 +57,8 @@ public class DashWaypointsFragment extends DashLocationFragment {
|
|||
}
|
||||
|
||||
public void setupView() {
|
||||
if(getMyApplication().getWaypointHelper().isRouteCalculated()) {
|
||||
setupWaypoints();
|
||||
} else {
|
||||
setupTargets();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWaypoints() {
|
||||
FragmentActivity activity = getActivity();
|
||||
View mainView = getView();
|
||||
if (activity != null && mainView != null) {
|
||||
WaypointHelper wh = getMyApplication().getWaypointHelper();
|
||||
List<LocationPointWrapper> allPoints = wh.getAllPoints();
|
||||
if (allPoints.size() == 0) {
|
||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
|
||||
return;
|
||||
} else {
|
||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.shared_string_waypoints));
|
||||
((Button) mainView.findViewById(R.id.show_all)).setText(getString(R.string.shared_string_show_all));
|
||||
((Button) mainView.findViewById(R.id.show_all)).setVisibility(View.VISIBLE);
|
||||
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
dashboard.hideDashboard();
|
||||
WaypointsFragment.showInstance((MapActivity) activity);
|
||||
}
|
||||
}
|
||||
});
|
||||
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
|
||||
favorites.removeAllViews();
|
||||
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
for (int i = 0; i < 3 && i < allPoints.size(); i++) {
|
||||
LocationPointWrapper ps = allPoints.get(i);
|
||||
View dv = activity.getLayoutInflater().inflate(R.layout.divider, null);
|
||||
favorites.addView(dv);
|
||||
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
|
||||
activity, null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
|
||||
favorites.addView(v);
|
||||
|
||||
}
|
||||
this.distances = distances;
|
||||
}
|
||||
}
|
||||
|
||||
public void setupTargets() {
|
||||
View mainView = getView();
|
||||
|
|
Loading…
Reference in a new issue