protected override void Dispose(bool disposing) { if (disposing && !_disposed) { if (prevBtn != null) { prevBtn.Click -= PrevBtn_Click; prevBtn.Dispose(); prevBtn = null; } if (nextBtn != null) { nextBtn.Click -= NextBtn_Click; nextBtn.Dispose(); nextBtn = null; } if (indicators != null) { indicators.Dispose(); indicators = null; } if (viewPager != null) { viewPager.PageSelected -= ViewPager_PageSelected; viewPager.PageScrollStateChanged -= ViewPager_PageScrollStateChanged; if (viewPager.Adapter != null) { viewPager.Adapter.Dispose(); } viewPager.Dispose(); viewPager = null; } if (Element != null) { Element.SizeChanged -= Element_SizeChanged; if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged -= ItemsSource_CollectionChanged; } } _disposed = true; } try { base.Dispose(disposing); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
/// <summary> /// /// </summary> private void UpdateContent() { if (RefreshView.Content == null) { return; } if (_packed != null) { RemoveView(_packed.ViewGroup); } _packed = Platform.CreateRenderer(RefreshView.Content); try { RefreshView.Content.SetValue(RendererProperty, _packed); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to sent renderer property, maybe an issue: " + ex); } PrepareHint(); PrepareSwipeObserver(); _packed.ViewGroup.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); Android.Widget.LinearLayout baseLinearLayout = new Android.Widget.LinearLayout(this.Context); baseLinearLayout.Orientation = Orientation.Vertical; baseLinearLayout.AddView(_hintLayout); baseLinearLayout.AddView(_packed.ViewGroup); AddView(baseLinearLayout, LayoutParams.MatchParent); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } var layout = new Android.Widget.LinearLayout(this.Context); layout.SetBackgroundColor(Android.Graphics.Color.Black); layout.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); VideoView mVideoView = new VideoView(Context); mVideoView.SetVideoPath("android.resource://" + this.Context.PackageName + "/" + Resource.Drawable.IntroGladys); layout.SetVerticalGravity(GravityFlags.Center); layout.SetHorizontalGravity(GravityFlags.Center); mVideoView.LayoutParameters = new LayoutParams(LayoutParams.FillParent, LayoutParams.FillParent); layout.AddView(mVideoView); mVideoView.Start(); _view = layout; AddView(_view); }
protected override void OnElementChanged(ElementChangedEventArgs <ReceiverView> e) { base.OnElementChanged(e); if (Control == null) { var layoutparams = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _streamImage = new ImageView(Context); _streamImage.LayoutParameters = layoutparams; var mainView = new Android.Widget.LinearLayout(this.Context); mainView.AddView(_streamImage); SetNativeControl(mainView); } if (Control == null || Element == null) { return; } if (e.OldElement != null) { //Element being deleted } if (e.NewElement != null) { //Element being created } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { base.OnElementChanged(e); if (e.OldElement != null || e.NewElement == null) { return; } var stackLayout = (VideoLayout)this.Element; var mainActivity = Forms.Context as MainActivity; var publiserLayout = new Android.Widget.LinearLayout(mainActivity) { Orientation = Orientation.Vertical, LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 200) }; var subscriberLayout = new Android.Widget.LinearLayout(mainActivity) { Orientation = Orientation.Vertical, LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 200) }; var loadingProggressBar = new Android.Widget.ProgressBar(mainActivity); loadingProggressBar.Visibility = ViewStates.Gone; subscriberLayout.AddView(loadingProggressBar); stackLayout.Children.Add(publiserLayout); stackLayout.Children.Add(subscriberLayout); mainActivity.SetLayouts(publiserLayout, subscriberLayout, loadingProggressBar); }
void SetArrows() { if (Element.ShowArrows) { if (prevBtn == null) { prevBtn = nativeView.FindViewById <AWidget.LinearLayout>(Resource.Id.prev); prevBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); prevBtn.Visibility = Element.Position == 0 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; prevBtn.Alpha = Element.ArrowsTransparency; var prevArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.prevArrow); prevArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); prevBtn.Click += delegate { if (Element.Position > 0) { Element.Position = Element.Position - 1; } }; } if (nextBtn == null) { nextBtn = nativeView.FindViewById <AWidget.LinearLayout>(Resource.Id.next); nextBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); nextBtn.Visibility = Element.Position == Element.ItemsSource.GetCount() - 1 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; nextBtn.Alpha = Element.ArrowsTransparency; var nextArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.nextArrow); nextArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); nextBtn.Click += delegate { if (Element.Position < Element.ItemsSource.GetCount() - 1) { Element.Position = Element.Position + 1; } }; } } else { if (prevBtn != null) { prevBtn.Visibility = AViews.ViewStates.Gone; } if (nextBtn != null) { nextBtn.Visibility = AViews.ViewStates.Gone; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Camera); sessionPath = File.CreateDirectory(GetSessionName(), 0); layout = FindViewById <Android.Widget.LinearLayout>(Resource.Id.layoutBase); if (surfaceHolder == null) { SetSurfaceHolder(false); } SetOnLayoutClickEvent(); SetOnLayoutLongClickEvent(); SetOnTouchLayoutEvents(); }
void UpdateTitleViewLayout(Page lastPage, Android.Widget.LinearLayout titleViewLayout, AppCompatTextView titleTextView, AppCompatTextView subTitleTextView, Android.Graphics.Drawables.Drawable defaultBackground) { UpdateTitleViewLayoutAlignment(titleViewLayout, titleTextView, subTitleTextView, CustomNavigationPage.GetTitlePosition(lastPage)); if (!string.IsNullOrEmpty(CustomNavigationPage.GetTitleBackground(lastPage))) { UpdateTitleViewLayoutBackground(titleViewLayout, CustomNavigationPage.GetTitleBackground(lastPage), defaultBackground); } else { _titleViewLayout?.SetBackground(CreateShape(ShapeType.Rectangle, (int)CustomNavigationPage.GetTitleBorderWidth(lastPage), (int)CustomNavigationPage.GetTitleBorderCornerRadius(lastPage), CustomNavigationPage.GetTitleFillColor(lastPage), CustomNavigationPage.GetTitleBorderColor(lastPage))); } UpdateTitleViewLayoutMargin(titleViewLayout, CustomNavigationPage.GetTitleMargin(lastPage)); UpdateTitleViewLayoutPadding(titleViewLayout, CustomNavigationPage.GetTitlePadding(lastPage)); }
public override av.View GetView(int position, av.View convertView, av.ViewGroup parent) { var colCount = Handler.columns.Count; var row = position; var view = convertView as aw.LinearLayout; var item = Handler.collection.ElementAt(row); if (view == null || view.ChildCount != Handler.columns.Count) { view = new aw.LinearLayout(aa.Application.Context); for (int i = 0; i < Handler.columns.Count; i++) { var column = Handler.columns.ElementAt(i); var cell = column.DataCell; av.View colView = null; if (cell != null) { var cellHandler = cell.Handler as ICellHandler; if (cellHandler != null) { colView = cellHandler.CreateView(null, item); } } view.AddView(colView ?? new av.View(aa.Application.Context), new aw.LinearLayout.LayoutParams(av.ViewGroup.LayoutParams.MatchParent, av.ViewGroup.LayoutParams.MatchParent, 1f)); } } else { for (int i = 0; i < Handler.columns.Count; i++) { var column = Handler.columns.ElementAt(i); var cell = column.DataCell; if (cell != null) { var cellHandler = cell.Handler as ICellHandler; if (cellHandler != null) { var colView = view.GetChildAt(i); cellHandler.CreateView(colView, item); } } } } return(view); }
void SetArrows() { if (Element.ShowArrows) { if (prevBtn == null) { prevBtn = nativeView.FindViewById <AWidget.LinearLayout>(Resource.Id.prev); prevBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); prevBtn.Visibility = Element.Position == 0 || Element.ItemsSource.GetCount() == 0 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; prevBtn.Alpha = Element.ArrowsTransparency; prevBtn.SetMinimumWidth((int)Element.ArrowsWidth); prevBtn.SetMinimumHeight((int)Element.ArrowsHeight); var prevArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.prevArrow); prevArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); prevBtn.Click += PrevBtn_Click; } if (nextBtn == null) { nextBtn = nativeView.FindViewById <AWidget.LinearLayout>(Resource.Id.next); nextBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); nextBtn.Visibility = Element.Position == Element.ItemsSource.GetCount() - 1 || Element.ItemsSource.GetCount() == 0 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; nextBtn.Alpha = Element.ArrowsTransparency; var nextArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.nextArrow); nextArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); nextBtn.Click += NextBtn_Click; } } else { if (prevBtn == null || nextBtn == null) { return; } prevBtn.Visibility = AViews.ViewStates.Gone; nextBtn.Visibility = AViews.ViewStates.Gone; } }
private void FindView(View view) { _titleTextView = view.FindViewById <Android.Support.V7.Widget.AppCompatTextView>(Resource.Id.fingerprint_dialog_title_default); if (string.IsNullOrWhiteSpace(_dialogConfiguration.DialogTitle)) { _titleTextView.Visibility = ViewStates.Gone; } else { _titleTextView.Text = _dialogConfiguration.DialogTitle; } _descTextView = view.FindViewById <Android.Support.V7.Widget.AppCompatTextView>(Resource.Id.fingerprint_dialog_message_default); if (string.IsNullOrWhiteSpace(_dialogConfiguration.DialogDescription)) { _descTextView.Visibility = ViewStates.Gone; } else { _descTextView.Text = _dialogConfiguration.DialogDescription; } _fingerprintIconView = view.FindViewById <Android.Widget.ImageView>(Resource.Id.fingerprint_icon); _statusTextView = view.FindViewById <Android.Support.V7.Widget.AppCompatTextView>(Resource.Id.fingerprint_dialog_status_default); _statusTextView.Text = _dialogConfiguration.FingerprintDialogConfiguration.FingerprintHintString; _alternativeActionButton = view.FindViewById <Android.Support.V7.Widget.AppCompatButton>(Resource.Id.fingerprint_dialog_alternative_default); _alternativeActionButton.Text = _dialogConfiguration.AlternativeActionMessage; _alternativeActionButton.Click += (s, e) => { //_fingerprintCancellationSignal.Cancel(); DismissDialog(); _dialogConfiguration.AlternativeAction?.Invoke(); }; _fingerprintStatusPanelLinearLayout = view.FindViewById <Android.Widget.LinearLayout>(Resource.Id.fingerprint_status_panel_default); }
private Android.Views.View CreateLayout(Context context) { Android.Widget.RelativeLayout layout = new Android.Widget.RelativeLayout(context); var layoutParam = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); layout.SetPadding(30, 15, 30, 15); layout.LayoutParameters = layoutParam; //main layout Android.Widget.LinearLayout mainView = new Android.Widget.LinearLayout(context); var paramLayout = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); mainView.Orientation = Orientation.Vertical; paramLayout.AddRule(NativeCell.IsIncoming ? LayoutRules.AlignParentLeft : LayoutRules.AlignParentRight); paramLayout.SetMargins(NativeCell.IsIncoming ? 0 : 50, 0, NativeCell.IsIncoming ? 50 : 0, 0); mainView.SetPadding(30, 30, 30, 30); mainView.LayoutParameters = paramLayout; //set drawable GradientDrawable shape = new GradientDrawable(); shape.SetCornerRadius(NativeCell.CornerRadius * 2); shape.SetColor(NativeCell.IsIncoming ? NativeCell.IncomingColor.ToAndroid() : NativeCell.OutgoingColor.ToAndroid()); mainView.Background = shape; // name text NameText = new TextView(context); NameText.SetTextColor(NativeCell.NameFontColor.ToAndroid()); NameText.TextSize = NativeCell.NameFontSize; NameText.Text = NativeCell.Name; NameText.Id = Name_Text_Id; var paramNameText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); NameText.LayoutParameters = paramNameText; //message text MessageText = new TextView(context); MessageText.SetTextColor(NativeCell.TextFontColor.ToAndroid()); MessageText.Text = NativeCell.MessageBody; MessageText.TextSize = NativeCell.TextFontSize; MessageText.Id = Message_Text_Id; var paramMessageText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); MessageText.LayoutParameters = paramMessageText; // status layout LinearLayout linearLayout = new LinearLayout(context); linearLayout.Orientation = Orientation.Horizontal; var paramlinearLayout = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramlinearLayout.Gravity = Android.Views.GravityFlags.Right; linearLayout.SetGravity(Android.Views.GravityFlags.Right); linearLayout.LayoutParameters = paramlinearLayout; // status text StatusText = new TextView(context); StatusText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); StatusText.Text = StatusHelper.GetStatusString(NativeCell.Status); StatusText.Id = Status_Text_Id; StatusText.TextSize = NativeCell.InfoFontSize; StatusText.SetPadding(0, 0, 10, 0); StatusText.Gravity = Android.Views.GravityFlags.Left; var paramStatusText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramStatusText.Gravity = Android.Views.GravityFlags.Left; StatusText.LayoutParameters = paramStatusText; if (!NativeCell.IsIncoming) { linearLayout.AddView(StatusText); } // date text DateText = new TextView(context); DateText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); DateText.Text = NativeCell.Date; DateText.SetLines(1); DateText.TextSize = NativeCell.InfoFontSize; DateText.SetMinWidth(LayoutParams.WrapContent); DateText.Id = Date_Text_Id; var paramDateText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); DateText.LayoutParameters = paramDateText; linearLayout.AddView(DateText); if (!string.IsNullOrWhiteSpace(NameText.Text) && NativeCell.IsIncoming) { mainView.AddView(NameText); } mainView.AddView(MessageText); mainView.AddView(linearLayout); layout.AddView(mainView); return(layout); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var ignored = base.OnCreateView(inflater, container, savedInstanceState); view = inflater.Inflate(Resource.Layout.content_dashboard, null); settings = Settings.Instance; try { #region Popup Dialog var remoteViews = new RemoteViews(context.PackageName, Resource.Layout.layout_popup); var layoutInflater = LayoutInflater.FromContext(context); var viewPopup = layoutInflater.Inflate(remoteViews.LayoutId, null); popupDialog = new Dialog(Platform.CurrentActivity); popupDialog.SetContentView(viewPopup); popupDialog.Window.SetSoftInputMode(SoftInput.AdjustResize); var textView = viewPopup.FindViewById <TextView>(Resource.Id.textView1); buttonOkPopup = viewPopup.FindViewById <Button>(Resource.Id.button1); buttonOkPopup.Click += ButtonOk_Popup_Click; buttonCancelPopup = viewPopup.FindViewById <Button>(Resource.Id.button2); buttonCancelPopup.Click += ButtonCancel_Popup_Click; #endregion buttonOk = view.FindViewById <MaterialButton>(Resource.Id.materialButton1); buttonOk.Click += async delegate(object sender, EventArgs e) { await ButtonOk_Click(sender, e); }; buttonCancel = view.FindViewById <MaterialButton>(Resource.Id.materialButton2); buttonCancel.Click += async delegate(object sender, EventArgs e) { await ButtonCancel_Click(sender, e); }; circularProgress = view.FindViewById <CircularProgressIndicator>(Resource.Id.circular_progress); circularProgressCpu = view.FindViewById <CircularProgressIndicator>(Resource.Id.circular_progress_cpu); switchTest = view.FindViewById <Android.Widget.Switch>(Resource.Id.switch1); linearLayout = view.FindViewById <Android.Widget.LinearLayout>(Resource.Id.bt_linearlayout); if (settings.ProVersion == false) { switchTest.Touch += SwitchTest_Touch; } else { switchTest.CheckedChange += SwitchTest_CheckedChange; } Task.Run(() => ProgressIndicatorUpdate()); cancellationToken = new CancellationTokenSource(); return(view); } catch (System.Exception ex) { #region Logging LogRuntimeAttribute.InLogFiles(typeof(DashboardFragment), ex); #endregion return(view); } finally { } }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_entrydetail); OverridePendingTransition(Resource.Animation.zoom_enter, Resource.Animation.zoom_exit); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar_addItem); SetSupportActionBar(toolbar); this.SupportActionBar.Title = AppResources.PageTitleItemDetail; this.SupportActionBar.SetDisplayHomeAsUpEnabled(true); listEntryEdit = FindViewById <Android.Widget.LinearLayout>(Resource.Id.contentView); var e = Navigate.selectedEntry; vm = new EntryDetailVM(e); var view = listEntryEdit; #if SCREENSHOT Navigate.screenshotScreen = this; #endif var binding = DataContext <EntryDetailVM> .FromView(view); binding.VM = vm; listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_edit_entry_top, null)); AmountCollectionVM avm = vm.AmountCollectionVM; ServingSizeAdapter a = new ServingSizeAdapter(this, avm); // serving sizes listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_serving, null)); var ServingExtraMenu = FindViewById(Resource.Id.addItemDialog); ServingExtraMenu.Click += (object sender, EventArgs e2) => { ShowServingsExtraMenu(); }; var servingsizes = FindViewById <Android.Widget.LinearLayout>(Resource.Id.servingSizes); int cnt = Math.Min(a.Count, MAXSERVINGSFIRST); for (int i = 0; i < cnt; i++) { servingsizes.AddView(a.GetView2(i, null, servingsizes)); } View showmore = null; if (a.Count > MAXSERVINGSFIRST) { showmore = View.Inflate(this, Resource.Layout.item_servings_show_more, null); listEntryEdit.AddView(showmore); var button = FindViewById <TextView>(Resource.Id.button_showmoreoptions); button.Click += (sender, e2) => { servingsizes.RemoveAllViews(); for (int i = 0; i < a.Count; i++) { servingsizes.AddView(a.GetView2(i, null, servingsizes)); } showmore.Visibility = ViewStates.Invisible; }; } // add serving szie avm.Amounts.CollectionChanged += (sender, e3) => { if (showmore != null) { showmore.Visibility = ViewStates.Invisible; } servingsizes.RemoveAllViews(); for (int i = 0; i < a.Count; i++) { servingsizes.AddView(a.GetView2(i, null, servingsizes)); } }; PropertyAdapter p = new PropertyAdapter(this, vm); // properties listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_nutrition, null)); var properties = FindViewById <Android.Widget.LinearLayout>(Resource.Id.properties); for (int i = 0; i < p.Count; i++) { properties.AddView(p.GetView2(i, null, properties)); } Action action = () => { servingsizes.RemoveAllViewsInLayout(); for (int i = 0; i < a.Count; i++) { servingsizes.AddView(a.GetView(i, null, servingsizes)); } }; a.RegisterDataSetObserver(new DSO(action)); if (binding.Bindings.Count == 0) { binding.Add(Resource.Id.addInputDialog, x => x.Text); binding.Add(Resource.Id.opt_pergrams, x => x.Is100Gram); binding.Add(Resource.Id.opt_percup, x => x.IsNot100Gram); binding.Add(Resource.Id.opt_percup, x => x.SelectedServingText); } addInputDialog = listEntryEdit.FindViewById <EditText>(Resource.Id.addInputDialog); if (Navigate.selectedEntry.Item.IsNewItem) { addInputDialog.TextChanged += AddInputDialogTextChanged; } else { EditMode = true; } OriginalText = Navigate.selectedItem.Text; #if DEBUG AndroidDebug.SetViewBorders(listEntryEdit); #endif }