Why doesn't RecyclerView have onItemSelectListener? - android-5.0-lollipop

I have been working on RecyclerView and CardView recently provided by Android L.
Both of them are quite impressive but I got disappointed when I wanted to use onItemSelectListener with RecyclerView and couldn't find such method.
Help needed.

Related

MvvmCross 4 support for UWP, AppShell missing Frame

I have created a new solution for my MvvmCross app that supported Windows Store and I want to support UWP on Windows 10. I have moved over the PCL successfully, but I am having problems getting the basic UWP app working using a sample provided by MS (NavigationMenu) which uses the SplitView and the AppShell pattern they are recommending for the new navigation/command model. I referenced a helpful blog post (http://stephanvs.com/implementing-a-multi-region-presenter-for-windows-10-uwp-and-mvvmcross/), which gave me some guidance on how to integrate mvvmcross into the AppShell, but startup is failing because the AppShell does not have a valid Frame defined. Frame is a read-only property, and I have been unable to see where this is being set up.
I am using the standard AppShell implementation from the NavigationMenu with the following changes as recommended in the blog post:
public sealed partial class AppShell : MvxWindowsPage // was Page
public Frame AppFrame { get { return this.Frame; } } // was this.frame
Except for code after the error, there are no differences in the setup. In looking at the MvxWindowsPage implementation, there doesn't seem to be anything special as it still invokes the Page initialization. Is there something obvious I am missing?
So the link to the blogpost is correct, in other words you'll need to use MultiRegions from MvvmCross to get this working.
But what the blogpost doesn't show is a complete working version...
I've added one on my github here:
https://github.com/Depechie/MvvmCrossUWPSplitView
Some pointers to take away, like I said in the comments.
Your view where the SplitView will be present, needs to have a property to return a valid Frame to look for while injecting new views. This can be returned like this return (Frame)this.WrappedFrame.UnderlyingControl; found in the code here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml.cs#L13
Than all views you want to load up in the SplitView will need to reference to the region you defined in that SplitView, in my case I named it FrameContent as seen here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml#L48
So use that name for the region attribute in all to be loaded views like so [MvxRegion("FrameContent")] example here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/SecondView.xaml.cs#L7
I see what you're trying to do with the SplitView template that's provided by Microsoft. There is however a mismatch between things managed by MvvmCross and UWP.
By default MvvmCross maps ViewModels to Views based on naming conventions. What you are trying to do is use a view 'AppShell' (which is derived of Windows.UI.Xaml.Controls.Page) that doesn't adhere to the default MvvmCross convention.
The way I choose to implement this SplitView (Hamburger) functionality is by deleting the provided AppShell class entirely. I then created a new view named HomeView (since I have a ViewModel with the name HomeViewModel) and added the SplitView control there as described in the post you mentioned above.
For completeness I've created a Gist with the App.xaml.cs and HomeView.xaml as you requested. You can find them here: https://gist.github.com/Stephanvs/7bb2cdc9dbf15cb7a90f

JsonLocalisation and WPF cannot find my translation files

My app runs in WPF and Android (Windows Phone later) with mvvmcross as framework. I implemented localization with JsonLocalisation like the Babel (N21) example and it is working fine in Android. But whatever I try in WPF I get this message;
mvx:Warning: 0,22 Language file could not be loaded for Danish.SettingsViewModel -
FileNotFoundException: Unable to find resource file MyAppResources/Text/Danish/SettingsViewModel.json
at Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxContentJsonDictionaryTextProvider.
LoadJsonFromResource(String namespaceKey, String typeKey, String resourcePath) at >Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxTextProviderBuilder.LoadResources(String >whichLocalisationFolder)"
Stuart says in his video tutorial that the json translation files must be included as "Content" and not copied to the output folder - like;
But looking at the compiled executable with "dotPeek" doesn't reveal the files.
Am I missing something obvious? Any hints would be highly appreciated. Even confirmation from somebody who has JsonLocalisation working in WPF would be nice.
EDIT:
Well, I tried this code in my WPF mainWindow. I understand this call is used internally in MvxWPFResourceLoader.
public MainWindow()
{
....
//This return null without exceptions.
var t = Application.GetResourceStream(new Uri("MyAppResources/Text/Danish/SettingsViewModel.json", UriKind.Relative));
//This throwns an IOException; Cannot locate resource 'thisdoesnotexist/text/danish/settingsviewmodel.json'.
var y = Application.GetResourceStream(new Uri("ThisDoesNotExist/Text/Danish/SettingsViewModel.json", UriKind.Relative));
}
It seems when the path if wrong an exception is thrown. When it is correct it just returns null!!?! I am a bit puzzled, any ideas?
Best regards
Thank you for such fast answer (and for mvvmcross!).
The link you provided is to a Babel solution with a WPF sample - exactly what I needed. I mistakenly used the one from N21 without WPF sample :-)
Anyway, when looking at the sample I noticed that the json files must be included as 'Resource' and not 'Content'. That made all the difference - hurray!
Best regards

