Example #1
0
 public override void AddView(Android.Views.View child)
 {
     base.AddView(child);
     if (!(child is CoordinatorLayout))
     {
         child.RemoveFromParent();
     }
 }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                if (Element != null)
                {
                    Element.PropertyChanged -= OnElementPropertyChanged;
                }

                if (_visualElementTracker != null)
                {
                    _visualElementTracker.Dispose();
                    _visualElementTracker = null;
                }

                if (_visualElementPackager != null)
                {
                    _visualElementPackager.Dispose();
                    _visualElementPackager = null;
                }

                if (_backgroundDrawable != null)
                {
                    _backgroundDrawable.Dispose();
                    _backgroundDrawable = null;
                }

                if (_visualElementRenderer != null)
                {
                    _visualElementRenderer.Dispose();
                    _visualElementRenderer = null;
                }

                while (ChildCount > 0)
                {
                    AView child = GetChildAt(0);
                    child.RemoveFromParent();
                    child.Dispose();
                }

                if (Element != null)
                {
                    if (Platform.GetRenderer(Element) == this)
                    {
                        Element.ClearValue(Platform.RendererProperty);
                    }
                }
            }

            base.Dispose(disposing);
        }
Example #3
0
        protected override void Dispose(bool disposing)
        {
            if (CheckFlagsForDisposed())
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                EffectUtilities.UnregisterEffectControlProvider(this, Element);

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;
                }

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    while (ChildCount > 0)
                    {
                        AView child = GetChildAt(0);
                        child.RemoveFromParent();
                        child.Dispose();
                    }
                }

                if (Element != null)
                {
                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
Example #4
0
        public override void AddView(Android.Views.View child)
        {
            base.AddView(child);
            if (child is LinearLayout)
            {
                return;
            }

            child.RemoveFromParent();
            _androidLinearLayout.AddView(child);
            child.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            scrollView             = child;
        }
 public sealed override void AddView(Android.Views.View child)
 {
     if (!(child is LinearLayout))
     {
         child.RemoveFromParent();
         _androidLinearLayout.AddView(child);
         child.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
         webView = child;
     }
     else
     {
         base.AddView(child);
     }
 }
Example #6
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            if (disposing)
            {
                while (ChildCount > 0)
                {
                    AView child = GetChildAt(0);
                    child.RemoveFromParent();
                    child.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Example #7
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            searchView = Control;
            //linearLayout = Control;

            if (Control != null)
            {
                searchView.Iconified = false;
                searchView.SetIconifiedByDefault(false);
                searchView.BaselineAligned           = false;
                searchView.BaselineAlignedChildIndex = 0;

                /*
                 * linearLayout.RemoveAllViews();
                 * TextView label = new TextView(context);
                 * label.Text = "hola";
                 * linearLayout.AddView(label);
                 * Toolbar toolbar = new Toolbar(context);
                 * toolbar.AddView(new RadioButton(context));
                 * linearLayout.AddView(toolbar);
                 *
                 */

                //searchView.RemoveAllViews();
                //FormsTextView label = new FormsTextView(context);
                //label.Text = "holaaa";
                //searchView.AddView(label);

                // (Resource.Id.search_mag_icon); is wrong / Xammie bug

                //(icon as ImageView).SetImageResource(Resource.Drawable.search);

                //int cancelIconId = Context.Resources.GetIdentifier("android:id/search_close_btn", null, null);
                //var eicon = searchView.FindViewById(cancelIconId);
                //(eicon as ImageView).SetImageResource(Resource.Drawable.search);


                LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout;
                linearLayout = linearLayout.GetChildAt(2) as LinearLayout;
                linearLayout = linearLayout.GetChildAt(1) as LinearLayout;

                linearLayout.Background = null;                                                     //removes underline

                AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView; //modify for text appearance customization

                int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
                icon            = searchView.FindViewById(searchIconId);
                icon.Visibility = ViewStates.Invisible;
                icon.RemoveFromParent();

                var textView2Id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
                var textView2   = (searchView.FindViewById(textView2Id) as EditText);
                if (textView == null)
                {
                    return;
                }
                textView.SetTextColor(global::Android.Graphics.Color.Black);

                IntPtr IntPtrtextViewClass        = JNIEnv.FindClass(typeof(TextView));
                IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");
                JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, Resource.Layout.design_layout_tab_text);                 // replace 0 with a Resource.Drawable.my_cursor

                Android.Widget.Button buttonFilter = new Android.Widget.Button(context);
                //buttonFilter.SetBackgroundResource(Resource.Drawable.ic_filter_list_black_24dp);
                //buttonFilter.SetBackgroundColor(Android.Graphics.Color.Transparent);
                //Toolbar toolbar = new Toolbar(context); toolbar = (toolbar.FindViewById(Resource.Layout.Toolbar) as Toolbar);

                //linearLayout.AddView(buttonFilter); <! IMPORTANTE !>

                //var editViewId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
                //var editView = (searchView.FindViewById(editViewId) as )

                //LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout;
                //linearLayout = linearLayout.GetChildAt(2) as LinearLayout;
                //linearLayout = linearLayout.GetChildAt(1) as LinearLayout;

                //AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView;
                //textView.SetTextColor(Android.Graphics.Color.Blue);
            }
            if (e.OldElement != null)
            {
            }
            if (e.NewElement != null)
            {
            }

            /*
             * if (e.NewElement == null)
             * {
             *
             *      GradientDrawable gd = new GradientDrawable();
             *      gd.SetStroke(0, Android.Graphics.Color.Transparent);
             *
             *      linearLayout.Background = gd;
             *
             *
             *      textView.SetBackgroundColor(Android.Graphics.Color.Red);
             *
             *      //ImageView icon = linearLayout.GetChildAt(1) as ImageView;
             *      //icon.Visibility = ViewStates.Invisible;
             *
             * }
             */
        }
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            bool isHeader, nextIsHeader;
            Cell item = GetCellForPosition(position, out isHeader, out nextIsHeader);

            if (item == null)
            {
                return(new AView(Context));
            }

            var   makeBline = true;
            var   layout    = convertView as ConditionalFocusLayout;
            AView aview     = CellFactory.GetCell(item, convertView, parent, Context, _view);

            if (layout != null)
            {
                makeBline   = false;
                convertView = layout.GetChildAt(0);
            }
            else
            {
                layout = new ConditionalFocusLayout(Context)
                {
                    Orientation = Orientation.Vertical
                };
            }

            if (!makeBline)
            {
                if (convertView != aview)
                {
                    if (layout.ChildCount == 2)
                    {
                        layout.RemoveViewAt(0);
                    }

                    aview.RemoveFromParent();
                    layout.AddView(aview, 0);
                }
            }
            else
            {
                aview.RemoveFromParent();
                layout.AddView(aview, 0);
            }

            AView bline;

            if (makeBline)
            {
                bline = new AView(Context)
                {
                    LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1)
                };

                layout.AddView(bline);
            }
            else
            {
                bline = layout.GetChildAt(1);
            }

            if (isHeader)
            {
                if (Application.AccentColor != null)
                {
                    bline.SetBackgroundColor(Application.AccentColor.ToPlatform());
                }
            }
            else if (nextIsHeader)
            {
                bline.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            }
            else
            {
                using (var value = new TypedValue())
                {
                    int id = global::Android.Resource.Drawable.DividerHorizontalDark;
                    if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ListDivider, value, true))
                    {
                        id = value.ResourceId;
                    }
                    else if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.Divider, value, true))
                    {
                        id = value.ResourceId;
                    }

                    bline.SetBackgroundResource(id);
                }
            }

            layout.ApplyTouchListenersToSpecialCells(item);

            if (_restoreFocus == item)
            {
                if (!aview.HasFocus)
                {
                    aview.RequestFocus();
                }

                _restoreFocus = null;
            }
            else if (aview.HasFocus)
            {
                aview.ClearFocus();
            }

            return(layout);
        }
        public void Show(ContentPage page, string name, bool InitiateFlag)
        {
            if (Xamarin.Forms.Application.Current.MainPage != null)
            {
                page.Parent = Xamarin.Forms.Application.Current.MainPage;
            }
            else
            {
                return;
            }

            List <KeyValuePair <string, Dialog> > kvpList = new List <KeyValuePair <string, Dialog> >(dialogDic.Keys);

            for (int i = 0; i < kvpList.Count; i++)
            {
                if (kvpList[i].Key == name)
                {
                    if (InitiateFlag)
                    {
                        dialogDic.Remove(kvpList[i]);
                        kvpList[i].Value.Dispose();
                        break;
                    }
                    if (dialogDic[kvpList[i]])
                    {
                        return;
                    }
                    kvpList[i].Value.Show();
                    dialogDic[kvpList[i]] = true;
                    return;
                }
            }

            // Run the Layout Rendering Cycle for the page
            page.Layout(new Rectangle(0, 0,
                                      Xamarin.Forms.Application.Current.MainPage.Width,
                                      Xamarin.Forms.Application.Current.MainPage.Height));
            // Get the native renderered instance for our page
            var  nativePageRendererInstance = page.GetOrCreateRenderer((name == "busyPage") ? true : false);
            bool ShouldCancel = (name == "changePage") ? true : false;

            // Get the native page for our page
            Android.Views.View nativePageView = nativePageRendererInstance.View;
            if (nativePageView.Parent != null)
            {
                nativePageView.RemoveFromParent();
            }
            // Create the native transparent Dialog instance to embed our page
            Dialog dialog = new Dialog(CrossCurrentActivity.Current.Activity);

            dialog.RequestWindowFeature((int)WindowFeatures.NoTitle);
            dialog.SetCancelable(ShouldCancel);
            dialog.SetCanceledOnTouchOutside(ShouldCancel);
            dialog.SetContentView(nativePageView);
            Window window = dialog.Window;

            window.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            window.ClearFlags(WindowManagerFlags.DimBehind);
            window.SetBackgroundDrawable(new ColorDrawable(Android.Graphics.Color.Transparent));

            dialogDic.Add(new KeyValuePair <string, Dialog>(name, dialog), true);

            dialog.Show();
        }