public GPSTracker GetGpsTracker(Context context) { if (_gpsTracker != null) { return _gpsTracker; } else { _gpsTracker = new GPSTracker(this); return _gpsTracker; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fa = base.Activity; ll = (RelativeLayout) inflater.Inflate(Resource.Layout.FightIt, container, false); _gpsTracker = ((AfaApplication)fa.ApplicationContext).GetGpsTracker(fa); //_loadingDialog = LoadingDialogManager.ShowLoadingDialog (fa); _crueltySpotsList = ll.FindViewById<ListView>(Resource.Id.CrueltySpots); _crueltySpotsList.ItemClick += (sender, e) => { var crueltySpot = _crueltySpots[e.Position]; NavigateToCrueltySpotDetails(crueltySpot.ObjectId); }; _loadingDialog = DialogManager.ShowLoadingDialog(this.Activity, "Retrieving Cruelty Spots"); LoadCrueltySpots(); return ll; }
protected override void OnCreate(Bundle bundle) { DebugHelper.WriteDebugEntry("In IntroActivity OnCreate()"); base.OnCreate(bundle); SetContentView(Resource.Layout.Intro); _gpsTracker = ((AfaApplication)ApplicationContext).GetGpsTracker(this); _listToggleButton = FindViewById<Button>(Resource.Id.ListButton); SupportActionBar.NavigationMode = SherlockActionBar.NavigationModeTabs; SherlockActionBar.Tab trackItTab = SupportActionBar.NewTab(); trackItTab.SetText("Fight It"); trackItTab.SetTabListener(this); trackItTab.SetTag("track"); SupportActionBar.AddTab(trackItTab); SherlockActionBar.Tab reportItTab = SupportActionBar.NewTab(); reportItTab.SetText("Report It"); reportItTab.SetTabListener(this); reportItTab.SetTag("report"); SupportActionBar.AddTab(reportItTab); string tabFromIntent = Intent.GetStringExtra("tab") ?? null; if (tabFromIntent != null) { _currentTabTag = tabFromIntent; } else if (bundle != null) { _currentTabTag = bundle.GetString("tab") ?? ""; } else { _currentTabTag = ""; } DebugHelper.WriteDebugEntry("Selecting Tab"); switch (_currentTabTag.ToLower()) { case "report": SupportActionBar.SelectTab(reportItTab); break; default: SupportActionBar.SelectTab(trackItTab); break; } _listToggleButton.Click += (o, e) => { _isMapView = !_isMapView; SupportActionBar.SelectTab(trackItTab); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Places); _gpsTracker = ((AfaApplication)ApplicationContext).GetGpsTracker(this); _googlePlaces = new GooglePlacesApi.GooglePlaces(AfaConfig.GoogleApiKey); _loading = DialogManager.ShowLoadingDialog(this, "Retrieving Nearby Places"); Log.Debug("Position Lat:", _gpsTracker.Latitude.ToString()); Log.Debug("Position Lng:", _gpsTracker.Longitude.ToString()); _placesListView = FindViewById<ListView>(Resource.Id.Places); var layout = new LinearLayout(this); _loadMoreButton = new Button(this); _loadMoreButton.Text = "Load More Results"; _loadMoreButton.LayoutParameters = new TableLayout.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.WrapContent, 1f); layout.AddView(_loadMoreButton); _addNewPlaceButton = new Button(this); _addNewPlaceButton.Text = "Add New"; _addNewPlaceButton.LayoutParameters = new TableLayout.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.WrapContent, 1f); layout.AddView(_addNewPlaceButton); _placesListView.AddFooterView(layout); _loadMoreButton.Click += (sender, args) => FetchMoreResults(); _addNewPlaceButton.Click += (sender, args) => { var intent = new Intent(this, typeof (AddPlaceActivity)); StartActivity(intent); }; DoPlacesSearch(); var searchButton = FindViewById<ImageButton>(Resource.Id.searchButton); searchButton.Click += (sender, args) => { _loading.Show(); var inputManager = (InputMethodManager) GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); var placeNameInput = FindViewById<EditText>(Resource.Id.placeNameSearch); var locationNameInput = FindViewById<EditText>(Resource.Id.locationSearch); var placeNameSpecified = !String.IsNullOrWhiteSpace(placeNameInput.Text); var locationNameSpecified = !String.IsNullOrWhiteSpace(locationNameInput.Text); if (!placeNameSpecified && !locationNameSpecified) { // Nothing specified, do default search DoPlacesSearch(); } else if (locationNameSpecified) { _googlePlaces.Search(this, locationNameInput.Text, PlaceTypes, placeNameInput.Text, SearchCallback); } else { _googlePlaces.Search(_gpsTracker.Latitude, _gpsTracker.Longitude, PlaceTypes, placeNameInput.Text, SearchCallback); } }; }