Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.Forms 3.3 and IImageViewHandler support #7

Merged
merged 10 commits into from Oct 15, 2018
Merged
17 changes: 14 additions & 3 deletions build.cake
Expand Up @@ -12,11 +12,15 @@ var dirs = new[]
Directory("./glidex/obj") + Directory(configuration),
Directory("./glidex.forms/bin") + Directory(configuration),
Directory("./glidex.forms/obj") + Directory(configuration),
Directory("./glidex.sample/bin") + Directory(configuration),
Directory("./glidex.sample/obj") + Directory(configuration),
Directory("./glidex.forms.sample/bin") + Directory(configuration),
Directory("./glidex.forms.sample/obj") + Directory(configuration),
};
string output = dirs[0];
string sln = "./glidex.sln";
string version = "1.0.2";
string suffix = "";
string version = "1.0.3";
string suffix = "-pre";

Task("Clean")
.Does(() =>
Expand All @@ -39,6 +43,13 @@ Task("Build")
MSBuild(sln, settings => settings.SetConfiguration(configuration));
});

Task("Install")
.IsDependentOn("Build")
.Does(() =>
{
MSBuild("./glidex.forms.sample/glidex.forms.sample.csproj", settings => settings.SetConfiguration(configuration).WithTarget("Install").WithTarget("_Run"));
});

Task("NuGet-Package-GlideX")
.IsDependentOn("Build")
.Does(() =>
Expand Down Expand Up @@ -78,4 +89,4 @@ Task("NuGet-Push")
Task("Default")
.IsDependentOn("NuGet-Package");

RunTarget(target);
RunTarget(target);
2 changes: 1 addition & 1 deletion glidex.forms.sample/Forms/Images.cs
Expand Up @@ -30,7 +30,7 @@ public static ImageSource SourceById (int x)
switch (x) {
//Urls
case 0:
return ImageSource.FromUri (new Uri ("https://botlist.co/system/BotList/Bot/logos/000/002/271/medium/chuck_norris.jpg"));
return ImageSource.FromUri (new Uri ("https://growtix-melupufoagt.stackpathdns.com/media/big//34/28/23/5a9f03c2-3734-4486-bd04-2d45ac1c102e.png"));
case 1:
return ImageSource.FromUri (new Uri ("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Steven_Seagal_November_2016.jpg/230px-Steven_Seagal_November_2016.jpg"));
case 2:
Expand Down
6 changes: 3 additions & 3 deletions glidex.forms.sample/Properties/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.glidex.forms.sample">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="glidex.forms.sample"></application>
</manifest>
</manifest>
18 changes: 8 additions & 10 deletions glidex.forms.sample/glidex.forms.sample.csproj
Expand Up @@ -8,21 +8,20 @@
<OutputType>Library</OutputType>
<RootNamespace>Android.Glide.Sample</RootNamespace>
<AssemblyName>glidex.forms.sample</AssemblyName>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidTlsProvider>btls</AndroidTlsProvider>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
Expand All @@ -32,7 +31,6 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
Expand All @@ -52,12 +50,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="2.4.0.280" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="23.3.0" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="23.3.0" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="23.3.0" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="23.3.0" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="23.3.0" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.893527-pre3" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2" />
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\EdgeCasesPage.xaml.cs">
Expand Down
6 changes: 5 additions & 1 deletion glidex.forms.sample/proguard.cfg
Expand Up @@ -4,4 +4,8 @@
**[] $VALUES;
public *;
}
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder

# https://github.com/xamarin/Xamarin.Forms/issues/2709
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.*
16 changes: 2 additions & 14 deletions glidex.forms/GlideExtensions.cs
Expand Up @@ -14,20 +14,9 @@ public static class GlideExtensions
{
const string Tag = "glidex";

public static void LoadViaGlide (this ImageView imageView, Image image)
{
LoadViaGlide (imageView, () => image.Source);
}

public static void LoadViaGlide (this ImageView imageView, ImageCell cell)
{
LoadViaGlide (imageView, () => cell.ImageSource);
}

static async void LoadViaGlide (ImageView imageView, Func<ImageSource> func)
public static async void LoadViaGlide (this ImageView imageView, ImageSource source, CancellationToken token)
{
try {
var source = func ();
if (source == null) {
Clear (imageView);
return;
Expand Down Expand Up @@ -62,10 +51,9 @@ static async void LoadViaGlide (ImageView imageView, Func<ImageSource> func)
} else if (source is UriImageSource uriSource) {
builder = request.Load (uriSource.Uri.OriginalString);
} else if (source is StreamImageSource streamSource) {
var token = new CancellationToken ();
using (var memoryStream = new MemoryStream ())
using (var stream = await streamSource.Stream (token)) {
if (token.IsCancellationRequested || stream == null || source != func ())
if (token.IsCancellationRequested || stream == null)
return;
stream.CopyTo (memoryStream);
builder = request.Load (memoryStream.ToArray ());
Expand Down
42 changes: 0 additions & 42 deletions glidex.forms/ImageCellRenderer.cs

This file was deleted.

25 changes: 0 additions & 25 deletions glidex.forms/ImageExtensions.cs

This file was deleted.

156 changes: 0 additions & 156 deletions glidex.forms/ImageRenderer.cs

This file was deleted.