Jump to content

Java / Android client libraries


Luke

Recommended Posts

Since I now have a goal of using code generation techniques to create C++ and Java versions, it has to become as primitive as possible. So all Guid properties are now strings.

 

The data isn't changing, and this doesn't affect api output at all. This just means that on the client you'll only see it as a plain string, which is what it should have been to begin with.

 

To be honest, there weren't a whole lot of guids anyway, mostly ImageTag values. So it shouldn't be too hard.

 

Ebr - I know at some point you took a copy of BaseApiWebSocket from ApiClient. You will want to do that again as it now adds support for receiving a lot of the new commands.

Link to comment
Share on other sites

Starting with java because that's the easy one

 

https://github.com/MediaBrowser/MediaBrowser.ApiClient.Java

 

Just model classes for now. Hopefully api connectivity later. Only one more class to fix and then it's a more or less perfect conversion.

 

This should save Red and Shiv a ton of time if it turns out well. (After any upgrade work though).

Link to comment
Share on other sites

Redshirt

How did the conversion handle some of the Generics in the model classes? <T> specifically.

Link to comment
Share on other sites

techywarrior

Long term is the OS X and Linux version going to end up being Java based while the Win version is C++ ? Just curious the though pattern for this undertaking. Java is more portable then .NET but it seems like most of the work to get it running in Mono has been taken care of at this point. No performance difference is there between Java and .NET I thought. Or .NET being a bit faster... and less security issues. C++ would be awesome because it would definitely be faster and may reduce the memory footprint as well.

Link to comment
Share on other sites

Aphid

This is only for the client side API libraries, not the server itself.

 

Java is more portable then .NET

 

CLI languages run on more platforms than JVM languages.

Link to comment
Share on other sites

techywarrior

Ah ok. I thought Luke was working to port the entire server code base.

 

And I hate Java (besides not seeing the benefit at least from .NET to Java).

Link to comment
Share on other sites

Yea it will make it easier for client developers to get up and running quickly. Just had to dumb it down a little by removing linq and var keywords, but resharper took care of that in one shot for me.

Link to comment
Share on other sites

@@Redshirt - the java conversion is now complete and at this point i would highly suggest switching over to it, even if it sets you back a few days.

 

for one thing you'll be able to use core code to build your stream url's. the same code 7 is using, and that will soon be used by Scott, MBC, MBT and media portal. It's all based on a device profile.

Link to comment
Share on other sites

Redshirt

I thought it was just model objects. You've added an actual api client as well?

Link to comment
Share on other sites

Koleckai Silvestri

Good to here that we won't have to run JAVA on our servers. I realize it is great for embedded machines but I don't want it near my Windows hardware.

  • Like 1
Link to comment
Share on other sites

There's a whole Dlna namespace with parameter construction based on a device profile. and then the ability to construct a url. That's the extent of it. No ApiClient yet. But even still, you get two major benefits - exact replicas of model objects, as well as keeping them up to date. and then you get the stream url building.

  • Like 1
Link to comment
Share on other sites

Red, I just updated the java api client to the latest model objects.

Link to comment
Share on other sites

Redshirt

I can't use the model project in it's current state. None of the import directives (c# using) are created by the conversion tool. If I go through the source and add them, the files will just get overwritten the next time the conversion tool is run. 

 

The alternatives are to either find a different conversion tool, or see if there is an option to generate the import statements. Or go all-in and maintain the project as a first-class citizen. Or just give it up :(

 

Scratch that. They're generated, but android studio is ignoring them... weird.

Edited by Redshirt
Link to comment
Share on other sites

maybe getting ignored based on the structure of the folders?

Link to comment
Share on other sites

Redshirt

I've already reworked the directory structure to correct that. It's actually all the C# only classes. For example, Model\Events\GenericEventArgs is broken because it's extending System.EventArgs which doesn't exist in Java. Also any string comparison in the model objects still has the ordinalIgnoreCase in the signature which doesn't exist in Java. There's more, I'm just scratching the surface.

Link to comment
Share on other sites

ok great - keep listing these things out and i'll keep dumbing them down so that they'll work for you

Link to comment
Share on other sites

by the way, you don't need GenericEventArgs. I've been basing the conversion off of the .net 3.5 model project. since it faster for me to just point the tool to the whole project file, that's what i do.

 

i think 90% of the classes you will want but there will be some you can drop, like that one.

Link to comment
Share on other sites

what i can also do is take all the uses or OrdinalIgnoreCase, move them to a helper class, and then all you'll have to do is replace the helper with java's equalsIgnoreCase. That is unless i write a hand made comparison.

Link to comment
Share on other sites

Redshirt

There's already a helper class in the tangible directory. You could just expand that if it's not being overwritten each time you run the tool.

 

I'm not sure what's going on with the tangible.RefObject<T> references everywhere. Perhaps the class was lost in the mix somewhere. Also CultureInfo has to go.

Link to comment
Share on other sites

ok, thanks. as soon as the server release goes out i'll take care of this.

Link to comment
Share on other sites

  • 2 weeks later...

Red can you give this another shot and report back? Thanks. The classes in the Extensions folder you'll need to implement yourself but that should be pretty easy.

Link to comment
Share on other sites

This has been synced to the latest. The directory structure has been fixed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...