Ejemplo n.º 1
0
 @Override
 public ContentValues pack(Template entity) {
   ContentValues cv = new ContentValues();
   cv.put("name", entity.getName());
   cv.put("id_payord", entity.getIdPayord());
   cv.put("active", (entity.isActive() ? 1 : 0));
   return cv;
 }
Ejemplo n.º 2
0
 @Override
 public int compare(Template object1, Template object2) {
   if (object2.getDt_create().getTime() < object1.getDt_create().getTime()) {
     return -1;
   } else if (object2.getDt_create().getTime() > object1.getDt_create().getTime()) {
     return 1;
   } else {
     return 0;
   }
 }
Ejemplo n.º 3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;

    if (v == null) {
      v = this.layInflater.inflate(R.layout.template_row_template, null);
    }

    TextView txtAccName = (TextView) v.findViewById(R.id.rowTemplAccName);
    TextView txtSaldo = (TextView) v.findViewById(R.id.rowTemplSaldo);
    TextView txtPayName = (TextView) v.findViewById(R.id.rowTemplPayName);
    TextView txtPayCat = (TextView) v.findViewById(R.id.rowTemplPayCat);

    ImageView imgRepeat = (ImageView) v.findViewById(R.id.rowImgTemplRepeat);
    ImageView imgRemind = (ImageView) v.findViewById(R.id.rowImgTemplRemind);
    ImageView imgPlus = (ImageView) v.findViewById(R.id.rowImgTemplPlus);
    ImageView imgMinus = (ImageView) v.findViewById(R.id.rowImgTemplMinus);

    Template templ = templs.get(position);
    Payord pay = templ.getPayord(context);
    Account acc = pay.getAccount(context);
    Category cat = pay.getCategory(context);

    txtAccName.setText(acc.getNameAndCurrency());
    txtPayName.setText(pay.getName());
    txtPayCat.setText(cat.getName());

    imgRepeat.setVisibility(View.GONE);
    imgRemind.setVisibility(View.GONE);
    imgPlus.setVisibility(View.GONE);
    imgMinus.setVisibility(View.GONE);

    if (pay.isPermanent()) {
      imgRepeat.setVisibility(View.VISIBLE);
    }
    if (pay.isRemind()) {
      imgRemind.setVisibility(View.VISIBLE);
    }
    if (pay.getType() == Payord.Type.CREDIT) {
      imgPlus.setVisibility(View.VISIBLE);
    }
    if (pay.getType() == Payord.Type.DEBIT) {
      imgMinus.setVisibility(View.VISIBLE);
    }
    txtSaldo.setTextColor(
        pay.getType() == Payord.Type.DEBIT
            ? context.getResources().getColor(R.color.red)
            : context.getResources().getColor(R.color.xdark_green));
    txtSaldo.setText(Utils.intToMoney(pay.getAmount()));
    return v;
  }
Ejemplo n.º 4
0
 @Override
 public Template extractCurrent(Cursor cur) {
   Template res = new Template();
   res.setId(cur.getInt(cur.getColumnIndex("_id")));
   res.setName(cur.getString(cur.getColumnIndex("name")));
   res.setIdPayord(cur.getInt(cur.getColumnIndex("id_payord")));
   res.setActive(cur.getInt(cur.getColumnIndex("active")) == 1);
   res.setDt_create(new java.sql.Date(cur.getLong(cur.getColumnIndex("dt_create"))));
   res.setDt_update(new java.sql.Date(cur.getLong(cur.getColumnIndex("dt_update"))));
   return res;
 }