Skip to content

Commit

Permalink
[Mono.Android] Import from monodroid/3e934261
Browse files Browse the repository at this point in the history
(*Now* things are starting to come together...)

One of the important infrastructural pieces of Xamarin.Android is
Mono.Android.dll, a "binding" for the Android SDK `android.jar` file.

Bindings are generated by using the `generator` tool from
Java.Interop, along with tools/jnienv-gen, and various other programs.

This in turn requires adding a git submodule for Java.Interop.

Stitch all these pieces together so that we can take an
*API description* (stored in Profiles\api-*.xml.in) and generate a
binding for that API description.

The generated files are located in
obj\$(Configuration)\android-$(ApiLevel), and the resulting
Mono.Android.dll is copied to
$(topdir)\bin\$(Configuration)\xbuild-frameworks\MonoAndroid\$(XAFrameworkVersion).

One SNAFU: currently, Mono.Android.csproj conditinally <Import/>s a
Mono.Android.projitems file generated by Java.Interop's generator
tool, which contains a list of all the generated files.

When the project is first loaded, Mono.Android.projitems will not
exist, so on that initial build, source code will be generated but
xbuild won't re-read Mono.Android.projitems (once it exists). This
will result in a failing build.

Simply rebuild the project to get a valid build, or use the `make all`
Makefile target.
  • Loading branch information
jonpryor committed Apr 21, 2016
1 parent 67e216c commit 5777337
Show file tree
Hide file tree
Showing 237 changed files with 2,710,484 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "external/mono"]
path = external/mono
url = git@github.com:mono/mono.git
[submodule "external/Java.Interop"]
path = external/Java.Interop
url = git@github.com:xamarin/Java.Interop.git
1 change: 1 addition & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Unix' And Exists ('/Applications') ">Darwin</HostOS>
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Unix' ">Linux</HostOS>
<ManagedRuntime Condition=" '$(ManagedRuntime)' == '' And '$(OS)' != 'Windows_NT' ">mono</ManagedRuntime>
<HOME Condition=" '$(HOME)' == '' ">$(HOMEDRIVE)$(HOMEPATH)</HOME>
<AndroidToolchainCacheDirectory Condition=" '$(AndroidToolchainCacheDirectory)' == '' ">$(HOME)\android-archives</AndroidToolchainCacheDirectory>
<AndroidToolchainDirectory Condition=" '$(AndroidToolchainDirectory)' == '' ">$(HOME)\android-toolchain</AndroidToolchainDirectory>
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CONFIGURATION = Debug
MSBUILD = xbuild /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS)

all:
(cd src/Mono.Android && $(MSBUILD) /t:_GenerateBinding)
$(MSBUILD)

prepare:
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Then, you may do one of the following:

2. Load `Xamarin.Android.sln` into Xamarin Studio and Build the project.

*Note*: The `Mono.Android` project may *fail* on the first build
because it generates sources, and those sources won't exist on the
initial project load. Rebuild the project should this happen.

# Build Output Directory Structure

