Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Quick JSON serializer performance test (Json.NET vs ServiceStack)

$
0
0

No pun intended but this is just a quick test between two popular JSON (de)serializers available for Xamarin iOS and Android. I will run iOS comparison later on but from previous experiments Android shows more difference between the two libraries.

Source code is available at GitHub in case you want to extend the tests or run them yourself: https://github.com/sami1971/SimplyMobile

Tests were compiled and ran in Release mode.

[NUnitLite] NUnit automated tests loaded.
[Runner executing:  Run Everything]
[M4A Version:   ???]
[Board:     tuna]
[Bootloader:    PRIMELA03]
[Brand:     samsung]
[CpuAbi:    armeabi-v7a armeabi]
[Device:    maguro]
[Display:   JOP40D.I9250XWMA2]
[Fingerprint:   samsung/yakjuxw/maguro:4.2.1/JOP40D/I9250XWMA2:user/release-keys]
[Hardware:  tuna]
[Host:      DELL123]
[Id:        JOP40D]
[Manufacturer:  samsung]
[Model:     Galaxy Nexus]
[Product:   yakjuxw]
[Radio:     unknown]
[Tags:      release-keys]
[Time:      1359045633000]
[Type:      user]
[User:      dpi.sec]
[VERSION.Codename:  REL]
[VERSION.Incremental:   I9250XWMA2]
[VERSION.Release:   4.2.1]
[VERSION.Sdk:       17]
[VERSION.SdkInt:    17]
[Device Date/Time:  11/6/2013 11:07:32 PM]
TextSerializationTests
JsonNetTests
    [FAIL] TestBase.CanSerializeInterface : Newtonsoft.Json.JsonSerializationException : Could not create an instance of type TextSerializationTests.IAnimal. Type is an interface or abstract class and cannot be instantated. Path 'Pets[0].Name', line 1, position 62.
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultConstructor) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IWrappedCollection wrappedList, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <filename unknown>:0 
SimplyMobile.Text.JsonNet.JsonSerializer took 1583ms deserializing 10000 iterations.
    Passed TestBase.DeserializationSpeed
SimplyMobile.Text.JsonNet.JsonSerializer took 425ms serializing 10000 iterations.
    Passed TestBase.SerializationSpeed
JsonNetTests : 2583.71 ms
ServiceStackTests
    Passed TestBase.CanSerializeInterface
SimplyMobile.Text.ServiceStack.JsonSerializer took 364ms deserializing 10000 iterations.
    Passed TestBase.DeserializationSpeed
SimplyMobile.Text.ServiceStack.JsonSerializer took 187ms serializing 10000 iterations.
    Passed TestBase.SerializationSpeed
ServiceStackTests : 1332.855 ms
TextSerializationTests : 3936.737 ms
Tests run: 6, Passed: 5, Failed: 1, Skipped: 0, Inconclusive: 0

How would you approach auto hide/show of tab bar

$
0
0

I'd like to add in the effect of hiding my UITabBarController when a user starts to scroll a table, and then if they start to scroll back towards the top, it reappears. Similar to how Safari works. I'm assuming that you look at scrollViewDidScroll and then do something like what is documented here:

http://stackoverflow.com/a/11490623

Does anyone have an example of hiding/showing the tab bar in C#? I can take a stab at translation, but if someone has a copy handy or if there is a demo that I missed I'd appreciate a pointer. The biggest part that I'm not sure of in the translation from ObjC is the animations part.

Thanks!

JB

Java 1.7 (Java 7)

$
0
0

In setting up the Android tools, the Xamarin Installer sets up Java 1.6 (Java 6). Does Java 1.7 work by itself? I got this question today. It's been so long since I set the tools up manually, I had forgotten all about this.

Wally

ShouldChangeCharacters not working as expected

$
0
0

It is my understanding that if ShouldChangeCharacters returns false, the character typed is omitted. Well, I'm using the following test:

textFieldEmail.ShouldChangeCharacters = (textField, range, replacement) => { return false; };

and the keys are being typed in. Here's my Version information:

