User.java revision e0b6d649e4970925ae24ed707ec0cad82b393fd1
1package com.android.example.bindingdemo.vo; 2 3import android.binding.Bindable; 4import android.graphics.Color; 5 6import com.android.databinding.library.AbsObservable; 7 8import java.util.Objects; 9 10public class User extends AbsObservable { 11 @Bindable 12 private String name; 13 @Bindable 14 private String lastName; 15 @Bindable 16 private int photoResource = 0; 17 private int favoriteColor = Color.RED; 18 @Bindable 19 private int group; 20 21 public static final int TOOLKITTY = 1; 22 public static final int ROBOT = 2; 23 24 public User(String name, String lastName, int photoResource, int group) { 25 this.name = name; 26 this.lastName = lastName; 27 this.photoResource = photoResource; 28 this.group = group; 29 } 30 31 public void setGroup(int group) { 32 if (this.group == group) { 33 return; 34 } 35 this.group = group; 36 notifyChange(android.binding.BR.group); 37 } 38 39 public int getGroup() { 40 return group; 41 } 42 43 public String getName() { 44 return name; 45 } 46 47 public void setName(String name) { 48 if (Objects.equals(name, this.name)) { 49 return; 50 } 51 this.name = name; 52 notifyChange(android.binding.BR.name); 53 } 54 55 public String getLastName() { 56 return lastName; 57 } 58 59 public void setLastName(String lastName) { 60 if (Objects.equals(lastName, this.lastName)) { 61 return; 62 } 63 this.lastName = lastName; 64 notifyChange(android.binding.BR.lastName); 65 } 66 67 public int getPhotoResource() { 68 return photoResource; 69 } 70 71 public void setPhotoResource(int photoResource) { 72 if (this.photoResource == photoResource) { 73 return; 74 } 75 this.photoResource = photoResource; 76 notifyChange(android.binding.BR.photoResource); 77 } 78 79 public int getFavoriteColor() { 80 return favoriteColor; 81 } 82} 83