Esempio n. 1
0
 public void Init(Activity activity)
 {
     if (Font == null)
     {
         Font = ResourcesCompat.GetFont(activity, Resource.Font.fontawesome);
     }
 }
        private void InitializeFromAttributes(Context context, IAttributeSet attrs)
        {
            var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.DataTableView, 0, 0);

            LazyLoad        = attr.GetBoolean(Resource.Styleable.DataTableView_lazyLoad, false);
            LazyLoadLimit   = attr.GetInteger(Resource.Styleable.DataTableView_lazyLoadLimit, 0);
            ChoiceMode      = (ChoiceMode)attrs.GetAttributeIntValue(Android.Resource.Attribute.ChoiceMode, 0);
            HeaderTextSize  = attr.GetFloat(Resource.Styleable.DataTableView_headerTextSize, 20.0f);
            HeaderTextColor = attr.GetColor(Resource.Styleable.DataTableView_headerTextColor, unchecked ((int)0xFFFFFFFF));

            var headerFontID = attr.GetResourceId(Resource.Styleable.DataTableView_headerFontFamily, -1);

            if (headerFontID >= 0)
            {
                HeaderTypeface = ResourcesCompat.GetFont(Context, headerFontID);
            }

            HeaderBackground = attr.GetDrawable(Resource.Styleable.DataTableView_headerBackground);
            RowTextSize      = attr.GetFloat(Resource.Styleable.DataTableView_rowTextSize, DataTableAdapter.DEFAULT_TEXT_SIZE);
            RowTextColor     = attr.GetColor(Resource.Styleable.DataTableView_rowTextColor, DataTableAdapter.DEFAULT_TEXT_COLOR);

            var rowFontID = attr.GetResourceId(Resource.Styleable.DataTableView_rowFontFamily, -1);

            if (rowFontID >= 0)
            {
                RowTypeface = ResourcesCompat.GetFont(Context, rowFontID);
            }

            RowBackground        = attr.GetDrawable(Resource.Styleable.DataTableView_rowBackground);
            HorizontalRowDivider = attr.GetDrawable(Resource.Styleable.DataTableView_horizontalRowDivider)
                                   ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.horizontal_divider, null);
            VerticalRowDivider = attr.GetDrawable(Resource.Styleable.DataTableView_verticalRowDivider)
                                 ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.vertical_divider, null);

            CreateAdapter();
            CreateHeaderView();
            CreateRowView();
        }
Esempio n. 3
0
        public static Bitmap WeatherIconToBitmap(Context context, String text, int textSize, Color textColor)
        {
            Paint    paint        = new Paint(PaintFlags.AntiAlias);
            Typeface weathericons = ResourcesCompat.GetFont(context, Resource.Font.weathericons);

            paint.SubpixelText = true;
            paint.SetTypeface(weathericons);
            paint.SetStyle(Paint.Style.Fill);
            paint.Color     = textColor;
            paint.TextSize  = textSize;
            paint.TextAlign = Paint.Align.Left;

            float baseline = -paint.Ascent();
            int   width    = (int)(paint.MeasureText(text) + 0.5f);
            int   height   = (int)(baseline + paint.Descent() + 0.5f);

            Bitmap bmp      = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            Canvas myCanvas = new Canvas(bmp);

            myCanvas.DrawText(text, 0, baseline, paint);

            return(bmp);
        }
Esempio n. 4
0
        public void ApplyStylableAttributes(Context context, TypedArray a, int[] styleableRes)
        {
            if (styleableRes == Resource.Styleable.CircularEventGauge)
            {
                // Background Gauge Attributes

                bool  ringColorsSet = false;
                Color startColor    = Color.DarkGray;
                Color endColor      = Color.White;
                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringStartColor))
                {
                    startColor    = a.GetColor(Resource.Styleable.CircularEventGauge_ringStartColor, Color.DarkGray);
                    ringColorsSet = true;
                }
                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringEndColor))
                {
                    endColor      = a.GetColor(Resource.Styleable.CircularEventGauge_ringEndColor, Color.White);
                    ringColorsSet = true;
                }
                if (ringColorsSet)
                {
                    RingColors = new ShadingColorPair(startColor, endColor);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_centerTint))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_centerTint);
                    if (csl != null)
                    {
                        CenterTint = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_centerSrc))
                {
                    CenterDrawable = a.GetDrawable(Resource.Styleable.CircularEventGauge_centerSrc);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringGap))
                {
                    RingGapPx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_ringGap, RingThicknessPx);
                }


                // Count Atttributes

                bool     fontPropertiesSet = false;
                Typeface typeface          = null;
                string   familyName        = null;
                string   styleName         = null;

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTypeface))
                {
                    typeface          = (Typeface)a.GetInt(Resource.Styleable.CircularEventGauge_countTypeface, 0);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTextStyle))
                {
                    styleName         = a.GetString(Resource.Styleable.CircularEventGauge_countTextStyle);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countFontFamily))
                {
                    Typeface tf = null;
                    // Try to resolve as a font resource
                    try
                    {
                        var resId = a.GetResourceId(Resource.Styleable.CircularEventGauge_countFontFamily, 0);
                        tf = ResourcesCompat.GetFont(Context, resId);
                    }
                    catch (Exception ex) { }

                    if (tf == null)
                    {
                        // Try to resolve as a font asset or system font
                        familyName = a.GetString(Resource.Styleable.CircularEventGauge_countFontFamily);
                    }
                    else
                    {
                        typeface = tf;
                    }
                    fontPropertiesSet = true;
                }

                if (fontPropertiesSet)
                {
                    var typefaceAndStyle = GetTypefaceFromAttrs(typeface, familyName, styleName);
                    if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 == null)
                    {
                        CountTypeface = typefaceAndStyle.Item1;
                    }
                    else if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 != null)
                    {
                        SetCountTypeface(typefaceAndStyle.Item1, (TypefaceStyle)typefaceAndStyle.Item2);
                    }
                }


                if (a.HasValue(Resource.Styleable.CircularEventGauge_countColor))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_countColor);
                    if (csl != null)
                    {
                        CountColors = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countAutosize))
                {
                    CountAutoSize = a.GetBoolean(Resource.Styleable.CircularEventGauge_countAutosize, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTextSize))
                {
                    CountTextSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_countTextSize, PixelSizeConverter.SpToPx(20));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countAllCaps))
                {
                    CountAllCaps = a.GetBoolean(Resource.Styleable.CircularEventGauge_countAllCaps, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countText))
                {
                    CountText = a.GetString(Resource.Styleable.CircularEventGauge_countText);
                }



                // Label Atttributes

                fontPropertiesSet = false;
                typeface          = null;
                familyName        = null;
                styleName         = null;

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTypeface))
                {
                    typeface          = (Typeface)a.GetInt(Resource.Styleable.CircularEventGauge_labelTypeface, 0);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTextStyle))
                {
                    styleName         = a.GetString(Resource.Styleable.CircularEventGauge_labelTextStyle);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelFontFamily))
                {
                    Typeface tf = null;
                    // Try to resolve as a font resource
                    try
                    {
                        var resId = a.GetResourceId(Resource.Styleable.CircularEventGauge_labelFontFamily, 0);
                        tf = ResourcesCompat.GetFont(Context, resId);
                    }
                    catch (Exception ex) { }

                    if (tf == null)
                    {
                        // Try to resolve as a font asset or system font
                        familyName = a.GetString(Resource.Styleable.CircularEventGauge_labelFontFamily);
                    }
                    else
                    {
                        typeface = tf;
                    }
                    fontPropertiesSet = true;
                }

                if (fontPropertiesSet)
                {
                    var typefaceAndStyle = GetTypefaceFromAttrs(typeface, familyName, styleName);
                    if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 == null)
                    {
                        LabelTypeface = typefaceAndStyle.Item1;
                    }
                    else if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 != null)
                    {
                        SetLabelTypeface(typefaceAndStyle.Item1, (TypefaceStyle)typefaceAndStyle.Item2);
                    }
                }


                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelColor))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_labelColor);
                    if (csl != null)
                    {
                        LabelColors = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTextSize))
                {
                    LabelTextSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_labelTextSize, PixelSizeConverter.SpToPx(10));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelAllCaps))
                {
                    LabelAllCaps = a.GetBoolean(Resource.Styleable.CircularEventGauge_labelAllCaps, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelText))
                {
                    LabelText = a.GetString(Resource.Styleable.CircularEventGauge_labelText);
                }


                // Icon attributes

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconSrc))
                {
                    IconDrawable = a.GetDrawable(Resource.Styleable.CircularEventGauge_iconSrc);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconSize))
                {
                    IconSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_iconSize, PixelSizeConverter.SpToPx(18));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconTint))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_iconTint);
                    if (csl != null)
                    {
                        IconTint = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconTintMode))
                {
                    var mode = a.GetInt(Resource.Styleable.CircularEventGauge_iconTintMode, -1);
                    if (mode != -1)
                    {
                        IconTintMode = (PorterDuff.Mode)mode;
                    }
                }



                // Other Attributes

                if (a.HasValue(Resource.Styleable.CircularEventGauge_count))
                {
                    var count = a.GetInt(Resource.Styleable.CircularEventGauge_count, -1);
                    if (count > -1)
                    {
                        EventCount = count;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_active))
                {
                    Active = a.GetBoolean(Resource.Styleable.CircularEventGauge_active, true);
                }

                CreateGuage();
            }
        }
