/// <summary> /// temporarily disabled this in favor of the LoadImageDirectly method /// until i figure out why this isn't always called-back /// </summary> public void UpdatedImage(Uri uri) { MWCApp.LogDebug("IGNORING... speaker.ImageUrl CALLBACK"); //var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, this); //RunOnUiThread(() => { // imageview.SetImageDrawable(drawable); //}); }
protected override void OnStart() { base.OnStart(); MWCApp.LogDebug("EXHIBITORS OnStart"); BL.Managers.UpdateManager.UpdateExhibitorsStarted += HandleUpdateStarted; BL.Managers.UpdateManager.UpdateExhibitorsFinished += HandleUpdateFinished; }
protected override void OnStart() { base.OnStart(); MWCApp.LogDebug("UPDATELOADING OnStart"); BL.Managers.UpdateManager.UpdateStarted += HandleUpdateStarted; BL.Managers.UpdateManager.UpdateFinished += HandleUpdateFinished; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SpeakerDetailsScreen); var id = Intent.GetIntExtra("SpeakerID", -1); if (id >= 0) { speaker = BL.Managers.SpeakerManager.GetSpeaker(id); if (speaker != null) { FindViewById <TextView>(Resource.Id.NameTextView).Text = speaker.Name; FindViewById <TextView>(Resource.Id.PositionTextView).Text = speaker.Title; FindViewById <TextView>(Resource.Id.CompanyTextView).Text = speaker.Company; imageview = FindViewById <ImageView>(Resource.Id.SpeakerImageView); if (!String.IsNullOrEmpty(speaker.Bio)) { FindViewById <TextView>(Resource.Id.Bio).Text = speaker.Bio; } else { var tv = FindViewById <TextView>(Resource.Id.Bio); tv.Text = "no speaker bio available"; } if (!string.IsNullOrEmpty(speaker.ImageUrl)) { var uri = new Uri(speaker.ImageUrl); MWCApp.LogDebug("speaker.ImageUrl " + speaker.ImageUrl); try { var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, this); if (drawable != null) // use it { imageview.SetImageDrawable(drawable); } else // we're just going to grab it ourselves and not wait for the callback from ImageLoader { LoadImageDirectly(uri); } } catch (Exception ex) { MWCApp.LogDebug(ex.ToString()); } } else { imageview.SetImageResource(Resource.Drawable.Icon); } } else // shouldn't happen... { FindViewById <TextView>(Resource.Id.TitleTextView).Text = "Speaker not found: " + id; } } }
void HandleUpdateFinished(object sender, EventArgs e) { MWCApp.LogDebug("EXHIBITORS HandleUpdateFinished"); RunOnUiThread(() => { if (progress != null) { progress.Hide(); } PopulateTable(); }); }
protected override void OnStop() { MWCApp.LogDebug("EXHIBITORS OnStop"); if (progress != null) { progress.Hide(); } BL.Managers.UpdateManager.UpdateExhibitorsStarted -= HandleUpdateStarted; BL.Managers.UpdateManager.UpdateExhibitorsFinished -= HandleUpdateFinished; base.OnStop(); }
protected override void OnStop() { MWCApp.LogDebug("UPDATELOADING OnStop"); if (progress != null) { progress.Hide(); } BL.Managers.UpdateManager.UpdateStarted -= HandleUpdateStarted; BL.Managers.UpdateManager.UpdateFinished -= HandleUpdateFinished; base.OnStop(); }
public override View GetView(int position, View convertView, ViewGroup parent) { // Get our object for this position var item = speakers[position]; //Try to reuse convertView if it's not null, otherwise inflate it from our item layout // This gives us some performance gains by not always inflating a new view // This will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell() var view = (convertView ?? context.LayoutInflater.Inflate( Resource.Layout.SpeakerListItem, parent, false)) as LinearLayout; // Find references to each subview in the list item's view var bigTextView = view.FindViewById <TextView>(Resource.Id.NameTextView); var smallTextView = view.FindViewById <TextView>(Resource.Id.CompanyTextView); var imageview = view.FindViewById <ImageView>(Resource.Id.SpeakerImageView); //Assign this item's values to the various subviews bigTextView.SetText(speakers[position].Name, TextView.BufferType.Normal); smallTextView.SetText(speakers[position].Title + ", " + this.speakers[position].Company, TextView.BufferType.Normal); if (!string.IsNullOrEmpty(speakers[position].ImageUrl)) { var uri = new Uri(speakers[position].ImageUrl); imageview.Tag = uri.ToString(); var iw = new AL.ImageWrapper(imageview, context); try { MonoTouch.Dialog.Utilities.ImageLoader.LogDebug("gv + " + position + " " + MonoTouch.Dialog.Utilities.ImageLoader.ImageName(uri.AbsoluteUri)); Log.Debug("MWC1", "gv + " + position + " " + MonoTouch.Dialog.Utilities.ImageLoader.ImageName(uri.AbsoluteUri)); var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, iw); if (drawable == null) { imageview.SetImageResource(Resource.Drawable.Icon); } else { imageview.SetImageDrawable(drawable); } } catch (Exception ex) { MonoTouch.Dialog.Utilities.ImageLoader.Purge(); // have seen outofmemory here MWCApp.LogDebug("SPEAKERS " + ex.ToString()); } } else { imageview.SetImageResource(Resource.Drawable.Icon); } //Finally return the view return(view); }
protected override void PopulateTable() { MWCApp.LogDebug("SPEAKERS PopulateTable"); if (speakers == null || speakers.Count == 0) { titleTextView.Text = "SPEAKERS"; speakers = MWC.BL.Managers.SpeakerManager.GetSpeakers(); // create our adapter speakerList = new MWC.Adapters.SpeakerListAdapter(this, speakers); //Hook up our adapter to our ListView speakerListView.Adapter = this.speakerList; } }
public override View GetView(int position, View convertView, ViewGroup parent) { // Get our object for this position var item = this.exhibitors[position]; //Try to reuse convertView if it's not null, otherwise inflate it from our item layout // This gives us some performance gains by not always inflating a new view // This will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell() var view = (convertView ?? this.context.LayoutInflater.Inflate( Resource.Layout.ExhibitorListItem, parent, false)) as LinearLayout; // Find references to each subview in the list item's view var nameTextView = view.FindViewById <TextView>(Resource.Id.NameTextView); var countryTextView = view.FindViewById <TextView>(Resource.Id.CountryTextView); var locationTextView = view.FindViewById <TextView>(Resource.Id.LocationTextView); var imageview = view.FindViewById <ImageView>(Resource.Id.ExhibitorImageView); //Assign this item's values to the various subviews nameTextView.SetText(this.exhibitors[position].Name, TextView.BufferType.Normal); countryTextView.SetText(this.exhibitors[position].City + ", " + this.exhibitors[position].Country, TextView.BufferType.Normal); locationTextView.SetText(this.exhibitors[position].Locations, TextView.BufferType.Normal); var uri = new Uri(this.exhibitors[position].ImageUrl); var iw = new AL.ImageWrapper(imageview, context); imageview.Tag = uri.ToString(); try { var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, iw); if (drawable != null) { imageview.SetImageDrawable(drawable); } } catch (Exception ex) { MonoTouch.Dialog.Utilities.ImageLoader.Purge(); // have seen outofmemory here MWCApp.LogDebug("EXHIBITORS " + ex.ToString()); } //Finally return the view return(view); }
protected override void OnCreate(Bundle bundle) { MWCApp.LogDebug("SPEAKERS OnCreate"); base.OnCreate(bundle); // set our layout to be the home screen SetContentView(Resource.Layout.SpeakersScreen); //Find our controls speakerListView = FindViewById <ListView>(Resource.Id.SpeakerList); titleTextView = FindViewById <TextView>(Resource.Id.TitleTextView); // wire up task click handler if (speakerListView != null) { speakerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { var speakerDetails = new Intent(this, typeof(SpeakerDetailsScreen)); speakerDetails.PutExtra("SpeakerID", speakers[e.Position].ID); StartActivity(speakerDetails); }; } }
protected override void OnResume() { MWCApp.LogDebug("EXHIBITORS OnResume"); base.OnResume(); if (BL.Managers.UpdateManager.IsUpdatingExhibitors) { MWCApp.LogDebug("EXHIBITORS OnResume IsUpdating"); if (progress == null) { progress = ProgressDialog.Show(this, "Loading", "Please Wait...", true); } } else { MWCApp.LogDebug("EXHIBITORS OnResume PopulateTable"); if (progress != null) { progress.Hide(); } PopulateTable(); } }
public void LoadImageDirectly(Uri uri) { var webClient = new WebClient(); MWCApp.LogDebug("Get speaker image directly, bypassing the ImageLoader which is taking too long"); webClient.DownloadDataCompleted += (sender, e) => { try { //var image = new global::Android.Graphics.Drawables.BitmapDrawable(bitmap); var byteArray = e.Result; MemoryStream ms = new MemoryStream(byteArray, 0, byteArray.Length); ms.Write(byteArray, 0, byteArray.Length); ms.Position = 0; var d = new global::Android.Graphics.Drawables.BitmapDrawable(ms); RunOnUiThread(() => { MWCApp.LogDebug("DETAILS speaker.ImageUrl"); imageview.SetImageDrawable(d); }); } catch (Exception ex) { MWCApp.LogDebug("Image error: " + ex); } }; webClient.DownloadDataAsync(uri); }
protected override void OnResume() { Console.WriteLine("UPDATELOADING OnResume"); base.OnResume(); if (BL.Managers.UpdateManager.IsUpdating) { MWCApp.LogDebug("UPDATELOADING OnResume IsUpdating"); if (progress == null) { progress = ProgressDialog.Show(this, "Loading", "Please Wait...", true); } } else { MWCApp.LogDebug("UPDATELOADING OnResume PopulateTable"); if (progress != null) { progress.Hide(); } PopulateTable(); } }
void HandleUpdateStarted(object sender, EventArgs e) { MWCApp.LogDebug("EXHIBITORS HandleUpdateStarted"); }
void HandleUpdateStarted(object sender, EventArgs e) { MWCApp.LogDebug("UPDATELOADING HandleUpdateStarted"); }