Example #1
0
        private Android.Widget.LinearLayout AddStandardLayout(Android.App.AlertDialog.Builder builder,
                                                              string title, string msg)
        {
            Android.Widget.ScrollView   scrollView = new Android.Widget.ScrollView(builder.Context);
            Android.Widget.LinearLayout container  = new LinearLayout(builder.Context);
            int horizontalPadding = GetViewPadding(builder);
            int verticalPadding   = string.IsNullOrEmpty(msg) ? horizontalPadding : 0;

            container.Orientation = Android.Widget.Orientation.Vertical;
            container.SetPadding(
                /* left */ horizontalPadding,
                /* top */ verticalPadding,
                /* right */ horizontalPadding,
                /* bottom */ verticalPadding);
            scrollView.AddView(container);
            builder.SetTitle(title)
            .SetMessage(msg)
            .SetView(scrollView);
            return(container);
        }
Example #2
0
        public static void getTiles(Android.Widget.ScrollView parent)
        {
            parent.RemoveAllViewsInLayout();
            if (UserTiles != null)
            {
                UserTiles.Clear();
            }
            UserTiles = new List <LinearLayout>();
            int pixelDensity = (int)Android.Content.Res.Resources.System.DisplayMetrics.Density;
            ContextThemeWrapper mainContext = new ContextThemeWrapper(parent.Context, Resource.Style.MainLinearForUserTiles);
            LinearLayout        MainLinear  = new LinearLayout(mainContext);

            MainLinear.Orientation = Orientation.Vertical;
            parent.AddView(MainLinear);
            LinearLayout currentRow = null;
            int          i          = 0;

            foreach (User user in Controller._users)
            {
                if (i % 2 == 0)
                {
                    ContextThemeWrapper rowContext = new ContextThemeWrapper(parent.Context, Resource.Style.UserTileRowLayoutStyle);
                    currentRow             = new LinearLayout(rowContext);
                    currentRow.Orientation = Orientation.Horizontal;
                }

                ContextThemeWrapper userTileContext = new ContextThemeWrapper(parent.Context, Resource.Style.UserTileLayoutStyle);
                LinearLayout        currentUser     = new LinearLayout(userTileContext);
                currentUser.Orientation = Orientation.Vertical;
                currentUser.Id          = i;

                ContextThemeWrapper userNameContext = new ContextThemeWrapper(parent.Context, Resource.Style.UserNameCenteredText);
                TextView            userName        = new TextView(userNameContext);
                userName.Text = user.Name.FirstName;

                ContextThemeWrapper relativeLayoutStyle = new ContextThemeWrapper(parent.Context, Resource.Style.ProgressBorderStyle);
                FrameLayout         currentUserBar      = new FrameLayout(relativeLayoutStyle);

                ContextThemeWrapper        PgBarFillContext   = new ContextThemeWrapper(parent.Context, Resource.Style.ProgressBarFillStyle);
                Android.Widget.ProgressBar currentUserBarMask = new Android.Widget.ProgressBar(PgBarFillContext, null, Resource.Style.ProgressBarFillStyle);
                try
                {
                    double progress = (1 - ((double)user.Used / user.Allocated)) * 100;
                    currentUserBarMask.Progress = (int)(progress);
                }
                catch (DivideByZeroException)
                {
                    double progress = (1 - ((double)user.Used / Controller._totalRemainder)) * 100;
                    currentUserBarMask.Progress = (int)(progress);
                }

                currentUserBar.AddView(currentUserBarMask);
                currentUser.AddView(userName);
                currentUser.AddView(currentUserBar);
                UserTiles.Add(currentUser);
                currentRow.AddView(currentUser);
                MainLinear.RemoveView(currentRow);
                MainLinear.AddView(currentRow);
                i++;
            }
        }