Esempio n. 5
0
 public CustomShellRenderer(Context context) : base(context)
 {
     BottomTabTitleTypeface = ResourcesCompat.GetFont(context, Resource.Font.LemonMilkRegular);
 }
Esempio n. 6
0
        //MyPagerAdapter pageadapter;

        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            SetTheme(Resource.Style.Theme_Normal);

            SetContentView(Resource.Layout.Roles_Activity);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            // Sets the Toolbar to act as the ActionBar for this Activity window.
            // Make sure the toolbar exists in the activity and is not null
            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            Window.ClearFlags(WindowManagerFlags.TranslucentStatus);

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

                // finally change the color
                Window.SetStatusBarColor(Resources.GetColor(Android.Resource.Color.Transparent));
            }

            //create fragment:

            string id = Intent.Extras?.GetString("id");

            if (id != "")
            {
                //Analytics.TrackEvent("ChooseRole");

                //load event info:
                cancel = new CancellationTokenSource();
                AndHUD.Shared.Show(this, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, () =>
                {
                    cancel.Cancel();
                    Finish();
                });

                try
                {
                    CurrentEvent = await Bootlegger.BootleggerClient.GetEventInfo(id, cancel.Token);
                }
                catch (Exception)
                {
                    SetResult(Result.FirstUser);
                    Finish();
                    return;
                }
                finally
                {
                    AndHUD.Shared.Dismiss();
                }
            }
            else
            {
                CurrentEvent = Bootlegger.BootleggerClient.CurrentEvent;
            }

            Bootleg.API.Bootlegger.BootleggerClient.LogUserAction("ChooseRole",
                                                                  new KeyValuePair <string, string>("eventid", CurrentEvent.id));

            CollapsingToolbarLayout collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar);

            collapsingToolbar.SetTitle(CurrentEvent.name);
            //collapsingToolbar.SetCollapsedTitleTextColor(Color.Transparent);
            collapsingToolbar.SetExpandedTitleTextAppearance(Resource.Style.ExpandedAppBar);
            Typeface font = ResourcesCompat.GetFont(this, Resource.Font.montserratregular);

            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).CollapsedTitleTypeface = font;
            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).ExpandedTitleTypeface  = font;

            if (!string.IsNullOrEmpty(CurrentEvent.roleimg))
            {
                FindViewById <AppBarLayout>(Resource.Id.appbar).SetExpanded(false, false);
            }

            if (!string.IsNullOrEmpty(CurrentEvent.iconbackground) && !WhiteLabelConfig.REDUCE_BANDWIDTH)
            {
                Picasso.With(this).Load(CurrentEvent.iconbackground).CenterCrop().Fit().MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Into(FindViewById <ImageView>(Resource.Id.defaultback), new Action(() => {
                    var bitmap      = ((BitmapDrawable)FindViewById <ImageView>(Resource.Id.defaultback).Drawable).Bitmap;
                    Palette palette = Palette.From(bitmap).Generate();
                    int vibrant     = palette.GetLightVibrantColor(0);
                    if (vibrant == 0)
                    {
                        vibrant = palette.GetMutedColor(0);
                    }
                    int dark = palette.GetVibrantColor(0);
                    if (dark == 0)
                    {
                        dark = palette.GetLightMutedColor(0);
                    }
                    //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(vibrant);
                    //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark);
                }), null);
            }
            else
            {
                Picasso.With(this).Load(Resource.Drawable.user_back).CenterCrop().Fit().Into(FindViewById <ImageView>(Resource.Id.defaultback));
            }

            AndHUD.Shared.Dismiss();



            SelectRoleFrag myrole;

            if (bundle == null)
            {
                myrole = new SelectRoleFrag(CurrentEvent, false);
                myrole.OnRoleChanged += Myrole_OnRoleChanged;
                Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                try
                {
                    ft.Add(Resource.Id.roles_frag_holder, myrole, "rolefragment").Commit();
                }
                catch
                {
                    //failed dont know why!
                }
            }
            else
            {
                myrole = SupportFragmentManager.FindFragmentByTag("rolefragment") as SelectRoleFrag;
                myrole.OnRoleChanged += Myrole_OnRoleChanged;
            }
        }
 private void Initialize(Context context)
 {
     Typeface = ResourcesCompat.GetFont(context, Resource.Font.weathericons);
 }
