egslava

EViewGroup implements ContentListItem

May 19th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. @EViewGroup(R.layout.item_drug)
  2. public class DrugItem extends LinearLayout implements ContentListItem<Void>{
  3.  
  4.     // конструкторы просто нужны - без них не скомпилится. Желательно делать два, хотя не уверен
  5.     public DrugItem(Context context) { super(context); }
  6.     public DrugItem(Context context, AttributeSet attrs) { super(context, attrs); }
  7.  
  8.     // нужные тебе вьюхи - всё как обычно
  9.     @ViewById   TextView    name, description, cost, oldCost;
  10.     @ViewById   ImageView   cartIcon;
  11.  
  12.     @OrmLiteDao(helper = DBHelper.class)
  13.     Dao<Drug, Integer> dao;
  14.  
  15.  
  16.     // класс, который биндит вьюху на основе курсора
  17.     @Override public void bind (Cursor cursor, ListView list) {
  18.         bind ( Models.fromCursor(cursor, dao), list, cursor.getPosition() );
  19.     }
  20.  
  21.     // тут я типа байндю класс на вью
  22.     public void bind(Drug drug, Void params, int position) {
  23.         this.drug = drug;
  24.  
  25.         map(name, drug.name);
  26.         mapi(description, drug.description);
  27.         map(cost, drug.cost);
  28.         map(oldCost, drug.oldCost);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment