[ADD] Start Route button from other branch

This commit is contained in:
Robin Koedood
2021-01-06 13:55:20 +01:00
parent ca8d291262
commit 8a758f1d8d

View File

@@ -11,9 +11,12 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.data.RouteHandler;
import com.a1.nextlocation.network.ApiHandler;
public class RouteDetailFragment extends Fragment {
@@ -47,7 +50,18 @@ public class RouteDetailFragment extends Fragment {
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
});
Button startButton = view.findViewById(R.id.start_route_button);
startButton.setOnClickListener(this::startRoute);
return view;
}
public void startRoute(View view) {
ApiHandler.INSTANCE.getDirections(route);
RouteHandler.INSTANCE.followRoute(route);
Toast.makeText(requireContext(),"Route started!",Toast.LENGTH_SHORT).show();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).addToBackStack(null).commit();
}
}