@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.route_widget, container, false); ButterKnife.inject(this, rootView); fragment = this; adapter = new RouteAdapter(act, instructions, fragment); adapter.setDestinationName(simpleFeature.getProperty(TEXT)); TextView destinationName = (TextView) rootView.findViewById(R.id.destination_name); destinationName.setText(getString(R.string.routing_to_text) + simpleFeature.getProperty(TEXT)); if (route != null) { distanceToDestination.setDistance(route.getTotalDistance()); } pager.setAdapter(adapter); pager.setOnPageChangeListener(this); adapter.notifyDataSetChanged(); currentXCor = mapFragment.getMap().getMapPosition().getX(); initSpeakerbox(); initNotificationCreator(); pager.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { turnAutoPageOff(); return false; } }); initDebugView(rootView); initSlideLayout(rootView); setMapOnTouchListener(); res = act.getResources(); prefs = getDefaultSharedPreferences(act); if (LocationServices.FusedLocationApi != null) { if (prefs.getBoolean(getString(R.string.settings_mock_gpx_key), false)) { final String key = getString(R.string.settings_mock_gpx_filename_key); final String defaultFile = getString(R.string.settings_mock_gpx_filename_default_value); final String filename = prefs.getString(key, defaultFile); final File file = new File(Environment.getExternalStorageDirectory(), filename); LocationServices.FusedLocationApi.setMockMode(true); LocationServices.FusedLocationApi.setMockTrace(file); } else { LocationServices.FusedLocationApi.setMockMode(false); } } hideLocateButtonAndAttribution(); return rootView; }
@Override public void onDestroy() { app.activateMoveMapToLocation(); teardownLinedrawing(); markReadyForUpload(); mapController.clearLines(); act.updateView(); bus.unregister(this); showLocateButton(); if (LocationServices.FusedLocationApi != null) { LocationServices.FusedLocationApi.setMockMode(false); } super.onDestroy(); }