Xamarin Studio Version 4.2.2 (build 2) Installation UUID: 260f2c8d-92ee-4453-b830-bc9dd527db59 Runtime: Mono 3.2.5 ((no/964e8f0) GTK+ 2.24.20 theme: Raleigh GTK# (2.12.0.0) Package version: 302050000

Apple Developer Tools Xcode 5.0.2 (3335.32) Build 5A3005

Xamarin.iOS Version: 7.0.4.209 (Business Edition) Hash: 23a0827 Branch: Build date: 2013-11-11 16:04:00-0500

Xamarin.Mac Xamarin.Mac: Not Installed

Xamarin.Android Version: 4.10.1 (Business Edition) Android SDK: /Users/jstawski/Library/Developer/Xamarin/android-sdk-mac_x86 Supported Android versions: 2.1 (API level 7) 2.2 (API level 8) 2.3 (API level 10) 3.1 (API level 12) 3.2 (API level 13) 4.0 (API level 14) 4.0.3 (API level 15) 4.1 (API level 16) 4.2 (API level 17) Java SDK: /usr No Java runtime present, requesting install.

Build Information Release ID: 402020002 Git revision: c5f82958ae7d9af652b44b87ceff777b3ad19b91 Build date: 2013-11-19 15:35:40+0000 Xamarin addins: a4044fee09138f6fd031a9944b7caaeb51e57e80

Operating System Mac OS X 10.9.1 Darwin jonass-imac 13.0.0 Darwin Kernel Version 13.0.0 Thu Sep 19 22:22:27 PDT 2013 root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

Is this a bug?

Using NavigationController property prevents UIViewController collection

$
0
0

This is a follow on from here http://forums.xamarin.com/discussion/12005/uiviewcontroller-never-garbage-collected-with-derived-uiview in which I'm trying to sort out a bunch of issues relating to view controllers not getting released.

This time, it seems that after accessing UIViewController.NavigationController you must Dispose the returned object. For example:

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);

    if (false)
    {
        // This works
        using (var nav = NavigationController)
        {
            float headerHeight = nav.NavigationBar.Frame.Bottom;    
        }
    }
    else
    {
        // This causes the view controller to not be GC'ed.
        float headerHeight = this.NavigationController.NavigationBar.Frame.Bottom;  
    }
}

Really? Surely it shouldn't be necessary to Dispose the return value of a property get? Is there a better workaround?

See below for a full project that demonstrates the issue:

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;

namespace gctest
{
    class TypedWeakReference<T>
    {
        public TypedWeakReference(T target)
        {
            _wr = new WeakReference(target);
        }

        public T Target
        {
            get { return (T)_wr.Target; }
        }

        WeakReference _wr;
    }

    class OtherViewController : UIViewController
    {
        public OtherViewController()
        {
            this.View = new UIView();

            this.View.BackgroundColor = UIColor.Green;

            var button = new UIButton(new RectangleF(20, 40, 280, 60));
            button.SetTitle("Dismiss This", UIControlState.Normal);
            button.BackgroundColor = UIColor.Orange;
            this.View.AddSubview(button);

            var weakThis = new TypedWeakReference<OtherViewController>(this);
            button.TouchUpInside += (s, a) => {
                weakThis.Target.DismissViewController(true, null);
            };
        }

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            if (false)
            {
                // This works
                using (var nav = NavigationController)
                {
                    float headerHeight = nav.NavigationBar.Frame.Bottom;    
                }
            }
            else
            {
                // This causes the view controller to not be GC'ed.
                float headerHeight = this.NavigationController.NavigationBar.Frame.Bottom;  
            }
        }

        ~OtherViewController()
        {
            Console.WriteLine("OtherViewController finalized");
        }

    }

    class MainViewController : UIViewController
    {
        public MainViewController()
        {
            this.View.BackgroundColor = UIColor.Yellow;

            var button = new UIButton(new RectangleF(20, 40, 280, 60));
            button.SetTitle("Show Other", UIControlState.Normal);
            button.BackgroundColor = UIColor.Orange;
            button.TouchUpInside += (sender, e) => {

                var vc = new OtherViewController();
                PresentViewController(new UINavigationController(vc), true, null);

            };
            this.View.AddSubview(button);

            button = new UIButton(new RectangleF(20, 140, 280, 60));
            button.SetTitle("GC Now", UIControlState.Normal);
            button.BackgroundColor = UIColor.Orange;
            button.TouchUpInside += (sender, e) => {

                System.GC.Collect();

            };
            this.View.AddSubview(button);
        }
    }

    [Register("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        UIWindow window;
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = new MainViewController();
            window.MakeKeyAndVisible();

            return true;
        }
    }
}

How to Fix iOS6 and iOS7 View Differences?

$
0
0

Hi all,

I have a screen (and this applies to all screens) with a search box at the top of the View. It shows correctly in iOS7, while in iOS6 everything is pushed down.

How to make them look the same?

Thanks!

Application Output Pad missing

$
0
0

As you can see in the attached screenshot, I have no Application Output pad.

I have this same issue on two Macs; one runs OSX 10.7.5, the other has the latest Mavericks. Both have Xamarin up-to-date, both have had this issue for several versions, and I've tried switching around from Stable/Alpha/Beta channels.

Anyone have any idea on this? Thanks!

Where Did My XIB Files Go?????

$
0
0

Working on my project today and double-clicked on a XIB file in my Solution view. In the past it always started Xcode and brought me right to the IB Builder. Last few days I did this and it still worked, but always gave me some Xcode error that I ignored.

HOWEVER...

This time I doubled-clicked on a XIB in the Solution Explorer and got the usual error, but XCode never came up automatically as before. And all of my 30 or so XIB files are no longer showing up in the Solution View. The files still exist on disk, and the project still builds, even after a Clean and Rebuild.

So what happened???


Job Opportunity

$
0
0

Hello,