Esempio n. 8
0
        public void Startup()
        {
            /*** NEW PLAYER ***/
            _player = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _player.PlayWhenReady = true;
            _player.AddListener(this);

            progress?.Dispose();
            clipper?.Dispose();

            progress = new ProgressTracker(_player);
            progress.OnPositionChange += Progress_OnPositionChange;
            clipper = new ProgressTracker(_player, 50);
            clipper.OnPositionChange += Clipper_OnPositionChange;

            _playerView = FindViewById <PlayerView>(Resource.Id.videoview);

            Android.Graphics.Typeface subtitleTypeface = ResourcesCompat.GetFont(Context, Resource.Font.montserratregular);

            var captionStyleCompat = new CaptionStyleCompat(Android.Graphics.Color.White, Android.Graphics.Color.Transparent, Android.Graphics.Color.Transparent, CaptionStyleCompat.EdgeTypeNone, Android.Graphics.Color.Transparent, subtitleTypeface);

            _playerView.SubtitleView.SetStyle(captionStyleCompat);
            _playerView.SubtitleView.SetFractionalTextSize(0.06f);
            //_playerView.SubtitleView.SetFixedTextSize((int)ComplexUnitType.Sp, 10);

            _playerView.SubtitleView.SetBottomPaddingFraction(0.4f);
            _playerView.SubtitleView.TextAlignment = TextAlignment.Center;


            _playerView.Player        = _player;
            _playerView.UseController = true;

            webclient = new OkHttpClient.Builder()
                        .Cache((Context.ApplicationContext as BootleggerApp).FilesCache)
                        .Build();
            httpDataSourceFactory    = new OkHttpDataSourceFactory(webclient, "BootleggerEditor", null);
            extractorsFactory        = new DefaultExtractorsFactory();
            defaultDataSourceFactory = new DefaultDataSourceFactory(Context, "BootleggerEditor");
            /*************/

            _audioPlayer            = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _audioPlayer.Volume     = 0.4f;
            _audioPlayer.RepeatMode = Player.RepeatModeOne;

            cursor                       = FindViewById <View>(Resource.Id.trackposition);
            seeker                       = FindViewById <RangeSliderControl>(Resource.Id.seeker);
            trackcontrols                = FindViewById <View>(Resource.Id.trackcontrols);
            seeker.LowerValueChanged    += Seeker_LeftValueChanged;
            seeker.UpperValueChanged    += Seeker_RightValueChanged;
            seeker.StepValueContinuously = true;
            track = FindViewById <View>(Resource.Id.track);

            title = FindViewById <TextView>(Resource.Id.title);

            FindViewById <ImageButton>(Resource.Id.fullscreenbtn).Click += Fullscreen_Click;

            videoWrapper = FindViewById(Resource.Id.videoWrapper);

            mFullScreenDialog = new FullScreenVideoDialog(Context, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen);
            mFullScreenDialog.OnAboutToClose += MFullScreenDialog_OnAboutToClose;

            seeker.Visibility = ViewStates.Invisible;
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Bootlegger.BootleggerClient.CurrentEvent == null)
            {
                Finish();
                return;
            }

            CurrentEvent = Bootlegger.BootleggerClient.CurrentEvent;

            SetTheme(Resource.Style.Theme_Normal);

            SetContentView(Resource.Layout.Review);


            //AndHUD.Shared.Show(this, Resources.GetString(Resource.String.loading), -1, MaskType.Black, null, null, true);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            Window.ClearFlags(WindowManagerFlags.TranslucentStatus);

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                // finally change the color
                Window.SetStatusBarColor(new Color(ContextCompat.GetColor(this, Android.Resource.Color.Transparent)));
            }

            //FindViewById<TextView>(Resource.Id.customTitle).Text = CurrentEvent.name;

            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetTitle(CurrentEvent.name);

            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetExpandedTitleTextAppearance(Resource.Style.ExpandedAppBar);
            Typeface font = ResourcesCompat.GetFont(this, Resource.Font.montserratregular);

            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).CollapsedTitleTypeface = font;
            FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).ExpandedTitleTypeface  = font;

            FindViewById <AppBarLayout>(Resource.Id.appbar).SetExpanded(false, false);

            //if (!string.IsNullOrEmpty(CurrentEvent.iconbackground) && !WhiteLabelConfig.REDUCE_BANDWIDTH)
            //    Picasso.With(this).Load(CurrentEvent.iconbackground).CenterCrop().Fit().MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Tag(this).Into(FindViewById<ImageView>(Resource.Id.defaultback), new Action(() =>
            //    {
            //        var bitmap = ((BitmapDrawable)FindViewById<ImageView>(Resource.Id.defaultback).Drawable).Bitmap;
            //        Palette palette = Palette.From(bitmap).Generate();
            //        int vibrant = palette.GetLightVibrantColor(0);
            //        if (vibrant == 0)
            //            vibrant = palette.GetMutedColor(0);
            //        int dark = palette.GetVibrantColor(0);
            //        if (dark == 0)
            //            dark = palette.GetLightMutedColor(0);
            //        //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(vibrant);
            //        //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark);
            //    }), null);
            //else
            //{
            //Picasso.With(this).Load(Resource.Drawable.user_back).CenterCrop().Fit().Into(FindViewById<ImageView>(Resource.Id.defaultback));
            //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(Color.Transparent);
            //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark);
            //}

            FindViewById <TextView>(Resource.Id.organisedby).Text = CurrentEvent.organisedby;
            Picasso.With(this).Load(CurrentEvent.organiserprofile.Replace("sz=50", "")).Tag(this).Fit().Transform(new CircleTransform()).Into(FindViewById <ImageView>(Resource.Id.imgGravatar));

            FindViewById <TextView>(Resource.Id.contributors).Text  = Java.Lang.String.Format("%d", CurrentEvent.numberofcontributors);
            FindViewById <TextView>(Resource.Id.contributions).Text = Java.Lang.String.Format("%d", CurrentEvent.numberofclips);

            _pager = FindViewById <ViewPager>(Resource.Id.tabpager);

            capture = FindViewById <FloatingActionButton>(Resource.Id.capture);
            newedit = FindViewById <FloatingActionButton>(Resource.Id.newedit);
            newtag  = FindViewById <FloatingActionButton>(Resource.Id.newtag);


            capture.Click += CaptureClick;
            newedit.Click += Review_Click;
            newtag.Click  += Newtag_Click;

            var dip16 = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics);

            capture.LayoutParameters = new CoordinatorLayout.LayoutParams(capture.LayoutParameters)
            {
                Behavior = new MyFABAwareScrollingViewBehavior(this, capture, 0, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16
            };
            newtag.LayoutParameters = new CoordinatorLayout.LayoutParams(newtag.LayoutParameters)
            {
                Behavior = new MyFABAwareScrollingViewBehavior(this, newtag, 1, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16
            };
            newedit.LayoutParameters = new CoordinatorLayout.LayoutParams(newedit.LayoutParameters)
            {
                Behavior = new MyFABAwareScrollingViewBehavior(this, newedit, 2, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16
            };

            _tabs            = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.tabs);
            _tabs.TabGravity = 0;
            _tabs.TabMode    = 1;

            _adapter       = new ReviewPageAdapter(SupportFragmentManager, this);
            _pager.Adapter = _adapter;

            if (savedInstanceState == null)
            {
                myclips                    = new MyClipsFragment(this);
                myclips.OnPreview         += Myclips_OnPreview;
                myclips.OnRefresh         += Myclips_OnRefresh;
                myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate;
                myclips.OnStartUpload     += Myclips_OnStartUpload;

                myedits             = new MyEditsFragment();
                myedits.OnOpenEdit += Myedits_OnOpenEdit;
                myedits.OnPreview  += Myedits_OnPreview;

                myingest            = new AllClipsFragment(AllClipsFragment.ClipViewMode.LIST);
                myingest.OnPreview += Myingest_OnPreview;
            }
            else
            {
                myclips                    = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":0") as MyClipsFragment;
                myclips.OnPreview         += Myclips_OnPreview;
                myclips.OnRefresh         += Myclips_OnRefresh;
                myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate;
                myclips.OnStartUpload     += Myclips_OnStartUpload;

                myingest             = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":1") as AllClipsFragment;
                myingest.ChooserMode = AllClipsFragment.ClipViewMode.LIST;
                myingest.OnPreview  += Myingest_OnPreview;

                myedits = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":2") as MyEditsFragment;
                if (myedits == null)
                {
                    myedits = new MyEditsFragment();
                }

                myedits.OnOpenEdit += Myedits_OnOpenEdit;
                myedits.OnPreview  += Myedits_OnPreview;
            }

            //myedits.Reattach();

            _adapter.AddTab(GetString(Resource.String.videos), myclips, ReviewPageAdapter.TabType.CLIPS);
            _adapter.AddTab(GetString(Resource.String.tagging), myingest, ReviewPageAdapter.TabType.INGEST);
            _adapter.AddTab(GetString(Resource.String.edits), myedits, ReviewPageAdapter.TabType.EDITS);

            _pager.Post(() => {
                _tabs.SetupWithViewPager(_pager);
            });

            _pager.PageSelected += _pager_PageSelected;

            if (Intent?.GetBooleanExtra("needsperms", false) ?? false)
            {
                LoginFuncs.ShowError(this, new NeedsPermissionsException());
            }
        }