There are two configurations, `Debug` and `Release`, controlled by the
Expand All @@ -76,4 +80,35 @@ mirrors that of the OS X Xamarin.Android.framework directory structure:
* `bin\$(Configuration)\lib\xbuild\Xamarin\Android`: MSBuild-related support
files and required runtimes used by the MSBuild tooling.
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid`: Xamarin.Android
profile assemblies and facade assemblies.
profiles.
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\v1.0`: Xamarin.Android
Base Class Library assemblies such as `mscorlib.dll`.
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\*`: Contains
`Mono.Android.dll` for a given Xamarin.Android `$(TargetFrameworkVersion)`.

# Xamarin.Android `$(TargetFrameworkVersion)`s

Xamarin.Android uses the MSBuild `$(TargetFrameworkVersion)` mechanism
to provide a separate `Mono.Android.dll` *binding assembly* for each API
level.

This means there is no *single* `Mono.Android.dll`, there is instead a *set*
of them.

This complicates the "mental model" for the `Mono.Android` project, as
a *project* can have only one output, not many (...within reason...).
As such, building the `Mono.Android` project will only generate a single
`Mono.Android.dll`.

To control which API level is bound, set the `$(ApiLevel)` and
`$(XAFrameworkVersion)` properties. `$(ApiLevel)` is the Android API level,
*usually* a number, while `$(XAFrameworkVersion)` is the Xamarin.Android
`$(TargetFrameworkVersion)`.

The default values will target Android API-23, Android 6.0.

For example, to generate `Mono.Android.dll` for API-19 (Android 4.4):

cd src/Mono.Android
xbuild /p:ApiLevel=19 /p:XAFrameworkVersion=v4.4
# creates bin\Debug\lib\xbuild-frameworks\MonoAndroid\v4.4\Mono.Android.dll
89 changes: 89 additions & 0 deletions Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,123 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "mono-runtimes", "build-tool
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jnienv-gen", "build-tools\jnienv-gen\jnienv-gen.csproj", "{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{04E3E11E-B47D-4599-8AFC-50515A95E715}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop", "external\Java.Interop\src\Java.Interop\Java.Interop.csproj", "{94BD81F7-B06F-4295-9636-F8A3B6BDC762}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "generator", "external\Java.Interop\tools\generator\generator.csproj", "{D14A1B5C-2060-4930-92BE-F7190256C735}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Xamarin.Android.NamingCustomAttributes", "external\Java.Interop\src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.shproj", "{74598F5C-B8CC-4CE6-8EE2-AB9CA1400076}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Java.Interop.Tools.TypeNameMappings", "external\Java.Interop\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.shproj", "{E706B6F2-5562-4765-8F07-8CF84A797B30}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Android", "src\Mono.Android\Mono.Android.csproj", "{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
Release|AnyCPU = Release|AnyCPU
XAIntegrationDebug|Any CPU = XAIntegrationDebug|Any CPU
XAIntegrationRelease|Any CPU = XAIntegrationRelease|Any CPU
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.Build.0 = Release|AnyCPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|x86.ActiveCfg = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|x86.Build.0 = Debug|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|x86.ActiveCfg = Release|Any CPU
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|x86.Build.0 = Release|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|AnyCPU.Build.0 = Release|AnyCPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|x86.ActiveCfg = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|x86.Build.0 = Debug|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|x86.ActiveCfg = Release|Any CPU
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|x86.Build.0 = Release|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|AnyCPU.Build.0 = Release|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|x86.ActiveCfg = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|x86.Build.0 = Debug|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|x86.ActiveCfg = Release|Any CPU
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|x86.Build.0 = Release|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|AnyCPU.Build.0 = Release|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|x86.ActiveCfg = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|x86.Build.0 = Debug|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|x86.ActiveCfg = Release|Any CPU
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|x86.Build.0 = Release|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|AnyCPU.Build.0 = Release|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationDebug|Any CPU.ActiveCfg = XAIntegrationDebug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationDebug|Any CPU.Build.0 = XAIntegrationDebug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationRelease|Any CPU.ActiveCfg = XAIntegrationRelease|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationRelease|Any CPU.Build.0 = XAIntegrationRelease|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|x86.ActiveCfg = Debug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|x86.Build.0 = Debug|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|x86.ActiveCfg = Release|Any CPU
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|x86.Build.0 = Release|Any CPU
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|AnyCPU.ActiveCfg = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|AnyCPU.Build.0 = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|AnyCPU.ActiveCfg = Release|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|AnyCPU.Build.0 = Release|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationDebug|Any CPU.Build.0 = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationRelease|Any CPU.Build.0 = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|x86.ActiveCfg = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|x86.Build.0 = Debug|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|x86.ActiveCfg = Release|x86
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|x86.Build.0 = Release|x86
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|AnyCPU.Build.0 = Release|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|x86.ActiveCfg = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|x86.Build.0 = Debug|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|x86.ActiveCfg = Release|Any CPU
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{E8492EFB-D14A-4F32-AA28-88848322ECEA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{94BD81F7-B06F-4295-9636-F8A3B6BDC762} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{D14A1B5C-2060-4930-92BE-F7190256C735} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{74598F5C-B8CC-4CE6-8EE2-AB9CA1400076} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{E706B6F2-5562-4765-8F07-8CF84A797B30} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
Expand Down
1 change: 1 addition & 0 deletions external/Java.Interop
Submodule Java.Interop added at 28fbb0
44 changes: 44 additions & 0 deletions src/Mono.Android/Android.Accounts/AccountManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using Android.Content;
using Android.Runtime;

using Java.Interop;

#if ANDROID_5

namespace Android.Accounts {

public partial class AccountManager {

public static AccountManager FromContext (Context context)
{
return context.GetSystemService (Context.AccountService) as AccountManager;
}

WeakReference weak_implementor_AccountsUpdated;
public event EventHandler<AccountsUpdateEventArgs> AccountsUpdated {
add {
AndroidEventHelper.AddEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>(
ref weak_implementor_AccountsUpdated,
() => new IOnAccountsUpdateListenerImplementor (this),
SetOnAccountsUpdatedListener,
__h => __h.Handler += value);
}
remove {
AndroidEventHelper.RemoveEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>(
ref weak_implementor_AccountsUpdated,
IOnAccountsUpdateListenerImplementor.__IsEmpty,
SetOnAccountsUpdatedListener,
__h => __h.Handler -= value);
}
}

void SetOnAccountsUpdatedListener (IOnAccountsUpdateListener value)
{
AddOnAccountsUpdatedListener (value, null, false);
}
}
}

#endif // ANDROID_5

105 changes: 105 additions & 0 deletions src/Mono.Android/Android.Animation/Animator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#if ANDROID_11

using System;

using Android.Runtime;

namespace Android.Animation {

partial class Animator {

WeakReference dispatcher;
AnimatorEventDispatcher Dispatcher {
get {
if (dispatcher == null || !dispatcher.IsAlive) {
dispatcher = new WeakReference (new AnimatorEventDispatcher ());
AddListener ((AnimatorEventDispatcher) dispatcher.Target);
}
return (AnimatorEventDispatcher) dispatcher.Target;
}
}

public event EventHandler AnimationCancel {
add {
Dispatcher.AnimationCancel += value;
}
remove {
Dispatcher.AnimationCancel -= value;
}
}

public event EventHandler AnimationEnd {
add {
Dispatcher.AnimationEnd += value;
}
remove {
Dispatcher.AnimationEnd -= value;
}
}

public event EventHandler AnimationRepeat {
add {
Dispatcher.AnimationRepeat += value;
}
remove {
Dispatcher.AnimationRepeat -= value;
}
}

public event EventHandler AnimationStart {
add {
Dispatcher.AnimationStart += value;
}
remove {
Dispatcher.AnimationStart -= value;
}
}
}

[Register ("mono/android/animation/AnimatorEventDispatcher")]
internal class AnimatorEventDispatcher : Java.Lang.Object, Animator.IAnimatorListener {

public AnimatorEventDispatcher ()
: base (
JNIEnv.StartCreateInstance ("mono/android/animation/AnimatorEventDispatcher", "()V"),
JniHandleOwnership.TransferLocalRef)
{
JNIEnv.FinishCreateInstance (Handle, "()V");
}

public EventHandler AnimationCancel;
public EventHandler AnimationEnd;
public EventHandler AnimationRepeat;
public EventHandler AnimationStart;

public void OnAnimationCancel (Animator animation)
{
var h = AnimationCancel;
if (h != null)
h (animation, EventArgs.Empty);
}

public void OnAnimationEnd (Animator animation)
{
var h = AnimationEnd;
if (h != null)
h (animation, EventArgs.Empty);
}

public void OnAnimationRepeat (Animator animation)
{
var h = AnimationRepeat;
if (h != null)
h (animation, EventArgs.Empty);
}

public void OnAnimationStart (Animator animation)
{
var h = AnimationStart;
if (h != null)
h (animation, EventArgs.Empty);
}
}
}

#endif
49 changes: 49 additions & 0 deletions src/Mono.Android/Android.Animation/AnimatorSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#if ANDROID_11

using System;
using Android.Runtime;

namespace Android.Animation
{
public partial class AnimatorSet
{
private static IntPtr id_setDuration_J;
[Register ("setDuration", "(J)Landroid/animation/Animator;", "GetSetDuration_JHandler")]
public override Animator SetDuration (long duration)
{
if (id_setDuration_J == IntPtr.Zero)
id_setDuration_J = JNIEnv.GetMethodID (class_ref, "setDuration", "(J)Landroid/animation/Animator;");

if (base.GetType () == this.ThresholdType) {
return Java.Lang.Object.GetObject<AnimatorSet> (
JNIEnv.CallObjectMethod (base.Handle, id_setDuration_J, new JValue (duration)),
JniHandleOwnership.TransferLocalRef);
} else {
return Java.Lang.Object.GetObject<AnimatorSet> (
JNIEnv.CallNonvirtualObjectMethod (
base.Handle,
this.ThresholdClass,
JNIEnv.GetMethodID (ThresholdClass, "setDuration", "(J)Landroid/animation/Animator;"),
new JValue (duration)),
JniHandleOwnership.TransferLocalRef);
}
}

private static Delegate cb_setDuration_J;

private static Delegate GetSetDuration_JHandler ()
{
if (cb_setDuration_J == null)
cb_setDuration_J = JNINativeWrapper.CreateDelegate (new Func<IntPtr, IntPtr, long, IntPtr> (n_SetDuration_J));
return cb_setDuration_J;
}

private static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
{
AnimatorSet @object = Java.Lang.Object.GetObject<AnimatorSet> (native__this, JniHandleOwnership.DoNotTransfer);
return JNIEnv.ToJniHandle (@object.SetDuration (duration));
}
}
}

#endif
Loading

0 comments on commit 5777337

Please sign in to comment.