I am a C# developer and I just took on a project using Xamarin with iOS 7 for an iPad… would anyone be interested in a bit of consulting work on some methods I will be using and overall coding structure help? I have a few hundred lines written so far and the program i made as a test is working well, but I have a lot of questions… Please pm me if interested. I can do 50$ an hour PayPal and I promise it won't be too difficult.

-Tester

Listview First Row

$
0
0

I have a custom adapter working with a listview. Under my 'GetView' I have a CheckedChange function. It works perfectly for all rows except the very first/top row. Whenever the CheckBox in the first/top row is toggled, the CheckedChange function gets called for every row in the listview. Is there something I'm doing wrong? or should I just create a flag somehow to catch it? Thanks!

Xamarin Developer (iOS & Android) - 3 month contract - Buckinghamshire

$
0
0

Hi all, I'm currently recruiting a contractor to build an iOS & Android app using Xamarin. This will be a 3 month project based on-site in Buckinghamshire. Really interesting piece of work for an industry leading client. If suitable, please forward your CV to tom.townsend@24-7recruitment.net Feel free to share this with colleagues/friends. Kind Regards, Tom

Is there a way override the .plist device orientations in just one screen?

$
0
0

My i didn't write my last question very fine so im writing again. I need to know if theres a way for me to override the plist supported device orientations or if i need to allow it to all orientations and then block each screen i want to stay landscape for example. And what is the method for me to know when the screen orientation changed? Like override DidRotated or something... Please help >:

Can't prevent screen rotation

$
0
0

Okay, I feel like an idiot because I've done this before but I've been stuck now for a couple of days.

In my app I do want to allow rotation in many (most) cases. So in my Info.plist file I have 3 of the 4 device orientations selected (which I think is the default when creating a new project). On a couple of screens I want to keep the app in Portrait mode. In a plain vanilla UIViewController class I went ahead and added:

public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
  return UIInterfaceOrientationMask.Portrait;
}

public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
{
  return UIInterfaceOrientation.Portrait;
}

and for good measure

public override bool ShouldAutorotate()
{
  return false;
}

Yet the damn thing still rotates! What gives? Am I missing something obvious?

JB

Google Play Services component doesn't compile

$
0
0

I am having issue in running the Google Map.

It seems the error looks the same given in the link.

https://bugzilla.xamarin.com/show_bug.cgi?id=14910


/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_CompileJava target) ->

obj/Debug/android/src/mono/com/google/android/gms/plus/PlusClient_OnPersonLoadedListenerImplementor.java(8,41): javacerror : cannot find symbol symbol : class OnPersonLoadedListener location: class com.google.android.gms.plus.PlusClient com.google.android.gms.plus.PlusClient.OnPersonLoadedListener

------------------------------------Please help in this issue------------------------------------------

November 9: MUGH TechDay 2013: 'iOS & Android Development in C# & Visual Studio', Hyderabad, India

$
0
0

I'll be delivering a talk on iOS & Android Development in C# & Visual Studio at Microsoft Hyderabad. If you are in Hyderabad, don't miss!

Register here: http://mugh.net/techday2013/


Evolve 2014?

$
0
0

Will there be a Xamarin conference like last year's Evolve conference again this year?

[Xamarin Blog] iOS 6 & 7 Compatibility Tips

$
0
0

Just posted: iOS 6 & 7 Compatibility Tips on the Xamarin Blog.

Read the full article to learn how to up your Xamarin.iOS app to the new iOS 7 look and feel while still maintaining backwards compatibility with iOS 6.

Use this thread to discuss or ask questions.

Keychain issue using git

$
0
0

Hi.

Git prompts me for username and password every time I push something, this totaly fine. However, I keep getting the error message after I have providedd my credentials: "Could not add internet password to keychain etc..." The password has already been saved before, and now the commmit/push is aborted.

It will work again, ONE TIME, if i delete the "login" key inside the keychain.

Has someone else encountered the same problem?

I have very litle experiance working with OS X.

//Rickard

How to create round buttons

$
0
0

Hello! I am creating buttons dynamically. I need to create N round buttons. Window backround is gradient. Amount of buttons can be changed.

Now I am doing it like this:

Button btn = new Button (this);
btn.SetBackgroundResource (Resource.Drawable.myButton);

Where myButton is square picture of my button. First problem : button has not round shape. Second prblem : because of gradient background it looks terribly.

"Create installer package" -> .pkg but that .pkg does not do anything useful

$
0
0

I discovered an exciting-looking option in Xamarin studio that is labelled "Create installer package". And sure enough with it ticked I get a .pkg file as well as an .app file in the output directory.

However when I run that .pkg file, although it goes through the steps of installing the .app file (including "writing files" and "The installation was successful" - with a big white on green tick), it doesn't actually put the .app file anywhere. (I do a search on the whole machine and its not there.)

Any suggestions how I could fix this, or what I could be doing wrong?

I notice a small info triangle mentioning Mac store. Does this kind of .pkg only work if it is used through the mac store?

Viewing all 204402 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>