Esempio n. 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.CreateWeaponLayout);

            // Get user input items.
            WeaponNameTextField     = FindViewById <TextView>(Resource.Id.WeaponNameTextField);
            BaseDamageSpinner       = FindViewById <Spinner>(Resource.Id.BaseDamageSpinner);
            DamageModifier          = FindViewById <NumberPicker>(Resource.Id.DamageModifierNumberPicker);
            StoneTextField          = FindViewById <TextView>(Resource.Id.StoneTextField);
            ConfirmButton           = FindViewById <Button>(Resource.Id.ConfirmButton);
            CancelButton            = FindViewById <Button>(Resource.Id.CancelButton);
            DeleteButton            = FindViewById <Button>(Resource.Id.DeleteButton);
            DeleteButton.Visibility = Intent.GetBooleanExtra("NewWeapon", false) ? ViewStates.Gone : ViewStates.Visible;

            // Assign events to user inputs.
            WeaponNameTextField.TextChanged += WeaponNameTextField_TextChanged;
            BaseDamageSpinner.ItemSelected  += BaseDamageSpinner_ItemSelected;
            DamageModifier.ValueChanged     += DamageModifier_ValueChanged;
            StoneTextField.TextChanged      += StoneTextField_TextChanged;
            ConfirmButton.Click             += ConfirmButton_Click;
            CancelButton.Click += CancelButton_Click;
            DeleteButton.Click += DeleteButton_Click;
            // Clear focus on text fields when enter button is clicked.
            WeaponNameTextField.EditorAction += TextField_OnDone;
            StoneTextField.EditorAction      += TextField_OnDone;

            // Create array adapters for each spinner.
            ArrayAdapter <string> BaseDamageSpinnerArrayAdapter         = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, BaseDamageSpinnerSetsLabels);
            ArrayAdapter <DamageSet.AcriStone> StoneSpinnerArrayAdapter = new ArrayAdapter <DamageSet.AcriStone>(this, Android.Resource.Layout.SimpleSpinnerItem, StoneSpinnerStones);

            BaseDamageSpinnerArrayAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);

            // Set the spinners to have the correct array adapters.
            BaseDamageSpinner.Adapter = BaseDamageSpinnerArrayAdapter;

            // Add numbers to the number picker.
            DamageModifier.MinValue = 0;
            DamageModifier.MaxValue = 20;

            // Set the stone text field's font.
            var barazhad = ResourcesCompat.GetFont(this, Resource.Font.barazhad);

            StoneTextField.Typeface = barazhad;


            // Get selected weapon attributes.
            if (Intent.Extras.GetString("WeaponName") != null)
            {
                SelectedWeaponIndex  = Intent.Extras.GetInt("WeaponIndex");
                ResultWeaponName     = Intent.Extras.GetString("WeaponName");
                ResultDamageDice     = (JsonConvert.DeserializeObject <DamageSet>(Intent.Extras.GetString("BaseDamage")).DamageDice);
                ResultDamageModifier = (JsonConvert.DeserializeObject <DamageSet>(Intent.Extras.GetString("BaseDamage")).DamageBonus);
                ResultAcriStoneCode  = Intent.Extras.GetString("Stone");

                WeaponNameTextField.Text = ResultWeaponName;
                var damageDiceIndex = BaseDamageSpinnerSets.FindIndex(x => JsonConvert.SerializeObject(x) == JsonConvert.SerializeObject(ResultDamageDice));
                BaseDamageSpinner.SetSelection(damageDiceIndex);
                DamageModifier.Value = ResultDamageModifier;
                StoneTextField.Text  = ResultAcriStoneCode;
            }
            else
            {
                WeaponNameTextField.Text = "Unnamed Weapon";
                BaseDamageSpinner.SetSelection(0);
                DamageModifier.Value = 0;
                StoneTextField.Text  = "";
            }
        }