Permalink
Browse files

Updated AchievementElement.

  • Loading branch information...
1 parent 0f8d6d7 commit 50fff59a83c6616b577b144878826ead6aec5588 @CartBlanche CartBlanche committed Sep 26, 2011
Showing with 38 additions and 73 deletions.
  1. +38 −73 MonoDroid.Dialog/AchievementElement.cs
@@ -1,101 +1,66 @@
using System;
using Android.Content;
+using Android.Graphics;
using Android.Views;
using Android.Widget;
namespace MonoDroid.Dialog
{
- public class CheckboxElement : Element, CompoundButton.IOnCheckedChangeListener
+ public class AchievementElement : Element
{
- public bool Value
- {
- get { return _val; }
- set
- {
- bool emit = _val != value;
- _val = value;
- if(_checkbox != null && _checkbox.Checked != _val)
- _checkbox.Checked = _val;
- else if (emit && ValueChanged != null)
- ValueChanged(this, EventArgs.Empty);
- }
- }
- private bool _val;
+
+ public string Description
+ {
+ get;
+ set;
+ }
- public string SubCaption
+ public int PercentageComplete
{
- get
- {
- return subCap;
- }
- set
- {
- subCap = value;
- }
+ get;
+ set;
}
- private string subCap;
- public event EventHandler ValueChanged;
+ public Bitmap AchievementImage
+ {
+ get;
+ set;
+ }
- private CheckBox _checkbox;
+
+ private ImageView _achivementImage;
private TextView _caption;
- private TextView _subCaption;
+ private TextView _description;
+ private TextView _percentageComplete;
public string Group;
-
- public CheckboxElement(string caption)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = false;
- }
-
- public CheckboxElement(string caption, bool value)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = value;
- }
- public CheckboxElement(string caption, bool value, string subCaption, string group)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldsubright)
- {
- Value = value;
- Group = group;
- SubCaption = subCaption;
- }
-
- public CheckboxElement(string caption, bool value, string group)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = value;
- Group = group;
- }
-
- public CheckboxElement(string caption, bool value, string group, int layoutId)
- : base(caption, layoutId)
- {
- Value = value;
- Group = group;
+ public AchievementElement(string caption, string description, int percentageComplete, Bitmap achievementImage)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_achievements)
+ {
+ Description = description;
+ PercentageComplete = percentageComplete;
+ AchievementImage = achievementImage;
}
public override View GetView(Context context, View convertView, ViewGroup parent)
{
- View checkboxView;
- View view = DroidResources.LoadBooleanElementLayout(context, convertView, parent, LayoutId, out _caption, out _subCaption, out checkboxView);
+ View view = DroidResources.LoadAchievementsElementLayout(context, convertView, parent, LayoutId, out _caption, out _description, out _percentageComplete, out _achivementImage);
if (view != null)
{
- _caption.Text = Caption;
- _checkbox = checkboxView as CheckBox;
- _checkbox.SetOnCheckedChangeListener(null);
- _checkbox.Checked = Value;
- _checkbox.SetOnCheckedChangeListener(this);
- _subCaption.Text = SubCaption;
+ _caption.Text = Caption;
+ _description.Text = Description;
+ _percentageComplete.Text = PercentageComplete.ToString();
+ if ( AchievementImage != null )
+ {
+ _achivementImage.SetImageBitmap(AchievementImage);
+ }
+ }
+ else
+ {
+ Android.Util.Log.Error("AchievementElement", "GetView failed to load template view");
}
return view;
}
-
- public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
- {
- this.Value = isChecked;
- }
}
}

0 comments on commit 50fff59

Please sign in to comment.