bool TryLoadBanner(string filename) { // if the file exists if (FileCache.Instance.FileExists(filename) == true) { // load it asynchronously AsyncLoader.LoadImage(filename, false, false, delegate(Bitmap imageBmp) { if (IsFragmentActive == true) { // if for some reason it loaded corrupt, remove it. if (imageBmp == null) { FileCache.Instance.RemoveFile(filename); return(false); } else { FreeImageResources( ); HeaderImage = imageBmp; ImageBanner.SetImageBitmap(HeaderImage); ImageBanner.Invalidate( ); Rock.Mobile.PlatformSpecific.Android.UI.Util.FadeView(ImageBanner, true, null); return(true); } } return(false); }); return(true); } else { return(false); } }
void SetupDisplay(View view) { // get the placeholder image in case we need it // attempt to load the image from cache. If that doesn't work, use a placeholder HeaderImage = null; bool imageExists = TryLoadBanner(HeaderImageName); if (imageExists == false) { // use the placeholder and request the image download string widthParam = string.Format("&width={0}", NavbarFragment.GetContainerDisplayWidth_Landscape( )); string requestUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL(HeaderImageURL, widthParam); FileCache.Instance.DownloadFileToCache(requestUrl, HeaderImageName, null, delegate { TryLoadBanner(HeaderImageName); }); AsyncLoader.LoadImage(PrivateGeneralConfig.NewsDetailsPlaceholder, true, false, delegate(Bitmap imageBmp) { if (IsFragmentActive == true && imageBmp != null) { HeaderImage = imageBmp; ImageBanner.SetImageBitmap(HeaderImage); ImageBanner.Invalidate( ); Rock.Mobile.PlatformSpecific.Android.UI.Util.FadeView(ImageBanner, true, null); return(true); } return(false); }); } }