Closed thefex closed 8 years ago
Commit: https://github.com/thefex/MvvmCross-AndroidSupport/commit/c4ee026a4e3105cffd5c06453dc7f44ddff00a0a implements functionallity. Commit: https://github.com/thefex/MvvmCross-AndroidSupport/commit/79dc3fcbffc4344824d5d5ea5db8045ab012b104 implements scratch of Sample.
I don't make a pull request yet as sample fragment view needs to be improved but ItemTemplateSelectors works with backward compatibility to "MvxItemTemplate" attribute.
Take a look at that: https://github.com/thefex/MvvmCross-AndroidSupport/blob/79dc3fcbffc4344824d5d5ea5db8045ab012b104/Samples/Example.Droid/Common/TemplateSelectors/MultiItemTemplateModelTemplateSelector.cs https://github.com/thefex/MvvmCross-AndroidSupport/blob/79dc3fcbffc4344824d5d5ea5db8045ab012b104/Samples/Example.Droid/Resources/values/Strings.xml https://github.com/thefex/MvvmCross-AndroidSupport/blob/79dc3fcbffc4344824d5d5ea5db8045ab012b104/Samples/Example.Droid/Resources/layout/fragment_recyclerview_multiitemtemplate.axml
Isn't that just pretty that we can get multiitem template without creating custom adapter - just by implementing one interface and adding MvxItemTemplateSelector attribute to MvxRecyclerView xml:
<MvxRecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxItemTemplateSelector="@string/recyclerview_multiitem_templateselector"
local:MvxBind="ItemsSource Items; ItemClick ItemSelected" />
Where MvxItemTemplateSelector is "namespace.classname, AssemblyName" ;)
Great effort! I've commented your code with some ideas but overall, I believe you should tackle usage. "namespace.classname, AssemblyName" is a tuff thing to remember specially since this is only required here, as I stated in the commit comment for this to be useful you need to follow MvvmCross overall pattern of dev by naming convention. Devs should then implement classes suffixed with TemplateSelector
and use it like:
local:MvxItemTemplateSelector="MultiItemTemplateModel"
@vvolkgang I will implement MvvmCross conventions as you have suggested (and keep current namespace.classname, Assembly working too). I think I haven't done that yet because that requires a small changes in MvvmCross main library. By the way: strings are not used only for UI - check for example: Design Library behaviors.
cc: @martijn00 merged master into PR :-) cc: @vvolkgang at this moment Mvx Abbrevations are not supported - but that's gonna change... soon ;-)
MvxRecyclerView should expose somethnig similiar to DataTemplateSelector popular on Windows Phone controls like ListView.
Will work on that tomorrow.