Search in sources :

Example 1 with StationPickerView

use of im.tny.segvault.disturbances.ui.widget.StationPickerView in project underlx by underlx.

the class RouteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setUpActivity(getString(R.string.frag_route_title), R.id.nav_plan_route, false, false);
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_route, container, false);
    layoutNetworkClosed = (LinearLayout) view.findViewById(R.id.network_closed_layout);
    viewNetworkClosed = (TextView) view.findViewById(R.id.network_closed_view);
    layoutRoute = (LinearLayout) view.findViewById(R.id.layout_route);
    layoutOriginStationClosed = (LinearLayout) view.findViewById(R.id.origin_station_closed_layout);
    layoutDestinationStationClosed = (LinearLayout) view.findViewById(R.id.destination_station_closed_layout);
    viewOriginStationClosed = (TextView) view.findViewById(R.id.origin_station_closed_view);
    viewDestinationStationClosed = (TextView) view.findViewById(R.id.destination_station_closed_view);
    layoutInstructions = (LinearLayout) view.findViewById(R.id.layout_instructions);
    layoutBottomSheet = (RelativeLayout) view.findViewById(R.id.bottom_sheet_layout);
    swapButton = (ImageButton) view.findViewById(R.id.swap_button);
    swapButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Station o = originPicker.getSelection();
            originPicker.setSelection(destinationPicker.getSelection());
            destinationPicker.setSelection(o);
            tryPlanRoute();
        }
    });
    navigationStartButton = (Button) view.findViewById(R.id.navigation_start_button);
    navigationStartButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            S2LS loc = mListener.getMainService().getS2LS(networkId);
            if (loc != null && route != null) {
                loc.setCurrentTargetRoute(route, false);
                switchToPage("nav_home");
            }
        }
    });
    useRealtimeCheckbox = (CheckBox) view.findViewById(R.id.use_realtime_check);
    useRealtimeCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            tryPlanRoute();
        }
    });
    routeEtaView = (TextView) view.findViewById(R.id.route_eta_view);
    originPicker = (StationPickerView) view.findViewById(R.id.origin_picker);
    destinationPicker = (StationPickerView) view.findViewById(R.id.destination_picker);
    IntentFilter filter = new IntentFilter();
    filter.addAction(MainActivity.ACTION_MAIN_SERVICE_BOUND);
    filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(getContext());
    bm.registerReceiver(mBroadcastReceiver, filter);
    if (mListener != null && mListener.getMainService() != null) {
        network = mListener.getMainService().getNetwork(networkId);
        loc = mListener.getMainService().getS2LS(networkId);
        // the network map might not be loaded yet
        if (network != null && loc != null) {
            populatePickers();
            updateClosedWarning();
        }
    }
    return view;
}
Also used : Station(im.tny.segvault.subway.Station) S2LS(im.tny.segvault.s2ls.S2LS) IntentFilter(android.content.IntentFilter) ImageView(android.widget.ImageView) StationPickerView(im.tny.segvault.disturbances.ui.widget.StationPickerView) View(android.view.View) TextView(android.widget.TextView) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) CompoundButton(android.widget.CompoundButton)

Aggregations

IntentFilter (android.content.IntentFilter)1 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 StationPickerView (im.tny.segvault.disturbances.ui.widget.StationPickerView)1 S2LS (im.tny.segvault.s2ls.S2LS)1 Station (im.tny.segvault.subway.Station)1