bool TryLoadCachedImageAsync(NewsEntry entry, string imageName) { // if it exists, spawn a thread to load and decode it if (FileCache.Instance.FileExists(imageName) == true) { AsyncLoader.LoadImage(imageName, false, false, delegate(Bitmap imageBmp) { if (FragmentActive == true) { // if for some reason it loaded corrupt, remove it. if (imageBmp == null) { FileCache.Instance.RemoveFile(imageName); return(false); } else { // we might be replacing an existing image, so be sure to dispose our reference to it. if (entry.Image != null) { entry.Image.Dispose( ); entry.Image = null; } // flag that we do HAVE the image entry.Image = imageBmp; RefreshListView( ); return(true); } } return(false); }); return(true); } else { return(false); } }
void SetupDisplay(View view) { // setup our message list view MessagesListView = view.FindViewById <ListView>(Resource.Id.notes_details_list); MessagesListView.SetOnTouchListener(this); MessagesListView.Divider = null; // setup the messages list MessagesListView.Adapter = new NotesDetailsArrayAdapter(this); // load the placeholder and series image SeriesBillboard = null; bool imageExists = TryLoadBanner(NotesTask.FormatBillboardImageName(Series.SeriesName)); if (imageExists == false) { //string widthParam = string.Format( "&width={0}", NavbarFragment.GetContainerDisplayWidth_Landscape( ) ); // use the placeholder and request the image download FileCache.Instance.DownloadFileToCache(Series.BillboardUrl, NotesTask.FormatBillboardImageName(Series.SeriesName), null, delegate { TryLoadBanner(NotesTask.FormatBillboardImageName(Series.SeriesName)); }); AsyncLoader.LoadImage(PrivateNoteConfig.NotesMainPlaceholder, true, false, delegate(Bitmap imageBmp) { if (FragmentActive == true && imageBmp != null) { PlaceholderImage = imageBmp; RefreshList( ); return(true); } return(false); }); } }
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); }); } }
void SetupDisplay( ) { // load the top banner AsyncLoader.LoadImage(PrivateConnectConfig.MainPageHeaderImage, true, true, delegate(Bitmap imageBmp) { if (FragmentActive == true && imageBmp != null) { Billboard = imageBmp; ((ListAdapter)ListView.Adapter).NotifyDataSetChanged( ); return(true); } return(false); }); // load the thumbnails for (int i = 0; i < GetEngagedEntries.Count; i++) { int imageIndex = i; AsyncLoader.LoadImage(GetEngagedEntries[i].ImageName, true, false, delegate(Bitmap imageBmp) { if (FragmentActive == true && imageBmp != null) { GetEngagedBillboards[imageIndex] = imageBmp; ((ListAdapter)ListView.Adapter).NotifyDataSetChanged( ); return(true); } return(false); }); } }
void SetupDisplay(View view) { ListView = view.FindViewById <ListView>(Resource.Id.news_primary_list); ListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { // in portrait mode, it's fine to use the list // for click detection OnClick(e.Position); }; ListView.SetOnTouchListener(this); ListView.Adapter = new PortraitNewsArrayAdapter(this); // load the placeholder image AsyncLoader.LoadImage(PrivateGeneralConfig.NewsMainPlaceholder, true, false, delegate(Bitmap imageBmp) { if (FragmentActive == true && imageBmp != null) { Placeholder = imageBmp; imageBmp = null; RefreshListView( ); return(true); } return(false); }); // here we're simply trying to load the images that are already // stored for (int i = 0; i < News.Count; i++) { TryLoadCachedImageAsync(News[i], News[i].News.ImageName); } }
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 (FragmentActive == true) { // if for some reason it loaded corrupt, remove it. if (imageBmp == null) { FileCache.Instance.RemoveFile(filename); return(false); } else { SeriesBillboard = imageBmp; RefreshList( ); return(true); } } return(false); }); return(true); } else { return(false); } }