Exemple #1
0
                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);
                }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(MobileApp.Shared.Config.ControlStylingConfig.BackgroundColor);

            ScrollView = new UIScrollViewWrapper();
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent            = this;
            ScrollView.Bounds            = View.Bounds;
            View.AddSubview(ScrollView);

            ScrollView.ScrollEnabled = false;

            // setup everything except positioning, which will happen in LayoutChanged()
            SourceLocation = null;
            GroupEntries   = new List <MobileAppApi.GroupSearchResult>();

            SearchAddressButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(SearchAddressButton);
            SearchAddressButton.Layer.AnchorPoint = CGPoint.Empty;
            ControlStyling.StyleButton(SearchAddressButton, ConnectStrings.GroupFinder_SearchButtonLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            SearchAddressButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                SearchPage.Show( );
                Task.NavToolbar.Reveal(false);
            };


            MapView = new MKMapView( );
            ScrollView.AddSubview(MapView);

            CurrGroupIndex     = 0;
            NumRequestedGroups = 10;

            // set the default position for the map to whatever specified area.
            MKCoordinateRegion region = MKCoordinateRegion.FromDistance(new CLLocationCoordinate2D(
                                                                            ConnectConfig.GroupFinder_DefaultLatitude,
                                                                            ConnectConfig.GroupFinder_DefaultLongitude),
                                                                        ConnectConfig.GroupFinder_DefaultScale_iOS,
                                                                        ConnectConfig.GroupFinder_DefaultScale_iOS);

            MapView.SetRegion(region, true);

            MapView.Layer.AnchorPoint = new CGPoint(0, 0);
            MapView.Delegate          = new MapViewDelegate()
            {
                Parent = this
            };

            SearchResultsBGLayer = new UIView();
            ScrollView.AddSubview(SearchResultsBGLayer);
            SearchResultsBGLayer.Layer.AnchorPoint = new CGPoint(0, 0);
            SearchResultsBGLayer.BackgroundColor   = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color);

            SearchResultsPrefix = new UILabel( );
            ScrollView.AddSubview(SearchResultsPrefix);
            SearchResultsPrefix.Layer.AnchorPoint = new CGPoint(0, 0);
            SearchResultsPrefix.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            SearchResultsPrefix.Text = ConnectStrings.GroupFinder_NoGroupsFound;
            SearchResultsPrefix.SizeToFit( );
            SearchResultsPrefix.TextColor       = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            SearchResultsPrefix.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color);
            SearchResultsPrefix.TextAlignment   = UITextAlignment.Center;

            SearchResultsNeighborhood = new UILabel( );
            ScrollView.AddSubview(SearchResultsNeighborhood);
            SearchResultsNeighborhood.Layer.AnchorPoint = new CGPoint(0, 0);
            SearchResultsNeighborhood.Font            = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            SearchResultsNeighborhood.TextColor       = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor);
            SearchResultsNeighborhood.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color);
            SearchResultsNeighborhood.TextAlignment   = UITextAlignment.Center;


            Seperator = new UIView( );
            ScrollView.AddSubview(Seperator);
            Seperator.Layer.BorderWidth = 1;
            Seperator.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor).CGColor;


            GroupFinderTableView = new UITableView();
            ScrollView.AddSubview(GroupFinderTableView);
            GroupTableSource = new GroupFinderViewController.TableSource(this);

            // add the table view and source
            GroupFinderTableView.BackgroundColor = UIColor.Clear;
            GroupFinderTableView.Source          = GroupTableSource;
            GroupFinderTableView.SeparatorStyle  = UITableViewCellSeparatorStyle.None;

            BlockerView = new UIBlockerView(ScrollView, ScrollView.Frame.ToRectF( ));

            SearchPage = new UIGroupFinderSearch();
            SearchPage.Create(ScrollView, ScrollView.Frame.ToRectF( ),
                              // Search Neighborhood Groups
                              delegate
            {
                SearchPage.Hide(true);
                GetInitialGroups(PrivateGeneralConfig.GroupType_Neighborhood_GroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text);
                Task.NavToolbar.Reveal(true);
            },
                              // Search Short Term Groups
                              delegate
            {
                SearchPage.Hide(true);
                GetInitialGroups(PrivateGeneralConfig.GroupType_ShortTermGroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text);
                Task.NavToolbar.Reveal(true);
            },
                              // Search Young Adults Groups
                              delegate
            {
                SearchPage.Hide(true);
                GetInitialGroups(PrivateGeneralConfig.GroupType_YoungAdultsGroupId, SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text);
                Task.NavToolbar.Reveal(true);
            });
            SearchPage.SetTitle(ConnectStrings.GroupFinder_SearchPageHeader, ConnectStrings.GroupFinder_SearchPageDetails);
            SearchPage.Hide(false);

            KeyboardAdjustManager = new KeyboardAdjustManager(View);

            // 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( );

            // hook in delegates so we can handle return
            ((UITextField)SearchPage.Street.PlatformNativeObject).Delegate = new AddressDelegate( )
            {
                Parent = this
            };
            ((UITextField)SearchPage.City.PlatformNativeObject).Delegate = new AddressDelegate( )
            {
                Parent = this
            };
            ((UITextField)SearchPage.State.PlatformNativeObject).Delegate = new AddressDelegate( )
            {
                Parent = this
            };
            ((UITextField)SearchPage.ZipCode.PlatformNativeObject).Delegate = new AddressDelegate( )
            {
                Parent = this
            };
        }