public void FileListReceivedDelegate(List <string> fileList) { TextView ACTVItem; transferLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout_filetransfer); transferLayout.Post(() => { int i = 2; }); transferLayout.Post(() => { //Toast.MakeText(this, fileList.Count.ToString(), ToastLength.Short).Show(); transferLayout.RemoveAllViews(); foreach (string item in fileList) { ACTVItem = new TextView(this); ACTVItem.SetTextAppearance(Android.Resource.Style.TextAppearanceSmall); float factor = this.Resources.DisplayMetrics.Density; LinearLayout.LayoutParams paramss = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, (int)(40 * factor)); paramss.SetMargins(2, 2, 2, 2); ACTVItem.LayoutParameters = paramss; ACTVItem.TextAlignment = TextAlignment.Center; ACTVItem.Clickable = true; ACTVItem.Focusable = true; ACTVItem.Background = GetDrawable(Resource.Drawable.ACTextViewBackground); ACTVItem.Gravity = GravityFlags.Center; ACTVItem.Text = item; ACTVItem.Click += (o, e) => { TextView oo = o as TextView; const string permission = Android.Manifest.Permission.WriteExternalStorage; if (CheckSelfPermission(permission) == (int)Permission.Granted) { CommClientAndroid client = ClientHolder.Client; client.FileReceivedAction = FileReceivedDelegate; client.ProgressBarAction = ProgressBarDelegate; if (client.currentlyDownloadingFile == false) { client.DownloadFile(oo.Text, oo); } //client.RemoveFile(oo.Text); //ViewGroup parent = (ViewGroup)oo.Parent; //parent.RemoveView(oo); } else { Toast.MakeText(this, Resources.GetString(Resource.String.insufficient_permisions), ToastLength.Long).Show(); } }; transferLayout.AddView(ACTVItem); } }); }
private void SetGridLayout(LayoutInflater inflater, ViewGroup container, bool isGrid) { mRecyclerViewItemsList = thisFragmentView.FindViewById <RecyclerView>(Resource.Id.recyclerViewItemsList); //Create Layout Manager if (isGrid == true) { mLayoutManager = new GridLayoutManager((MainActivity)this.Activity, 3); } else { mLayoutManager = new LinearLayoutManager((MainActivity)this.Activity); } mRecyclerViewItemsList.SetLayoutManager(mLayoutManager); mRecyclerViewItemsList.HasFixedSize = true; mGridHolder = thisFragmentView.FindViewById <LinearLayout>(Resource.Id.recyclerViewItemsListHolder); //POST RENDERING mGridHolder.Post(() => { mRecyclerViewItemsList.SetAdapter(new CheckoutRecyclerViewAdapter(mDpVal, SetItemListContainerHeight(mGridHolder, toolbar), PopulateProductData2(""), PopulateParentProducts(""), mIsGrid, mRecyclerViewItemsList, mBtnCheckoutButton, Context, mShowSizes, this, GlobalVariables.mCurrentSelectedPricingType)); }); }
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()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.Title = (Resources.GetString(Resource.String.file_transfer)); SetContentView(Resource.Layout.filetransfer_submenu); TryGetStorage(); transferLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout_filetransfer); client = ClientHolder.Client; client.FileListReceivedAction = FileListReceivedDelegate; client.BrokenFileAction = delegate(string input) { transferLayout.Post(delegate { Toast.MakeText(this, input, ToastLength.Short).Show(); }); }; client.InstantiateTransfer(); // Create your application here }
private void UpdatePadding() { ConstraintLayout checkboxLayout = FindViewById <ConstraintLayout>(Resource.Id.checkbox_layout); LinearLayout consentInfoLayout = FindViewById <LinearLayout>(Resource.Id.consent_info_layout); // Post method moves setting padding to the end of action queue for consent_info_layout and sets padding when // height of checkbox_layout will be known. In this way we have dynamic padding. consentInfoLayout.Post(() => consentInfoLayout.SetPadding( consentInfoLayout.PaddingLeft, consentInfoLayout.PaddingTop, consentInfoLayout.PaddingRight, checkboxLayout.Height)); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { linearLayout = new LinearLayout(this.Context) { Orientation = Orientation.Vertical }; scrollView = new ScrollView(this.Context) { LayoutParameters = new LinearLayout.LayoutParams(-1, -1, 1.0f), FillViewport = true }; textView = new TextView(this.Context) { Text = "", Gravity = GravityFlags.Top, LayoutParameters = new ViewGroup.LayoutParams(-1, -2), Typeface = Typeface.Monospace, TextSize = 12, }; textView.SetPadding(DpInt(8), DpInt(8), DpInt(8), DpInt(8)); textView.SetBackgroundColor(Color.Black); textView.SetTextColor(Color.LightGray); textView.SetText(ssb, TextView.BufferType.Spannable); editText = new EditText(this.Context) { Background = null, LayoutParameters = new LinearLayout.LayoutParams(-1, -2, 0f), Hint = "Input here", InputType = InputTypes.ClassText }; editText.SetSingleLine(); editText.ImeOptions = ImeAction.Send; editText.SetOnEditorActionListener(this); scrollView.AddView(textView); linearLayout.AddView(scrollView); linearLayout.AddView(editText); linearLayout.Post(StartConsole); return(linearLayout); }
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()); }
public void AutoConfigFinished(List <string> outputLista) { EditText textBoxIP = FindViewById <EditText>(Resource.Id.textBoxIP); LinearLayout ACLayout = FindViewById <LinearLayout>(Resource.Id.linearLayoutAC); if (textBoxIP.Text == "acdebug") { autoConfigClient.listaWykrytychIP.Add("192.168.50.190"); autoConfigClient.listaWykrytychIP.Add("debug"); autoConfigClient.listaWykrytychIP.Add("127.0.0.1"); autoConfigClient.listaWykrytychIP.Add("1.2.3.4"); } //string final = ""; ////foreach(string item in outputLista) ////{ //// //final += item + " "; ////} //final += "finished"; //TextView textViewForIPS = FindViewById<TextView>(Resource.Id.textView_test); //textViewForIPS.Post(() => //{ // textViewForIPS.Text = final; //}); TextView ACTVItem; ACLayout.Post(() => { ACLayout.RemoveAllViews(); if (outputLista.Count == 0) { Toast.MakeText(this, Resources.GetString(Resource.String.no_clients), ToastLength.Short).Show(); } foreach (string item in outputLista) { ACTVItem = new TextView(this); ACTVItem.SetTextAppearance(Android.Resource.Style.TextAppearanceMedium); float factor = this.Resources.DisplayMetrics.Density; LinearLayout.LayoutParams paramss = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, (int)(40 * factor)); paramss.SetMargins(2, 2, 2, 2); ACTVItem.LayoutParameters = paramss; ACTVItem.TextAlignment = TextAlignment.Center; ACTVItem.Clickable = true; ACTVItem.Focusable = true; ACTVItem.Background = GetDrawable(Resource.Drawable.ACTextViewBackground); ACTVItem.Gravity = GravityFlags.Center; ACTVItem.Text = item; ACTVItem.Click += (o, e) => { TextView oo = o as TextView; textBoxIP.Text = oo.Text; }; ACLayout.AddView(ACTVItem); } }); }
void IniForms() { var layoutParams = (ViewGroup.MarginLayoutParams)layout.LayoutParameters; layoutParams.RightMargin = (int)context.Resources.GetDimension(Resource.Dimension.activity_vertical_margin); layoutParams.LeftMargin = (int)context.Resources.GetDimension(Resource.Dimension.activity_vertical_margin); layoutParams.TopMargin = (int)context.Resources.GetDimension(Resource.Dimension.activity_vertical_margin); layoutParams.BottomMargin = (int)context.Resources.GetDimension(Resource.Dimension.activity_vertical_margin); layout.LayoutParameters = layoutParams; TextView txtDescription; EditText ediText; for (int item = 0; item <= model.CamposForm.campos.Count - 1; item++) { var forms = model.CamposForm.campos[item].tipo; var minCaract = model.CamposForm.campos[item].minCaracteres; var maxCaract = model.CamposForm.campos[item].maxCaracteres; var conteudoString = model.CamposForm.campos[item].conteudo; switch (forms) { case (0): txtDescription = new TextView(context); IniLabel(txtDescription); ediText = new EditText(context); ediText.SetMaxLines(1); ediText.InputType = InputTypes.TextFlagMultiLine; IniEditText(ediText, txtDescription, model.CamposForm.campos[item].descricao, minCaract, maxCaract); if (!string.IsNullOrEmpty(conteudoString)) { ediText.Text = conteudoString; } layout.AddView(ediText); ediText.Tag = 0; break; case (1): txtDescription = new TextView(context); IniLabel(txtDescription); ediText = new EditText(context); ediText.SetMaxLines(1); ediText.InputType = InputTypes.ClassNumber | InputTypes.NumberFlagDecimal; IniEditText(ediText, txtDescription, model.CamposForm.campos[item].descricao, minCaract, maxCaract); if (!string.IsNullOrEmpty(conteudoString)) { ediText.Text = conteudoString; } layout.AddView(ediText); ediText.Tag = 1; break; case (2): if (!model.CamposForm.campos[item].descricao.ToUpper().Equals("RUPTURA")) { var chck = new CheckBox(context) { Text = model.CamposForm.campos[item].descricao }; chck.SetTextSize(ComplexUnitType.Sp, 20); chck.SetTextColor(ContextCompat.GetColorStateList(context, Resource.Color.verdeazulescuro)); var id = Resources.System.GetIdentifier("btn_check_holo_light", "drawable", "android"); chck.SetButtonDrawable(id); layout.AddView(chck); chck.Tag = 2; var checkString = model.CamposForm.campos[item].conteudo; if (checkString != null) { chck.Checked = Convert.ToBoolean(checkString); } chck.Post(delegate { var layoutCheck = (ViewGroup.MarginLayoutParams)chck.LayoutParameters; layoutCheck.TopMargin = (int)context.Resources.GetDimension(Resource.Dimension.padding_default); layoutCheck.BottomMargin = (int)context.Resources.GetDimension(Resource.Dimension.padding_default); chck.LayoutParameters = layoutCheck; }); } break; case (3): txtDescription = new TextView(context); IniLabel(txtDescription); var datePickerText = new EditText(context); datePickerText.SetMaxLines(1); IniEditText(datePickerText, txtDescription, model.CamposForm.campos[item].descricao, minCaract, maxCaract); datePickerText.Focusable = false; if (!datePickerText.HasOnClickListeners) { datePickerText.Click += delegate { var dateListener = new OnDateSetListener(datePickerText); new DatePickerDialog(context, Resource.Style.DialogTheme, dateListener, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).Show(); }; } if (!string.IsNullOrEmpty(conteudoString)) { datePickerText.Text = conteudoString; } layout.AddView(datePickerText); datePickerText.Tag = 3; break; case (4): txtDescription = new TextView(context); IniLabel(txtDescription); ediText = new EditText(context); ediText.SetMaxLines(1); IniEditText(ediText, txtDescription, model.CamposForm.campos[item].descricao, minCaract, 3); if (!string.IsNullOrEmpty(conteudoString)) { ediText.Text = conteudoString; } ediText.Focusable = false; layout.AddView(ediText); if (!ediText.HasOnClickListeners) { var index = layout.ChildCount - 1; ediText.Click += (sender, e) => { ShowPopUpSeekBar(index); }; } ediText.Tag = 4; break; case (5): var txt = new TextView(context); IniLabel(txt); var spinnerArray = new List <string> { "Selecione..." }; foreach (var spinnerItem in model.CamposForm.campos[item].opcoes) { try { if (spinnerItem != null) { var spinnerItemString = Convert.ToString(spinnerItem); spinnerArray.Add(spinnerItemString); } } catch (InvalidCastException) { /*Deu ruim na hora de converter tiu*/ } } var spinner = new Spinner(context); var spinnerArrayAdapter = new ArrayAdapter(context, Resource.Layout.support_simple_spinner_dropdown_item, spinnerArray); spinner.SetBackgroundResource(Resource.Drawable.spinner_background); if (Build.VERSION.SdkInt > BuildVersionCodes.IceCreamSandwich) { #pragma warning disable XA0001 // Find issues with Android API usage spinner.SetPopupBackgroundDrawable(ContextCompat.GetDrawable(context, Resource.Drawable.spinner_background)); #pragma warning restore XA0001 // Find issues with Android API usage } spinner.Adapter = spinnerArrayAdapter; if (!string.IsNullOrEmpty(conteudoString)) { var indexSelected = spinnerArray.IndexOf(conteudoString); if (indexSelected > 0) { spinner.SetSelection(indexSelected); } } layout.AddView(spinner); if (minCaract > 0) { txt.Text = model.CamposForm.campos[item].descricao + " *"; } else { txt.Text = model.CamposForm.campos[item].descricao; } spinner.Tag = 5; layout.Post(delegate { var layoutCheck = (ViewGroup.MarginLayoutParams)spinner.LayoutParameters; layoutCheck.TopMargin = (int)context.Resources.GetDimension(Resource.Dimension.padding_default); layoutCheck.BottomMargin = (int)context.Resources.GetDimension(Resource.Dimension.padding_default); spinner.LayoutParameters = layoutCheck; }); break; default: throw new InvalidCastException("Tipo nao reconhecido no formulário"); } } }
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()); }