Comments (12)
It shouldn't be complicated to add this info. I will look into it.
Therefore I'm very interested with your iOS fading logic. There is a task about it in fact #16
Would you mind sharing your fading code for iOS? We might be able to integrate that in the lib.
from ffimageloading.
Here's my fading code:
if (imageLoadingWork != null)
{
imageLoadingWork.Cancel();
imageLoadingWork = null;
}
Uri imageUrl = null;
if (viewModel != null)
{
var imageUrlViewModel = viewModel as IRemoteImage;
if (imageUrlViewModel != null)
{
imageUrl = imageUrlViewModel.ImageUrl;
if (imageUrl != null)
{
if (shownImageUrl == imageUrl)
{
// Nothing to do here, we are already showing the correct image
ContentImageView.Alpha = 1.0f;
}
else
{
// Clear the image and start loading the next one
ContentImageView.Image = null;
ContentImageView.Alpha = 0.0f;
var urlString = imageUrl.ToString();
imageLoadingWork = ImageService.LoadUrl(urlString)
.Error(e => Console.WriteLine("Failed to load image: " + urlString + " error: " + e))
.Success(() =>
{
shownImageUrl = imageUrl;
UIView.AnimateNotify(
AnimationDuration,
0.0f,
UIViewAnimationOptions.CurveEaseInOut,
() =>
{
ContentImageView.Alpha = 1.0f;
},
null);
})
.Finish(work =>
{
// This is a special case that occurs when the image is being loaded from a disk cache. The work is not marked as either cancelled or completed.
// In this case, we are going to stop to animation started by the success block and put the image onscreen without the fade
bool loadedAlready = work.IsCancelled == false && work.Completed == false;
if (loadedAlready && ContentImageView.Alpha == 1.0f)
{
ContentImageView.Layer.RemoveAllAnimations();
ContentImageView.Alpha = 1.0f;
}
})
.Into(ContentImageView);
}
}
else
{
ContentImageView.Alpha = 0.0f;
ContentImageView.Image = null;
}
}
from ffimageloading.
@mgorbach this is implemented in git now. Success callback gives both the size and a LoadingResult enum. It allows you to know if it was loaded from Internet, Disk, ApplicationBundle, DiskCache, or MemoryCache.
Could you give it a try?
from ffimageloading.
@molinch thanks for implementing this so quickly!
I can't quite try off git though, because I'm having trouble building the library. I'm trying to build the master branch on a Mac with the latest stable Xamarin Studio, and I'm getting a bunch of errors with missing references and WebP on iOS not being found, even though it seems to have restored the internal nuget packages as expected.
from ffimageloading.
Ok don't worry, I will soon make a release on NuGet so this will be included
from ffimageloading.
You can test this prerelease NuGet package: https://www.nuget.org/packages/Xamarin.FFImageLoading/1.1.6-alpha
If it works fine I'll make a release.
from ffimageloading.
@molinch thanks, I just gave it a shot. I'm getting callbacks with a loading result, but it always seems to be "internet." I haven't changed any of the disk cache settings, so I'd expect the disk cache to be enabled by default. Might be it's a bug with the result implementation?
from ffimageloading.
Also, the issue I was exploiting earlier still exists, and once the result implementation works it should probably be fixed. Specifically, when loading from the in-memory cache, the finish callback is called and both "completed" and "cancelled" are false. It seems like "completed" should be true in this case.
from ffimageloading.
Weird I tested this and got data from Internet, DiskCache and MemoryCache :(
I will give it another try
from ffimageloading.
And yes you are right it should have completed true when loading from Memory.
from ffimageloading.
@mgorbach I retested all scenarios on both iOS and Android and it works fine: Disk, DiskCache, Internet, Memory... It's always giving the correct result.
There was just one issue, affecting iOS DiskCache only, but everything else was working fine.
Now this is fixed in git too and I will make a Nuget release soon.
Could you make a separate issue regarding the callbacks?
from ffimageloading.
I pushed a new Alpha nuget https://www.nuget.org/packages/Xamarin.FFImageLoading/1.1.6-alpha1 which contains the last fix (plus other things)
I will make a release soon
from ffimageloading.
Related Issues (20)
- Check if Image Server side has changed from Cached version
- [Bug]In Xamarin.Forms (Android) throws System.ArgumentException in ImageService.SetTaskForTarget (FFImageLoading.Work.IImageLoaderTask currentTask).
- Support for image width/height query in the URL
- Some SVG images are displaying and some are not HOT 3
- CacheKeyFactory used in a CollectionView causes incorrect images to load.
- ReplaceStringMap Question
- Images from URL don't show at all on iOS in Xamarin Forms 5 app HOT 1
- For MAUI see here.... HOT 3
- Image Adjustments in Xamarin
- [ISSUE] [Android] GIF animation weird behavior
- App crashes after calling ImageService.SetTaskForTarget HOT 1
- Guid inside URL is changed
- .Net 6 support HOT 4
- Incomplete downloaded image is cached.
- Images disappear on Android after pressing the (hardware) Back button HOT 1
- .Net 8 support HOT 2
- RotateTransformation does not rotate images on iOS 17 HOT 1
- Image won't load in Maui Windows app
- Inquiry about Data Collection
- On windows image download fails randomly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ffimageloading.