Exemple #1
0
        protected override void OnAttached()
        {
            if (View == null)
            {
                return;
            }

            effect = TouchEffect.PickFrom(Element);
            if (effect?.IsDisabled ?? true)
            {
                return;
            }

            effect.Element = (VisualElement)Element;

            View.Touch += OnTouch;
            UpdateClickHandler();

            accessibilityManager = View.Context.GetSystemService(Context.AccessibilityService) as AccessibilityManager;
            if (accessibilityManager != null)
            {
                accessibilityListener = new AccessibilityListener(this);
                accessibilityManager.AddAccessibilityStateChangeListener(accessibilityListener);
                accessibilityManager.AddTouchExplorationStateChangeListener(accessibilityListener);
            }

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop || !effect.NativeAnimation)
            {
                return;
            }

            View.Clickable     = true;
            View.LongClickable = true;
            CreateRipple();

            if (Group == null)
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
                {
                    View.Foreground = ripple;
                }

                return;
            }

            rippleView = new FrameLayout(Group.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                Focusable        = false,
                Enabled          = false,
            };
            View.LayoutChange    += OnLayoutChange;
            rippleView.Background = ripple;
            Group.AddView(rippleView);
            rippleView.BringToFront();
        }
Exemple #2
0
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            BorderView?.BringToFront();
            if (ChildCount == 0 || GetChildAt(0) is not View child)
            {
                return;
            }

            var widthMeasureSpec  = MeasureSpecMode.Exactly.MakeMeasureSpec(right - left);
            var heightMeasureSpec = MeasureSpecMode.Exactly.MakeMeasureSpec(bottom - top);

            child.Measure(widthMeasureSpec, heightMeasureSpec);
            child.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
            BorderView?.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
        }
Exemple #3
0
        void StartRipple(float x, float y)
        {
            if (effect?.IsDisabled ?? true)
            {
                return;
            }

            if (effect.CanExecute && effect.NativeAnimation && rippleView != null)
            {
                UpdateRipple();
                rippleView.Enabled = true;
                rippleView.BringToFront();
                ripple.SetHotspot(x, y);
                rippleView.Pressed = true;
            }
        }
 public override void Animate(JazzyViewPager viewPager, View left, View right, float positionOffset, float positionOffsetPixels)
 {
     if (viewPager.State != JazzyState.Idle)
     {
         var effectOffset = GetEffectOffset(positionOffset);
         if (right != null)
         {
             var scale = (1 - ScaleMaximum) * effectOffset + ScaleMaximum;
             var translate = -viewPager.Width - viewPager.PageMargin + positionOffsetPixels;
             right.ScaleX = scale;
             right.ScaleY = scale;
             right.TranslationX = translate;
         }
         if (left != null)
         {
             left.BringToFront();
         }
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            OS.AutoDisposedGL = false;

            // Screen orientation
            var requiredOrientation = (desc.Orientation == ApplicationOrientations.Landscape) ? Android.Content.PM.ScreenOrientation.Landscape : Android.Content.PM.ScreenOrientation.Portrait;
            RequestedOrientation = requiredOrientation;

            // Remove title bar
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Create gl view
            VolumeControlStream = Android.Media.Stream.Music;
            view = new GLView(this);
            SetContentView(view);

            // Ads
            if (desc.UseAds)
            {
                adMobView = AdMobWrapper.CreateAdView(this, desc.PublisherID);
                var layout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent, GravityFlags.Bottom);
                AddContentView(adMobView, layout);
                AdMobWrapper.LoadAd(adMobView, false);
                adMobView.Visibility = Android.Views.ViewStates.Visible;
                adMobView.BringToFront();
            }

            // keep screen from locking
            var power = (PowerManager)GetSystemService(Context.PowerService);
            wakeLock = power.NewWakeLock(WakeLockFlags.ScreenDim, "AndroidApplication");
        }