Blog Pages

Wednesday, May 01, 2013

N=6 - Books over the network (N+1 days of MvvmCross)

Today we make another 4 platform example.

This time:
  • we include a very simple REST service - which sends GET requests to the Google Books search API
  • we include the JSON plugin to decode the requests
  • we try to use the Visual Designers to help produce nicer UIs

You'll quickly spot that I'm not very good with the designers - it's not them, it's me :)


Here's the video:





You'll see that I hit a couple of errors along the way:
  • I initially got my namespace wrong - sorry - just had to fix it during the demo!
  • A bug in  the JSON plugin NuGet package for MvvmCross - have already fixed in v3 (but not uploaded to nuget.org yet)
  • A possible bug in Mono (MonoTouch?) with SSL - will report to Xamarin and see what they say


Completed code is on: https://github.com/slodge/NPlus1DaysOfMvvmCross/tree/master/N-06-Books



For more on the Google Books API try https://developers.google.com/books/docs/v1/using#PerformingSearch


For more on json to C# conversion, see http://json2csharp.com/

.... or try http://blogs.msdn.com/b/webdev/archive/2012/12/18/paste-json-as-classes-in-asp-net-and-web-tools-2012-2-rc.aspx



Update: I then moved across to the Mac and did a prettier cell design - here it is:






Previously in N+1:

4 comments:

  1. I have this problem on last branch

    here

    public string authorSummary
    {
    get { return authors == null ? "-" : string.Join(", ", authors); }
    }

    /Users/Downloads/NPlus1DaysOfMvvmCross-master/N-06-Books/Book.Core/Services/VolumeInfo.cs(57,57): Error CS1502: The best overloaded method match for `string.Join(string, string[])' has some invalid arguments (CS1502) (Books.Core)

    /Users/Downloads/NPlus1DaysOfMvvmCross-master/N-06-Books/Book.Core/Services/VolumeInfo.cs(68,68): Error CS1503: Argument `#2' cannot convert `System.Collections.Generic.List' expression to type `string[]' (CS1503) (Books.Core)

    /Users/Downloads/NPlus1DaysOfMvvmCross-master/N-06-Books/Book.Core/ViewModels/FirstViewModel.cs(40,40): Error CS1684: Reference to type `System.Func`1' claims it is defined assembly `mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found (CS1684) (Books.Core)

    ReplyDelete
  2. What are you compiling on? Sounds like the same error as the unity guys saw - but they were using an old .net version - see https://github.com/slodge/MvvmCross/issues/246

    ReplyDelete
  3. I had configured Xamarin Studio in beta. I did a rollback in stable and now works correctly!

    Thanks for support!

    ReplyDelete
  4. Hi, I have problem about displaying images on my android project. Title and author have no problem but I can't display images with this layout;



    I checked the json document on link and follow path where the smallThumbnail is located. Do you have any suggestion.
    Thank you..

    ReplyDelete