Profile.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package de.tudarmstadt.informatik.hostage.model;
  2. import android.graphics.Bitmap;
  3. import android.graphics.BitmapFactory;
  4. import android.graphics.drawable.BitmapDrawable;
  5. import android.graphics.drawable.Drawable;
  6. import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
  7. /**
  8. * @author Alexander Brakowski
  9. * @created 14.01.14 18:04
  10. */
  11. public class Profile {
  12. public String mText;
  13. public String mLabel;
  14. public int mId;
  15. public boolean mActivated;
  16. public Bitmap mIcon;
  17. public String mIconPath;
  18. public boolean mIsBackVisible = false;
  19. public boolean mEditable = false;
  20. public Profile(){
  21. this.mEditable = true;
  22. this.mActivated = false;
  23. this.mId = -1;
  24. }
  25. public Profile(int id, String label, String text, Bitmap icon, boolean editable){
  26. this.mId = id;
  27. this.mLabel = text;
  28. this.mText = label;
  29. this.mActivated = false;
  30. this.mIcon = icon;
  31. this.mEditable = editable;
  32. }
  33. public Profile(int id, String label, String text, int icon, boolean editable){
  34. this(id, text, label, BitmapFactory.decodeResource(MainActivity.context.getResources(), icon), editable);
  35. }
  36. public Profile(int id, String label, String text, String iconPath, boolean editable){
  37. this.mId = id;
  38. this.mLabel = label;
  39. this.mText = text;
  40. this.mActivated = false;
  41. this.mIconPath = iconPath;
  42. this.mEditable = editable;
  43. }
  44. public void setIcon(Bitmap bitmap){
  45. this.mIcon = bitmap;
  46. }
  47. public void setIcon(int icon){
  48. this.mIcon = BitmapFactory.decodeResource(MainActivity.context.getResources(), icon);
  49. }
  50. public Bitmap getIconBitmap(){
  51. if(this.mIcon != null) return mIcon;
  52. if(this.mIconPath != null){
  53. BitmapFactory.Options options = new BitmapFactory.Options();
  54. options.inPreferredConfig = Bitmap.Config.ARGB_8888;
  55. Bitmap bitmap = BitmapFactory.decodeFile(this.mIconPath, options);
  56. return bitmap;
  57. }
  58. return null;
  59. }
  60. public Drawable getIconDrawable(){
  61. return new BitmapDrawable(getIconBitmap());
  62. }
  63. public boolean isEditable(){
  64. return this.mEditable;
  65. }
  66. public Profile cloneProfile(){
  67. return new Profile(mId, mLabel, mText, mIcon, mEditable);
  68. }
  69. }