private static BitmapDrawable GetCircleForProgress() { var conf = Bitmap.Config.Argb4444; if (_progressImage == null) { _progressImage = Bitmap.CreateBitmap(_windowSize.Width, _windowSize.Height, conf); } var canvas = new Canvas(_progressImage); var paint = new Paint(); paint.SetStyle(Paint.Style.Stroke); paint.StrokeWidth = 3; paint.AntiAlias = true; paint.Color = _colorToUse; canvas.DrawPaint(new Paint() { Color = Android.Graphics.Color.White }); if (Progress > 20) { _activity.RunOnUiThread(() => { var ll = _layoutCenter.LayoutParameters; if (ll.Height != _windowSize.Height) { ll.Height = _windowSize.Height; _layoutCenter.LayoutParameters = ll; _layoutCenter.RequestFocus(); } }); canvas.DrawBitmap(_car, _zoneCircle.CenterX() - _car.Width / 2f, _zoneCircle.CenterY() - _car.Height / 2f, null); var startAngle = -90f; var sweepingAngle = ((Progress - 20f) / 80f) * 360f; canvas.DrawArc(_zoneCircle, startAngle, sweepingAngle, false, paint); } else { _activity.RunOnUiThread(() => { var ll = _layoutCenter.LayoutParameters; ll.Height = (int)(((float)Progress / 20f) * _windowSize.Height); _layoutCenter.LayoutParameters = ll; _layoutCenter.RequestLayout(); }); } _layoutCenter.RequestLayout(); return(new BitmapDrawable(_progressImage)); }
private void UpdateMessages(User user) { LinearLayout messageList = FindViewById <LinearLayout> (Resource.Id.messageLayout); messageList.RemoveAllViews(); var x = db.Table <Message> (); List <Message> tmp = x.Where(q => q.conversation == conversation).OrderBy(e => e.time).Reverse().Take(visibleMessages).Reverse().ToList(); string prevDate = "0000-00-00"; foreach (var elem in tmp) { if (!elem.time.StartsWith(prevDate)) { prevDate = TimeConverter.Convert(elem.time, "yyyy-MM-dd"); View timeInsert; if (setting.FontSize == Setting.Size.large) { timeInsert = LayoutInflater.Inflate(Resource.Layout.TimeInsertLarge, null); } else { timeInsert = LayoutInflater.Inflate(Resource.Layout.TimeInsert, null); } TextView text = timeInsert.FindViewById <TextView> (Resource.Id.timeInsertTime); text.Text = TimeConverter.AutoConvertDate(elem.time); messageList.AddView(timeInsert); } AddMessage(messageList, elem); } messageList.Post(() => messageList.RequestLayout()); }
private int SetItemListContainerHeight(LinearLayout layout, Android.Support.V7.Widget.Toolbar layoutBelow) { var rlCheckoutButtonContainer = thisFragmentView.FindViewById <RelativeLayout>(Resource.Id.rlCheckoutButtonContainer); int actionBarHeight = dpToPixel(40); int tabLayoutHeight = mTabs.Height; int searchToolBarHeight = toolbar.Height; int checkoutButtonHeight = rlCheckoutButtonContainer.Height; int marginOffset = dpToPixel(10); int fragmentContainerHeight = thisFragmentViewOriginalHeight; int calculatedHeight = fragmentContainerHeight - (actionBarHeight + tabLayoutHeight + searchToolBarHeight + checkoutButtonHeight + marginOffset); int _topMargin = 0; int _bottomMargin = 0; int _leftMargin = dpToPixel(5); int _rightMargin = dpToPixel(5); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, calculatedHeight); layoutParams.SetMargins(_leftMargin, _topMargin, _rightMargin, _bottomMargin); layoutParams.AddRule(LayoutRules.Below, layoutBelow.Id); layout.LayoutParameters = layoutParams; layout.RequestLayout(); return(calculatedHeight); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); List <int> tiePlayerNumbers = GetTiePlayerNumbers(Application.GameScoreSubmitScoreData, Game.RoundNumber); LinearLayout container = FindViewById <LinearLayout>(Resource.Id.container); PlayersBuildingChose playersPanel = new PlayersBuildingChose(this, Resources.GetString(Resource.String.medina), 2, 10, new List <int>(), tiePlayerNumbers.ToDictionary(p => p, p => Game.GetPlayer(p).Name), SettingsType.ValidateBuildingsPrice); container.AddView(playersPanel); container.RequestLayout(); Button confirmButton = FindViewById <Button>(Resource.Id.confirmButton); confirmButton.Click += new EventHandler((object sender, EventArgs e) => { if (playersPanel.PlayersPanels.ValidatePlayerPanels()) { Dictionary <int, int> playersHighestPrices = new Dictionary <int, int>(); foreach (int playerNumber in tiePlayerNumbers) { playersHighestPrices[playerNumber] = playersPanel.PlayersPanels[playerNumber - 1].Value; } Application.ConfirmMedinasNumber(this, playersHighestPrices); } }); }
public void UpdateBackgroundViewHeight(int height, LinearLayout layout, int aspect = 1) { var paramList = layout.LayoutParameters; paramList.Height = height - GetUnderViewHeight(aspect);; layout.LayoutParameters = paramList; layout.RequestLayout(); layout.Invalidate(); }
private void SetSearchActiveGridHeight(LinearLayout _layout, int _gridheight, int _buttonheight, Android.Support.V7.Widget.Toolbar layoutBelow) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, _gridheight - _buttonheight); layoutParams.SetMargins(dpToPixel(5), 0, dpToPixel(5), 0); layoutParams.AddRule(LayoutRules.Below, layoutBelow.Id); _layout.LayoutParameters = layoutParams; _layout.RequestLayout(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Dictionary <GranadaBuildingType, List <int> > tiePlayerNumbers = GetTiePlayerNumbers(Application.GameScoreSubmitScoreData, Game.RoundNumber); LinearLayout container = FindViewById <LinearLayout>(Resource.Id.container); Dictionary <GranadaBuildingType, PlayersBuildingChose> playersPanels = new Dictionary <GranadaBuildingType, PlayersBuildingChose>(); foreach (GranadaBuildingType building in Game.GranadaBuildingsOrder) { PlayersBuildingChose playersPanel = null; if (tiePlayerNumbers[building].Count != 0) { playersPanel = new PlayersBuildingChose(this, building.GetEnumDescription(Resources), 2, 12, new List <int>() { 3, 5, 7, 9, 11 }, tiePlayerNumbers[building].ToDictionary(p => p, p => Game.GetPlayer(p).Name), SettingsType.ValidateBuildingsPrice); container.AddView(playersPanel); container.RequestLayout(); } playersPanels[building] = playersPanel; } Button confirmButton = FindViewById <Button>(Resource.Id.confirmButton); confirmButton.Click += new EventHandler((object sender, EventArgs e) => { bool correct = true; Dictionary <GranadaBuildingType, Dictionary <int, int> > result = new Dictionary <GranadaBuildingType, Dictionary <int, int> >(); foreach (KeyValuePair <GranadaBuildingType, PlayersBuildingChose> playersPanel in playersPanels) { Dictionary <int, int> playersHighestPrices = new Dictionary <int, int>(); if (playersPanel.Value != null) { if (!playersPanel.Value.PlayersPanels.ValidatePlayerPanels()) { correct = false; break; } foreach (int playerNumber in tiePlayerNumbers[playersPanel.Key]) { playersHighestPrices[playerNumber] = playersPanel.Value.PlayersPanels[playerNumber - 1].Value; } } result[playersPanel.Key] = playersHighestPrices; } if (correct) { Application.ConfirmGranadaBuildingsNumbers(this, result); } }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); container = FindViewById <LinearLayout>(Resource.Id.container); foreach (ResultHistory resultHistory in Application.Results) { HistoryPanel historyPanel = new HistoryPanel(this, resultHistory.StartDateTime, (DateTime)resultHistory.EndDateTime, resultHistory.Players.Where(p => p.Name != Player.DirkName).Select(p => p.Name).ToList()); container.AddView(historyPanel); container.RequestLayout(); } }
public void RemoveResult(HistoryPanel historyPanel) { new AlertDialog.Builder(this) .SetTitle(Resources.GetString(Resource.String.result_removing)) .SetMessage(Resources.GetString(Resource.String.continue_question)) .SetPositiveButton(Resources.GetString(Resource.String.yes), new DialogInterfaceOnClickListener((IDialogInterface dialog, int which) => { container.RemoveView(historyPanel); container.RequestLayout(); Application.RemoveResult(historyPanel.StartDateTime); Application.SaveResults(); })) .SetNegativeButton(Resources.GetString(Resource.String.no), new DialogInterfaceOnClickListener(null)) .Show(); }
private void SetContentsLayoutHeight(LinearLayout layout, SupportToolbar layoutBelow) { int checkoutButtonHeight = mLlSaveButtonContainer.Height; int layoutHeight = layout.Height; int _topMargin = dpToPixel(0); int _bottomMargin = dpToPixel(5); int _leftMargin = 0; int _rightMargin = 0; int calculatedHeight = layoutHeight - checkoutButtonHeight; calculatedHeight = calculatedHeight - _bottomMargin; RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, calculatedHeight); layoutParams.SetMargins(_leftMargin, _topMargin, _rightMargin, _bottomMargin); layoutParams.AddRule(LayoutRules.Below, layoutBelow.Id); layout.LayoutParameters = layoutParams; layout.RequestLayout(); }
internal void Initialize() { _rootLayout = new LinearLayout(Context) { Orientation = Orientation.Vertical, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _rootLayout.SetGravity(GravityFlags.Top); _editSummary = new TextView(Context) { LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _editSummary.SetTextColor(_foregroundColor); _rootLayout.AddView(_editSummary); _customHtmlDescription = new TextView(Context) { LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _customHtmlDescription.SetTextColor(_foregroundColor); _rootLayout.AddView(_customHtmlDescription); _detailsList = new ListView(Context) { ClipToOutline = true, Clickable = false, ChoiceMode = ChoiceMode.None, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), ScrollingCacheEnabled = false, PersistentDrawingCache = PersistentDrawingCaches.NoCache, }; _rootLayout.AddView(_detailsList); AddView(_rootLayout); _rootLayout.RequestLayout(); }
private void ShowChats(User user) { TextView placeholder = FindViewById <TextView> (Resource.Id.placeholder); var x = db.Table <Chat> (); if (x.Count() > 0) { placeholder.Visibility = ViewStates.Gone; } else { placeholder.Visibility = ViewStates.Visible; placeholder.Text = "No chats found."; } LinearLayout chatList = FindViewById <LinearLayout> (Resource.Id.chatList); chatList.RemoveAllViews(); foreach (var elem in x.OrderByDescending(e => e.time)) { View v; if (setting.FontSize == Setting.Size.large) { v = LayoutInflater.Inflate(Resource.Layout.ChatLarge, null); } else { v = LayoutInflater.Inflate(Resource.Layout.Chat, null); } TextView name = v.FindViewById <TextView>(Resource.Id.chatName); TextView message = v.FindViewById <TextView>(Resource.Id.chatMessage); TextView time = v.FindViewById <TextView>(Resource.Id.chatTime); ImageView image = v.FindViewById <ImageView> (Resource.Id.chatImage); new Thread(async() => { try { string conv = elem.conversation; if (conv.Split(',').Length == 2) { if (conv.Split(',')[0] == user.user) { conv = conv.Split(',')[1]; } else { conv = conv.Split(',')[0]; } } var imageBitmap = await network.GetImageBitmapFromUrl(Resources.GetString(Resource.String.profileUrl) + conv + ".png", AsyncNetwork.MINI_PROFILE_SIZE, AsyncNetwork.MINI_PROFILE_SIZE); RunOnUiThread(() => image.SetImageBitmap(imageBitmap)); } catch (Exception e) { Log.Error("BlaChat", e.StackTrace); } }).Start(); name.Text = elem.name; var tmp = db.Table <Message> ().Where(q => q.conversation == elem.conversation).OrderByDescending(q => q.time); var lastMsg = tmp.FirstOrDefault(); if (lastMsg != null) { var escape = lastMsg.text.Replace(""", "\""); escape = escape.Replace("<", "<"); escape = escape.Replace(">", ">"); escape = escape.Replace("&", "&"); if (lastMsg.nick == user.user) { message.Text = "Du: " + escape; } else { if (elem.conversation.Split(',').Length == 2 && lastMsg.nick != "watchdog") { message.Text = escape; } else { message.Text = lastMsg.author + ": " + escape; } } time.Text = TimeConverter.AutoConvert(lastMsg.time); } else { time.Text = ""; message.Text = "No message"; } v.Clickable = true; v.Click += delegate { Finish(); var intent = new Intent(this, typeof(ChatActivity)); intent.PutExtra("conversation", elem.conversation); StartActivity(intent); var chat = db.Get <Chat> (elem.conversation); new Thread(async() => { if (textShare != null) { while (!await network.SendMessage(db, user, chat, "(Shared Text) " + textShare)) { await network.Authenticate(db, user); } } foreach (var file in fileset) { Bitmap img = MediaStore.Images.Media.GetBitmap(ContentResolver, file); while (!await network.SendImage(db, user, chat, img)) { await network.Authenticate(db, user); } } }).Start(); }; chatList.AddView(v); } chatList.Post(() => chatList.RequestLayout()); }
private void Initialize() { if (!DesignTime.IsDesignMode) { TargetWidth = CalculateScreenDimension(200); } // Vertically-oriented layout for containing all scalebar components _rootLayout = new LinearLayout(Context) { Orientation = Orientation.Vertical, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _rootLayout.SetGravity(GravityFlags.Top); // Initialize scalebar components with placeholder sizes and values var scalelineHeight = CalculateScreenDimension(2); _combinedScaleLine = new RectangleView(Context, TargetWidth, scalelineHeight) { BackgroundColor = ForegroundColor }; _metricScaleLine = new RectangleView(Context, TargetWidth, 1); _metricValue = new TextView(Context) { Text = "100" }; _metricUnit = new TextView(Context) { Text = "m" }; _usScaleLine = new RectangleView(Context, _metricScaleLine.Width * .9144, 1); _usValue = new TextView(Context) { Text = "300" }; _usUnit = new TextView(Context) { Text = "ft" }; var fontSize = 12; _metricValue.SetTextSize(ComplexUnitType.Dip, fontSize); _metricValue.SetTextColor(ForegroundColor); _metricUnit.SetTextSize(ComplexUnitType.Dip, fontSize); _metricUnit.SetTextColor(ForegroundColor); _usValue.SetTextSize(ComplexUnitType.Dip, fontSize); _usValue.SetTextColor(ForegroundColor); _usUnit.SetTextSize(ComplexUnitType.Dip, fontSize); _usUnit.SetTextColor(ForegroundColor); // Listen for width updates on metric and imperial scale lines to update the combined scale line _metricScaleLine.PropertyChanged += ScaleLine_PropertyChanged; _usScaleLine.PropertyChanged += ScaleLine_PropertyChanged; // =============================================================== // First row - placeholder, numeric text, and units text // =============================================================== var firstRowLayout = new LinearLayout(Context) { Orientation = Orientation.Horizontal, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; firstRowLayout.AddView(_metricScaleLine); firstRowLayout.AddView(_metricValue); firstRowLayout.AddView(_metricUnit); // ================================================================================ // Second row - first metric tick line, placeholder, and second metric tick line // ================================================================================ var secondRowLayout = new LinearLayout(Context) { Orientation = Orientation.Horizontal, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; var tickWidth = CalculateScreenDimension(2); var tickHeight = CalculateScreenDimension(5); _firstMetricTickLine = new RectangleView(Context, tickWidth, tickHeight) { BackgroundColor = ForegroundColor }; _metricWidthPlaceholder = new RectangleView(Context, _metricScaleLine.Width, 1); _secondMetricTickLine = new RectangleView(Context, tickWidth, tickHeight) { BackgroundColor = ForegroundColor }; secondRowLayout.AddView(_firstMetricTickLine); secondRowLayout.AddView(_metricWidthPlaceholder); secondRowLayout.AddView(_secondMetricTickLine); // ============================================================================================== // Third row - filler segment at start of scale line, combined metric/imperial scale line // ============================================================================================== var thirdRowLayout = new LinearLayout(Context) { Orientation = Orientation.Horizontal, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _scaleLineStartSegment = new RectangleView(Context, Math.Round(tickWidth) * 2, scalelineHeight) { BackgroundColor = ForegroundColor }; thirdRowLayout.AddView(_scaleLineStartSegment); thirdRowLayout.AddView(_combinedScaleLine); // ============================================================================================== // Fourth row - first imperial tick line, placeholder, second imperial tick line // ============================================================================================== var fourthRowLayout = new LinearLayout(Context) { Orientation = Orientation.Horizontal, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _firstUsTickLine = new RectangleView(Context, tickWidth, tickHeight) { BackgroundColor = ForegroundColor }; _secondUsTickLine = new RectangleView(Context, tickWidth, tickHeight) { BackgroundColor = ForegroundColor }; fourthRowLayout.AddView(_firstUsTickLine); fourthRowLayout.AddView(_usScaleLine); fourthRowLayout.AddView(_secondUsTickLine); // ========================================================================== // Fifth row - placeholder, imperial numeric text, imperial unit text // ========================================================================== var fifthRowLayout = new LinearLayout(Context) { Orientation = Orientation.Horizontal, LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), }; _usWidthPlaceholder = new RectangleView(Context, _usScaleLine.Width, 1); fifthRowLayout.AddView(_usWidthPlaceholder); fifthRowLayout.AddView(_usValue); fifthRowLayout.AddView(_usUnit); // Add all scalebar rows to the root layout _rootLayout.AddView(firstRowLayout); _rootLayout.AddView(secondRowLayout); _rootLayout.AddView(thirdRowLayout); _rootLayout.AddView(fourthRowLayout); _rootLayout.AddView(fifthRowLayout); // Add root layout to view AddView(_rootLayout); _rootLayout.RequestLayout(); }
// --------------------------------------------------------------------- #endregion #region Private methods /* buildGrid =========================================================== * * Build the puzzle grid. This function creates the puzzle grid as a * 3x3 grid spaced evenly across the screen. Each grid cell contains * another 3x3 grid and each cell of the subgrids contains a textview * that can be accessed by IDs 0 - 80. * * ------------------------------------------------------------------ */ private void buildGrid() { //A var to assign unique IDs to each textview cell in the grid. int idCounter; //Loop counters. int xLoop; int yLoop; #region Top level grid layout: //Create a square percent layout to hold the main grid. SquarePercentLayout mainGridLayout = new SquarePercentLayout(myMainActivity); //Set main grid children to wrap. PercentRelativeLayout.LayoutParams mainGridLayoutParms = new PercentRelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ); //Set main grid layout parms. mainGridLayout.LayoutParameters = mainGridLayoutParms; //Set main grid background. mainGridLayout.SetBackgroundColor(Android.Graphics.Color.Black); //Add main grid to top layout. this.AddView(mainGridLayout); #endregion //Init ID counter. idCounter = 0; //For each subgrid in the main grid... for (xLoop = 0; xLoop < 9; xLoop++) { #region Subgrid outer frame: (LinearLayout) //Create subgrid outer frame. LinearLayout subGridFrame = new LinearLayout(myMainActivity); //Create parameters for subgrid frame. PercentRelativeLayout.LayoutParams subGridFrameLayoutParms = new PercentRelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); //Get percent layout helper for subgrid frame. PercentLayoutHelper.PercentLayoutInfo pctLayoutHelper = subGridFrameLayoutParms.PercentLayoutInfo; //Set left and top margins. pctLayoutHelper.LeftMarginPercent = ((xLoop % 3) * (1 / 3f)); pctLayoutHelper.TopMarginPercent = ((xLoop / 3) * (1 / 3f)); //Set subgrid container width to 1/3 of parent. pctLayoutHelper.WidthPercent = (1 / 3f); //Set background and padding for large gridlines. subGridFrame.SetBackgroundColor(Android.Graphics.Color.Black); subGridFrame.SetPadding(2, 2, 2, 2); //Set outer frame parms. subGridFrame.LayoutParameters = subGridFrameLayoutParms; //Set to center child view. subGridFrame.SetGravity(GravityFlags.Center); //Add subgrid frame to main grid. mainGridLayout.AddView(subGridFrame); #endregion #region Subgrid layout: (SquarePercentLayout) //Create a new square percent layout for the subgrid. SquarePercentLayout subGridLayout = new SquarePercentLayout(myMainActivity); //Set subgrid layout to match parent. PercentRelativeLayout.LayoutParams subGridLayoutParms = new PercentRelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); //Set subgrid layout parms. subGridLayout.LayoutParameters = subGridLayoutParms; //Set subgrid background. subGridLayout.SetBackgroundColor(Android.Graphics.Color.Black); subGridFrame.RequestLayout(); //Add subgrid to subgrid frame. subGridFrame.AddView(subGridLayout); #endregion //For each cell in subgrid... for (yLoop = 0; yLoop < 9; yLoop++) { #region Number field outer frame: (LinearLayout) //Create a linear layout for the num holder outer frame. LinearLayout numFieldLayout = new LinearLayout(myMainActivity); //Set subgrid layout to match parent. PercentRelativeLayout.LayoutParams numFieldLayoutParms = new PercentRelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); //Get subgrid layout helper. PercentLayoutHelper.PercentLayoutInfo numFieldLayoutHelper = numFieldLayoutParms.PercentLayoutInfo; //Set left and top margins. numFieldLayoutHelper.LeftMarginPercent = ((yLoop % 3) * (1 / 3f)); numFieldLayoutHelper.TopMarginPercent = ((yLoop / 3) * (1 / 3f)); //Set subgrid container width. numFieldLayoutHelper.WidthPercent = (1 / 3f); //Set subgrid layout parms. numFieldLayout.LayoutParameters = numFieldLayoutParms; //Add frame to subgrid. subGridLayout.AddView(numFieldLayout); #endregion #region Number field layout: (SquarePercentLayout) //Create square percent layout for the num field. SquarePercentLayout numFieldHolder = new SquarePercentLayout(myMainActivity); //Set num field holder layout to match parent. PercentRelativeLayout.LayoutParams numfieldHolderParms = new PercentRelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); //Set subgrid layout parms. numFieldHolder.LayoutParameters = numfieldHolderParms; //Set subgrid padding to show small gridlines. numFieldHolder.SetPadding(2, 2, 2, 2); //Add num field holder to layout frame. numFieldLayout.AddView(numFieldHolder); #endregion #region Number field: (FitTextView) //Create num field. FitTextView numField = new FitTextView(myMainActivity); //Set numfield ID. numField.Id = idCounter; idCounter++; //Center num field. numField.Gravity = GravityFlags.Center; //Set numfield layout to match parent view. numField.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ); //No font padding. numField.SetIncludeFontPadding(false); //Set so we don't lose numfield text on rotate. numField.FreezesText = true; //Set field text value. setNumText(numField); //Cells don't need focus because we are using our num picker. numField.Focusable = false; //Set callback for click to show our num picker. numField.Click += (object sender, EventArgs e) => { showNumPicker((FitTextView)sender); }; //Set field background color. numField.SetBackgroundColor(Android.Graphics.Color.DarkGreen); //Lay out field. numField.RequestLayout(); //Add field to holder. numFieldHolder.AddView(numField); #endregion } } }
private void ShowChats(User user) { TextView placeholder = FindViewById <TextView> (Resource.Id.placeholder); var x = db.Table <Chat> (); if (x.Count() > 0) { placeholder.Visibility = ViewStates.Gone; } else { placeholder.Visibility = ViewStates.Visible; placeholder.Text = "No chats found."; } LinearLayout chatList = FindViewById <LinearLayout> (Resource.Id.chatList); chatList.RemoveAllViews(); foreach (var elem in x.OrderByDescending(e => e.time)) { View v; if (setting.FontSize == Setting.Size.large) { v = LayoutInflater.Inflate(Resource.Layout.ChatLarge, null); } else { v = LayoutInflater.Inflate(Resource.Layout.Chat, null); } TextView name = v.FindViewById <TextView>(Resource.Id.chatName); TextView message = v.FindViewById <TextView>(Resource.Id.chatMessage); TextView time = v.FindViewById <TextView>(Resource.Id.chatTime); ImageView image = v.FindViewById <ImageView> (Resource.Id.chatImage); if (elem.Marked) { message.SetTypeface(null, TypefaceStyle.Bold); } new Thread(async() => { try { string conv = elem.conversation; if (conv.Split(',').Length == 2) { if (conv.Split(',')[0] == user.user) { conv = conv.Split(',')[1]; } else { conv = conv.Split(',')[0]; } } var imageBitmap = await network.GetImageBitmapFromUrl(Resources.GetString(Resource.String.profileUrl) + conv + "_mini.png", AsyncNetwork.MINI_PROFILE_SIZE, AsyncNetwork.MINI_PROFILE_SIZE); if (imageBitmap == null) { imageBitmap = await network.GetImageBitmapFromUrl(Resources.GetString(Resource.String.profileUrl) + "user_mini.png", AsyncNetwork.MINI_PROFILE_SIZE, AsyncNetwork.MINI_PROFILE_SIZE); } RunOnUiThread(() => { if (isUnbound()) { return; } image.SetImageBitmap(imageBitmap); }); } catch (Exception e) { Log.Error("BlaChat", e.StackTrace); } }).Start(); name.Text = SmileyTools.GetSmiledTextUTF(elem.name); var tmp = db.Table <Message> ().Where(q => q.conversation == elem.conversation).OrderByDescending(q => q.time); var lastMsg = tmp.FirstOrDefault(); if (lastMsg != null) { var escape = lastMsg.text.Replace(""", "\""); escape = escape.Replace("<", "<"); escape = escape.Replace(">", ">"); escape = escape.Replace("&", "&"); if (escape.StartsWith("#image")) { escape = "(image)"; } else if (escape.StartsWith("#video")) { escape = "(video)"; } if (lastMsg.nick == user.user) { message.Text = SmileyTools.GetSmiledTextUTF("Du: " + escape); //message.SetTextColor(Color.DarkBlue); message.SetTypeface(null, TypefaceStyle.Italic); } else { if (elem.conversation.Split(',').Length == 2 && lastMsg.nick != "watchdog") { message.Text = SmileyTools.GetSmiledTextUTF(escape); } else { message.Text = SmileyTools.GetSmiledTextUTF(lastMsg.author + ": " + escape); } //message.SetTextColor(Color.DarkGreen); } time.Text = TimeConverter.AutoConvert(lastMsg.time); } else { time.Text = ""; message.Text = "No message"; } v.Clickable = true; v.Click += delegate { var intent = new Intent(this, typeof(ChatActivity)); intent.PutExtra("conversation", elem.conversation); StartActivity(intent); }; chatList.AddView(v); } chatList.Post(() => chatList.RequestLayout()); }