public MvxRecyclerView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own ItemTemplateSelector if (adapter == null) { return; } var currentLayoutManager = GetLayoutManager(); if (currentLayoutManager == null) #pragma warning disable CA2000 // Dispose objects before losing scope { SetLayoutManager(new MvxGuardedLinearLayoutManager(context)); } #pragma warning restore CA2000 // Dispose objects before losing scope var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var itemTemplateSelector = MvxRecyclerViewAttributeExtensions.BuildItemTemplateSelector(context, attrs, itemTemplateId); adapter.ItemTemplateSelector = itemTemplateSelector; Adapter = adapter; if (itemTemplateId == 0) { itemTemplateId = global::Android.Resource.Layout.SimpleListItem1; } if (itemTemplateSelector.GetType() == typeof(MvxDefaultTemplateSelector)) { ItemTemplateId = itemTemplateId; } }
public MvxRecyclerView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own ItemTemplateSelector if (adapter == null) { return; } if (base.GetLayoutManager() == null) { SetLayoutManager(new LinearLayoutManager(context)); } var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var itemTemplateSelector = MvxRecyclerViewAttributeExtensions.BuildItemTemplateSelector(context, attrs); adapter.ItemTemplateSelector = itemTemplateSelector; Adapter = adapter; if (itemTemplateSelector.GetType() == typeof(MvxDefaultTemplateSelector)) { ItemTemplateId = itemTemplateId; } HidesHeaderIfEmpty = MvxRecyclerViewAttributeExtensions.IsHidesHeaderIfEmptyEnabled(context, attrs); HidesFooterIfEmpty = MvxRecyclerViewAttributeExtensions.IsHidesFooterIfEmptyEnabled(context, attrs); if (MvxRecyclerViewAttributeExtensions.IsGroupingSupported(context, attrs)) { GroupedDataConverter = MvxRecyclerViewAttributeExtensions.BuildMvxGroupedDataConverter(context, attrs); } }
public MvxRecyclerView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own ItemTemplateSelector if (adapter == null) { return; } var currentLayoutManager = base.GetLayoutManager(); // Love you Android // https://code.google.com/p/android/issues/detail?id=77846#c10 // Don't believe those bastards, it's not fixed - workaround hack hack hack if (currentLayoutManager == null) { SetLayoutManager(new MvxGuardedLinearLayoutManager(context)); } var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var itemTemplateSelector = MvxRecyclerViewAttributeExtensions.BuildItemTemplateSelector(context, attrs); adapter.ItemTemplateSelector = itemTemplateSelector; Adapter = adapter; if (itemTemplateSelector.GetType() == typeof(MvxDefaultTemplateSelector)) { ItemTemplateId = itemTemplateId; } }
public MvxHorizontalGridView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own itemTemplateId if (adapter == null) { return; } var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; var typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.MvxHorizontalGridView); try { FocusFirstChildOnLaidOut = typedArray.GetBoolean(Resource.Styleable.MvxHorizontalGridView_FocusFirstChildOnLaidOut, false); if (FocusFirstChildOnLaidOut) { SetOnChildLaidOutListener(new MvxFocusFirstChildOnChildLaidOutListener()); } } finally { typedArray.Recycle(); } // We need this listener to get information about the currently _selected_ item // Overriding setter of base.SelectedPosition is not enough! OnChildViewHolderSelectedListener = new MvxOnChildViewHolderSelectedListener(); SetOnChildViewHolderSelectedListener(OnChildViewHolderSelectedListener); }
public HeaderListView(Context context, IAttributeSet attrs, HeaderAdapter adapter) : base(context, attrs, adapter) { if (attrs != null) { HeaderTemplateId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, Resource.Styleable.HeaderListView, Resource.Styleable.HeaderListView_HeaderTemplate); } }
public BindableViewPager(Context context, IAttributeSet attrs, MvxBindablePagerAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; }
public MvxAppCompatAutoCompleteTextView(Context context, IAttributeSet attrs, MvxFilteringAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; ItemClick += OnItemClick; }
public MvxSectionedRecyclerView(Context context, IAttributeSet attrs) : base(context, attrs) { //create the adapter with parameters from attributes var headerTemplateId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance.ExpandableListViewStylableGroupId, MvxAndroidBindingResource.Instance.GroupItemTemplateId); IMvxRecyclerAdapter adapter = new MvxSectionedRecyclerAdapter(false, headerTemplateId); Adapter = adapter; }
public MvxSpinnerIndexer(Context context, IAttributeSet attrs, IMvxAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var dropDownItemTemplateId = MvxAttributeHelpers.ReadDropDownListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; adapter.DropDownItemTemplateId = dropDownItemTemplateId; Adapter = adapter; SetupHandleItemSelected(); }
public BindableGroupListView(Context context, IAttributeSet attrs, BindableGroupListAdapter adapter) : base(context, attrs, adapter) { var groupTemplateId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance .ListViewStylableGroupId, AndroidBindingResource.Instance .BindableListGroupItemTemplateId); adapter.GroupTemplateId = groupTemplateId; }
public BindableViewPager(Context context, IAttributeSet attrs, MvxBindablePagerAdapter adapter) : base(context, attrs) { this._initialIndex = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "selectedIndex", -1); this.OffscreenPageLimit = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "offscreenPageLimit", 1); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; }
public MvxAppCompatSpinner(Context context, IAttributeSet attrs, IMvxAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var dropDownItemTemplateId = MvxAttributeHelpers.ReadDropDownListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; adapter.DropDownItemTemplateId = dropDownItemTemplateId; Adapter = adapter; ItemSelected += OnItemSelected; }
public RecurringListView(Context context, IAttributeSet attrs, RecurringAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance.ListViewStylableGroupId, MvxAndroidBindingResource.Instance.ListItemTemplateId); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; Adapter.CustomItemClick = this; SetupItemClickListeners(); }
void InitFooters(Context context, IAttributeSet attrs) { var footerId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance.ListViewStylableGroupId, AndroidBindingResource.Instance.MvxListViewWithHeader_FooterLayout); if (footerId != 0) { var bindingContext = MvxAndroidBindingContextHelpers.Current(); var view = bindingContext.BindingInflate(footerId, null); AddFooterView(view, null, false); } }
public MvxAppCompatRadioGroup(Context context, IAttributeSet attrs, IMvxAdapterWithChangedEvent adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); if (adapter != null) { this.Adapter = adapter; this.Adapter.ItemTemplateId = itemTemplateId; } this.ChildViewAdded += this.OnChildViewAdded; this.ChildViewRemoved += this.OnChildViewRemoved; }
public MvxAppCompatListView(Context context, IAttributeSet attrs, IMvxAdapter adapter) : base(context, attrs) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own itemTemplateId if (adapter == null) { return; } var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; this.Adapter = adapter; }
public MvxRecyclerView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own itemTemplateId if (adapter == null) { return; } SetLayoutManager(new LinearLayoutManager(context)); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; }
public MvxAppCompatAutoCompleteTextView(Context context, IAttributeSet attrs, MvxFilteringAdapter adapter) : base(context, attrs) { var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); if (itemTemplateId > 0) { adapter.ItemTemplateId = itemTemplateId; } Adapter = adapter; // note - we shouldn't realy need both of these... but we do ItemClick += OnItemClick; ItemSelected += OnItemSelected; }
public MvxListViewWithHeader(Context context, IAttributeSet attrs) : base(context, attrs, null) { IMvxAdapter adapter = new MvxAdapter(context); ApplyAttributes(context, attrs); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; var headers = GetHeaders(); var footers = GetFooters(); IMvxAdapter headerAdapter = new HeaderMvxAdapter(headers, footers, adapter); Adapter = headerAdapter; }
public MvxListViewWithHeader(Context context, IAttributeSet attrs) : base(context, attrs, null) { var headerId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance.ListViewStylableGroupId, AndroidBindingResource.Instance.MvxListViewWithHeader_HeaderLayout); var footerId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance.ListViewStylableGroupId, AndroidBindingResource.Instance.MvxListViewWithHeader_FooterLayout); var headers = GetFixedViewInfos(headerId); var footers = GetFixedViewInfos(footerId); var adapter = new MvxAdapter(context); adapter.ItemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var headerAdapter = new HeaderMvxAdapter(headers, footers, adapter); Adapter = headerAdapter; }
public BindableExpandableListView(Context context, IAttributeSet attrs) : base(context, attrs) { var expandableAdapter = new BindableExpandableListAdapter(context); var groupTemplateId = MvxAttributeHelpers.ReadAttributeValue(context, attrs, MvxAndroidBindingResource.Instance .ListViewStylableGroupId, AndroidBindingResource.Instance .BindableListGroupItemTemplateId); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); expandableAdapter.GroupTemplateId = groupTemplateId; expandableAdapter.ItemTemplateId = itemTemplateId; SetAdapter(expandableAdapter); InitHeaders(context, attrs); InitFooters(context, attrs); }
public MvxRecyclerView(Context context, IAttributeSet attrs, int defStyle, IMvxRecyclerAdapter adapter) : base(context, attrs, defStyle) { // Note: Any calling derived class passing a null adapter is responsible for setting // it's own ItemTemplateSelector if (adapter == null) { return; } SetLayoutManager(new LinearLayoutManager(context)); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); var itemTemplateSelector = MvxRecyclerViewAttributeExtensions.BuildItemTemplateSelector(context, attrs); adapter.ItemTemplateSelector = itemTemplateSelector; Adapter = adapter; if (itemTemplateSelector.GetType() == typeof(MvxDefaultTemplateSelector)) { ItemTemplateId = itemTemplateId; } }
public ARViewPager(Context context, IAttributeSet attrs) : base(context, attrs) { ItemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); }
private void ApplyAttributes(Context c, IAttributeSet attrs) { _headerId = MvxAttributeHelpers.ReadAttributeValue(c, attrs, Resource.Styleable.ARListView, Resource.Styleable.ARListView_MvxHeaderTemplate); _footerId = MvxAttributeHelpers.ReadAttributeValue(c, attrs, Resource.Styleable.ARListView, Resource.Styleable.ARListView_MvxFooterTemplate); }
static MvxAdvancedRecyclerViewAttributes ReadRecyclerViewItemTemplateSelectorAttributes(Context context, IAttributeSet attrs) { TryInitializeBindingResourcePaths(); TypedArray typedArray = null; string templateSelectorClassName = string.Empty; string groupedDataConverterClassName = string.Empty; string groupExpandControllerClassName = string.Empty; string swipeableTemplateClassName = string.Empty; string uniqueItemIdProviderClassName = string.Empty; string groupSwipeableTemplateClassName = string.Empty; string childSwipeableTemplateClassName = string.Empty; int headerLayoutId = 0; int footerLayoutId = 0; try { typedArray = context.ObtainStyledAttributes(attrs, MvxRecyclerViewGroupId); int numberOfStyles = typedArray.IndexCount; for (int i = 0; i < numberOfStyles; ++i) { var attributeId = typedArray.GetIndex(i); if (attributeId == MvxRecyclerViewGroupExpandController) { groupExpandControllerClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewItemTemplateSelector) { templateSelectorClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewHeaderLayoutId) { headerLayoutId = typedArray.GetResourceId(attributeId, 0); } if (attributeId == MvxRecyclerViewFooterLayoutId) { footerLayoutId = typedArray.GetResourceId(attributeId, 0); } if (attributeId == MvxRecyclerViewGroupedDataConverter) { groupedDataConverterClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewSwipeableTemplate) { swipeableTemplateClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewUniqueItemIdProvider) { uniqueItemIdProviderClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewGroupSwipeableTemplate) { groupSwipeableTemplateClassName = typedArray.GetString(attributeId); } if (attributeId == MvxRecyclerViewChildSwipeableTemplate) { childSwipeableTemplateClassName = typedArray.GetString(attributeId); } } } finally { typedArray?.Recycle(); } if (string.IsNullOrEmpty(templateSelectorClassName)) { templateSelectorClassName = typeof(MvxDefaultTemplateSelector).FullName; } if (string.IsNullOrEmpty(groupExpandControllerClassName)) { groupExpandControllerClassName = typeof(DefaultMvxGroupExpandController).FullName; } return(new MvxAdvancedRecyclerViewAttributes() { TemplateSelectorClassName = templateSelectorClassName, ItemTemplateLayoutId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs), FooterLayoutId = footerLayoutId, HeaderLayoutId = headerLayoutId, GroupedDataConverterClassName = groupedDataConverterClassName, GroupExpandControllerClassName = groupExpandControllerClassName, SwipeableTemplateClassName = swipeableTemplateClassName, UniqueItemIdProviderClassName = uniqueItemIdProviderClassName, GroupSwipeableTemplateClassName = groupSwipeableTemplateClassName, ChildSwipeableTemplateClassName = childSwipeableTemplateClassName }); }
public static int ReadTemplateId(Context context, IAttributeSet attrs) { return(MvxAttributeHelpers.ReadAttributeValue(context, attrs, Resource.Styleable.ARLinearLayout, Resource.Styleable.ARLinearLayout_MvxItemTemplate)); }