public void BindDataToView(Context context, int position, Card item, bool editable, bool useParentPosition) { Card = item; //set height var width = context.Resources.DisplayMetrics.WidthPixels - 20; var height = (int)GetCalculatedHeight(width); ItemView.LayoutParameters = new RelativeLayout.LayoutParams(width, height); if (item == null) { return; } NameTextView.TextChanged -= NameTextView_TextChanged; NameTextView.Text = item.Name.Equals(Strings.Basic.new_card, StringComparison.InvariantCultureIgnoreCase) ? null : item.Name; NameTextView.Hint = Strings.Basic.new_card; NameTextView.TextChanged += NameTextView_TextChanged; NameTextView.Enabled = editable; FlipTextView.Click -= FlipTextView_Click; FlipTextView.Click += FlipTextView_Click; //wire up swipe gestures var touchListner = new OnSwipeTouchListener(context, ToggleViews, ToggleViews, position); ItemView.SetOnTouchListener(touchListner); var pos = useParentPosition ? position : 0; FrontView.BindDataToView(item, editable, pos); RearView.BindDataToView(item, editable, pos); // ApplyFlippedStateToView(); }
public void BindDataToView(Context context, int position, Card item, bool editable, bool useParentPosition) { Card = item; //set height var width = context.Resources.DisplayMetrics.WidthPixels - 20; var height = (int)GetCalculatedHeight(width); ItemView.LayoutParameters = new RelativeLayout.LayoutParams(width, height); if (item == null) { return; } NameTextView.TextChanged -= NameTextView_TextChanged; NameTextView.Text = item.Name.Equals(Strings.Basic.new_card, StringComparison.InvariantCultureIgnoreCase) ? null : item.Name; NameTextView.Hint = Strings.Basic.new_card; NameTextView.TextChanged += NameTextView_TextChanged; NameTextView.Enabled = editable; FlipTextView.Click -= FlipTextView_Click; FlipTextView.Click += FlipTextView_Click; //wire up swipe gestures var touchListner = new OnSwipeTouchListener(context, ToggleViews, ToggleViews, position); ItemView.SetOnTouchListener(touchListner); var pos = useParentPosition ? position : 0; FrontView.BindDataToView(item, editable, pos); RearView.BindDataToView(item, editable, pos); //LeftTextView.Text = item.Title; ////RightTextView.Text = item.Value; //if (ItemView.HasOnClickListeners) return; //ItemView.Click += (sender, e) => //{ // var intent = new Intent(SettingsShared.ItemClickedBroadcastReceiverKey); // intent.PutExtra(SettingsShared.ItemClickedBroadcastReceiverKeyPosition, position); // context.SendBroadcast(intent); //}; ApplyFlippedStateToView(); }