Open waypoint by click on fab

This commit is contained in:
PavelRatushny 2017-07-29 13:24:32 +03:00
parent cfe8fd102c
commit 7027ce98fd
2 changed files with 66 additions and 1 deletions

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/MainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ExpandableListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/ic_action_plus"
android:contentDescription="@string/quick_action_new_action"
app:backgroundTint="@color/dashboard_blue"/>
</RelativeLayout>

View file

@ -8,6 +8,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ActionMode;
@ -89,6 +90,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
private Set<Integer> selectedGroups = new LinkedHashSet<>();
private ActionMode actionMode;
private SearchView searchView;
private FloatingActionButton fab;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@ -106,10 +108,41 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.favorites_tree, container, false);
View view = inflater.inflate(R.layout.points_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
setHasOptionsMenu(true);
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
GpxDisplayItem item = null;
int groupCount = adapter.getGroupCount();
for (int i = 0; i < groupCount; i++) {
GpxDisplayGroup group = adapter.getGroup(i);
if (group.getType() == GpxDisplayItemType.TRACK_POINTS) {
int childrenCount = adapter.getChildrenCount(i);
item = adapter.getChild(i, childrenCount - 1);
}
}
if (item != null) {
if (item.group.getGpx() != null) {
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
}
final OsmandSettings settings = app.getSettings();
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
settings.getLastKnownMapZoom(),
new PointDescription(PointDescription.POINT_TYPE_WPT, item.name),
false,
item.locationStart);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
});
TextView tv = new TextView(getActivity());
tv.setText(R.string.none_selected_gpx);
tv.setTextSize(24);