public override void OnClick(Fragment source, int buttonId, object context) { base.OnClick(source, buttonId, context); // only handle input if the springboard is closed if (NavbarFragment.ShouldTaskAllowInput( )) { // decide what to do. if (source == MainPage) { ConnectLink linkEntry = (ConnectLink)context; // group finder is the only connect link that doesn't use an embedded webView. if (linkEntry.Title == ConnectStrings.Main_Connect_GroupFinder) { // launch group finder (and have it auto-show the search) GroupFinder.ShowSearchOnAppear = true; // if we're logged in, give it a starting address if (MobileApp.Shared.Network.RockMobileUser.Instance.LoggedIn == true && MobileApp.Shared.Network.RockMobileUser.Instance.HasFullAddress( )) { GroupFinder.SetSearchAddress(MobileApp.Shared.Network.RockMobileUser.Instance.Street1( ), MobileApp.Shared.Network.RockMobileUser.Instance.City( ), MobileApp.Shared.Network.RockMobileUser.Instance.State( ), MobileApp.Shared.Network.RockMobileUser.Instance.Zip( )); } PresentFragment(GroupFinder, true); } else { // launch the ConnectWebFragment. TaskWebFragment.HandleUrl(false, true, linkEntry.Url, this, WebFragment); } } else if (source == GroupFinder) { // turn off auto-show search so that if the user presses 'back', we don't pop it up again. GroupFinder.ShowSearchOnAppear = false; MobileAppApi.GroupSearchResult entry = (MobileAppApi.GroupSearchResult)context; GroupInfo.GroupEntry = entry; PresentFragment(GroupInfo, true); } else if (source == GroupInfo) { MobileAppApi.GroupSearchResult entry = (MobileAppApi.GroupSearchResult)context; JoinGroup.GroupTitle = entry.Name; JoinGroup.Distance = string.Format("{0:##.0} {1}", entry.DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix); JoinGroup.GroupID = entry.Id; JoinGroup.MeetingTime = string.IsNullOrEmpty(entry.MeetingTime) == false ? entry.MeetingTime : ConnectStrings.GroupFinder_ContactForTime; PresentFragment(JoinGroup, true); } } }
public void DisplayView(MobileAppApi.GroupSearchResult groupEntry, HttpRequest.RequestResult resultHandler) { // store the group and callback so that if it fails we can let them tap 'retry' and try again GroupEntry = groupEntry; GroupSummaryResult = resultHandler; Internal_DisplayView( ); }
IMKAnnotation TableRowToMapAnnotation(int row) { MobileAppApi.GroupSearchResult selectedGroup = GroupEntries[row]; CLLocationCoordinate2D selectedCoord = new CLLocationCoordinate2D(selectedGroup.Latitude, selectedGroup.Longitude); // given the row index of a group entry, return its associated annotation // select the matching marker foreach (IMKAnnotation marker in MapView.Annotations) { if (marker.Coordinate.Latitude == selectedCoord.Latitude || marker.Coordinate.Longitude == selectedCoord.Longitude) { return(marker); } } return(null); }
int MapAnnotationToTableRow(IMKAnnotation marker) { // given a map annotation, we'll go thru each group entry and compare the coordinates // to find the matching location. for (int i = 0; i < GroupEntries.Count; i++) { // find the row index by matching coordinates MobileAppApi.GroupSearchResult currGroup = GroupEntries[i]; CLLocationCoordinate2D currCoord = new CLLocationCoordinate2D(currGroup.Latitude, currGroup.Longitude); if (marker.Coordinate.Latitude == currCoord.Latitude && marker.Coordinate.Longitude == currCoord.Longitude) { return(i); } } return(-1); }
void OnJoinClicked( ) { // launch the join group UI GroupFinderJoinViewController joinController = new GroupFinderJoinViewController(); // set the group info MobileAppApi.GroupSearchResult currGroup = GroupEntry; joinController.GroupTitle = currGroup.Name; joinController.MeetingTime = string.IsNullOrEmpty(currGroup.MeetingTime) == false ? currGroup.MeetingTime : ConnectStrings.GroupFinder_ContactForTime; joinController.GroupID = currGroup.Id; joinController.Distance = string.Format("{0:##.0} {1}", currGroup.DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix); /*if ( row == 0 ) * { * joinController.Distance += " " + ConnectStrings.GroupFinder_ClosestTag; * }*/ // launch the view Task.PerformSegue(this, joinController); }
public static void GetGroups(int groupTypeId, string street, string city, string state, string zip, int skip, int top, GetGroupsComplete onCompletion) { MobileAppApi.GroupSearchResult sourceLocation = new MobileAppApi.GroupSearchResult( ); // first convert the address into a location object RockApi.Get_Locations_FromAddress(street, city, state, zip, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, Rock.Client.Location model) { // verify the call was successful AND it resulted in a valid location if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true && model != null && model.Latitude.HasValue == true && model.Longitude.HasValue == true) { // take the source location so we can provide it to the caller sourceLocation.Latitude = model.Latitude.Value; sourceLocation.Longitude = model.Longitude.Value; MobileAppApi.GetPublicGroupsByLocation(groupTypeId, model.Id, skip, top, delegate(List <MobileAppApi.GroupSearchResult> searchResults) { if (searchResults != null) { onCompletion(sourceLocation, searchResults, true); } else { // pass on empty list on failure onCompletion(sourceLocation, new List <MobileAppApi.GroupSearchResult>(), false); } }); } else { onCompletion(sourceLocation, new List <MobileAppApi.GroupSearchResult>( ), Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true ? true : false); } }); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return(null); } GroupEntries = new List <MobileAppApi.GroupSearchResult>(); MarkerList = new List <Android.Gms.Maps.Model.Marker>(); SourceLocation = new MobileAppApi.GroupSearchResult(); // limit the address to 90% of the screen so it doesn't conflict with the progress bar. Point displaySize = new Point( ); Activity.WindowManager.DefaultDisplay.GetSize(displaySize); //float fixedWidth = displaySize.X / 4.0f; // catch any exceptions thrown, as they'll be related to no map API key try { MapView = new Android.Gms.Maps.MapView(Rock.Mobile.PlatformSpecific.Android.Core.Context); MapView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); MapView.LayoutParameters.Height = (int)(displaySize.Y * .50f); MapView.GetMapAsync(this); MapView.SetBackgroundColor(Color.Black); MapView.OnCreate(savedInstanceState); } catch { MapView = null; Rock.Mobile.Util.Debug.WriteLine("GOOGLE MAPS: Unable to create. Verify you have a valid API KEY."); } NumRequestedGroups = 10; SearchAddressButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context); SearchAddressButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); ControlStyling.StyleButton(SearchAddressButton, ConnectStrings.GroupFinder_SearchButtonLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); SearchAddressButton.Click += (object sender, EventArgs e) => { SearchPage.Show( ); }; // setup the linear layout containing the "Your Neighborhood is: Horizon" text SearchLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context); SearchLayout.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); SearchLayout.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color)); SearchLayout.SetGravity(GravityFlags.Center); SearchResultPrefix = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context); SearchResultPrefix.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); SearchResultPrefix.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal); SearchResultPrefix.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize); SearchResultPrefix.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor)); SearchResultPrefix.Text = ConnectStrings.GroupFinder_NoGroupsFound; SearchResultNeighborhood = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context); SearchResultNeighborhood.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); SearchResultNeighborhood.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal); SearchResultNeighborhood.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize); SearchResultNeighborhood.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor)); SearchResultNeighborhood.Text = ""; Seperator = new View(Rock.Mobile.PlatformSpecific.Android.Core.Context); Seperator.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 0); Seperator.LayoutParameters.Height = 2; Seperator.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor)); ListView = new ListView(Rock.Mobile.PlatformSpecific.Android.Core.Context); ListView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); ListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { OnClick(e.Position, 0); }; ListView.SetOnTouchListener(this); ListView.Adapter = new GroupArrayAdapter(this); View view = inflater.Inflate(Resource.Layout.Connect_GroupFinder, container, false); view.SetOnTouchListener(this); view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color)); LinearLayout groupLayout = view.FindViewById <LinearLayout>(Resource.Id.groupFrame) as LinearLayout; // setup the address layout, which has the address text, padding, and finally the progress bar. if (MapView != null) { ((LinearLayout)groupLayout).AddView(MapView); } ((LinearLayout)groupLayout).AddView(SearchAddressButton); ((LinearLayout)groupLayout).AddView(SearchLayout); ((LinearLayout)SearchLayout).AddView(SearchResultPrefix); ((LinearLayout)SearchLayout).AddView(SearchResultNeighborhood); ((LinearLayout)groupLayout).AddView(Seperator); ((LinearLayout)groupLayout).AddView(ListView); BlockerView = new UIBlockerView(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels)); SearchPage = new UIGroupFinderSearch(); SearchPage.Create(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels), // Search Neighborhood Groups delegate { SearchPage.Hide(true); GetInitialGroups(PrivateGeneralConfig.GroupType_Neighborhood_GroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text); }, // Search Next Gen Groups delegate { SearchPage.Hide(true); GetInitialGroups(PrivateGeneralConfig.GroupType_NextGenGroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text); }, // Search Young Adult Groups delegate { SearchPage.Hide(true); GetInitialGroups(PrivateGeneralConfig.GroupType_YoungAdultsGroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text); }); SearchPage.SetTitle(ConnectStrings.GroupFinder_SearchPageHeader, ConnectStrings.GroupFinder_SearchPageDetails); SearchPage.LayoutChanged(new System.Drawing.RectangleF(0, 0, NavbarFragment.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels)); SearchPage.Hide(false); // if we should automatically show the search page... if (ShowSearchOnAppear == true) { // don't allow them to tap the address button until we reveal the search page. SearchAddressButton.Enabled = false; // wait a couple seconds before revealing the search page. System.Timers.Timer timer = new System.Timers.Timer(); timer.AutoReset = false; timer.Interval = 1000; timer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => { Rock.Mobile.Threading.Util.PerformOnUIThread(delegate { SearchAddressButton.Enabled = true; SearchPage.Show( ); }); }; timer.Start( ); } else { // otherwise, just allow the seach button SearchAddressButton.Enabled = true; } // hook into the search page as its listener ((View)SearchPage.View.PlatformNativeObject).SetOnTouchListener(this); ((EditText)SearchPage.Street.PlatformNativeObject).SetOnEditorActionListener(this); ((EditText)SearchPage.City.PlatformNativeObject).SetOnEditorActionListener(this); ((EditText)SearchPage.State.PlatformNativeObject).SetOnEditorActionListener(this); ((EditText)SearchPage.ZipCode.PlatformNativeObject).SetOnEditorActionListener(this); return(view); }