JSON won't work in Prism environment

In a project WITHOUT the Prism library I had this code working to get a collection of "Persoon" objects:
Dim ObjectCollectie As New ObservableCollection(Of Persoon)()
If MijnAPIResponse.IsSuccessStatusCode Then
Dim AntwoordVanAPI = Await MijnAPIResponse.Content.ReadAsStringAsync
ObjectCollectie = JsonConvert.DeserializeObject(Of ObservableCollection(Of Persoon))(AntwoordVanAPI)
This code refers to a WebAPI to fetch the data and everything works fine.
This same statement won't work in the Prism ViewModel. It goes perfect until the ObjectCollectie is trying to use the JsonConvert statement. The AntwoordVanAPI contains the same JSON string like before.
The error message I get is:
__The API 'System.Collections.ObjectModel.ObservableCollection1[[Dossier365.BusinessModels.Persoon, Dossier365.BusinessModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ff36822ea527de6]]..ctor(System.Collections.Generic.List1[Dossier365.BusinessModels.Persoon])' cannot be used on the current platform. See http://go.microsoft.com/fwlink/?LinkId=248273 for more information.__
This refers to a nonexisting page on the Internet (I have seen more than a few complaints about that!). It is not easy to find anything recent on the subject "API cannot be used". The newest posts were about 2 years old.
Because the code has not changed, I suspect the Prism library. But why? And how to overcome? I have posted this on the CodePlex Prism issuelist as well, but I get the impression that only a few readers are active there. No response for over a week on issues. I hope StackOverflow does a better job.
Please, PLEASE, anyone knows an answer to this??
Peter
After a couple of hours of comparning the code and about everything else, I finally figured out that the cause of this error lies in JSON.Net version 6.0.4. After stepping back to JSON.Net version 6.0.3 everything worked perfectly again. I have reported this in the JSON project on CodePlex.

SHDocVw - Creating IE9 com instances for printing

I have .net 3.5 app which creates IE9 com object instances.
InternetExplorerClass ie = new InternetExplorerClass();
Unfortunately for me, sometimes the creation of a new object fails with a generic 80004005 error.
I've noticed a similar post here, which however did not put the solution for the IE9 case.
Can you help me with this one? how should i create the ie9 object so that i will not get any more errors?
Thank you,
valentin

Status listener on mediaplayer object in javafx 2

I'm trying to make a media player with playlist in Javafx2.
I'm struggling because I want the playlist to advance to the next song when the current song ends. I was expecting a listener interface that I could implement in my playlist class but all that is on offer is that of a runnable.
Does anyone have any experience using this API that may help me?
Implement a Runnable for the setOnEndOfMedia method.
See this sample code which plays a list of audio files.
I think the media events should have been handled by EventHandlers rather than Runnables and requested that they be updated to work with EventHandlers but that requires a possibly incompatible API change which hasn't been implemented yet. So for now just use the Runnables - they work fine even though their method signatures are inconsistent with the rest of the JavaFX system.