Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(FRAG_TAG) == null) {

      FragmentTransaction ft = fm.beginTransaction();
      PaymentGroup group = null;
      if (paymentGroupId != -1) {
        try {
          group = paymentGroupDao.queryForId(paymentGroupId);
        } catch (SQLException e) {
          Logger.e(e);
        }
      }
      if (group == null) {
        group = paymentGroupDao.queryForAllSorted().get(0);
      }
      switch (group.state) {
        case PaymentGroup.STATE_NONE:
          fragment = InputFragment_.builder().paymentGroupId(group.id).build();
          break;
        case PaymentGroup.STATE_CALCULATED:
          fragment = ReceiptFragment_.builder().paymentGroupId(group.id).build();
          break;
      }

      ft.replace(R.id.contents, fragment, FRAG_TAG);
      ft.commit();
    }
  }
Пример #2
0
 <T> void deleteByPaymentGroup(Dao<T, Long> dao, PaymentGroup group) {
   DeleteBuilder<T, Long> builder = dao.deleteBuilder();
   try {
     builder.where().eq("paymentGroup_id", group.id);
     dao.delete(builder.prepare());
   } catch (SQLException e) {
     Logger.e(e);
   }
 }
Пример #3
0
  @Background
  void deletePaymentGroup(PaymentGroup group) {
    try {
      deleteByPaymentGroup(relationDao, group);
      deleteByPaymentGroup(paymentDao, group);
      deleteByPaymentGroup(attendeeDao, group);
      paymentGroupDao.delete(group);

      List<PaymentGroup> paymentGroups = paymentGroupDao.queryForAllSorted();
      setUpListview(paymentGroups);
      EventBus.getDefault().post(new SetPaymentGroupEvent(paymentGroups.get(0)));
    } catch (SQLException e) {
      Logger.e(e);
    }
  }
Пример #4
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.create_payment_group:
       {
         try {
           PaymentGroup group = paymentGroupDao.createDefault(this);
           paymentDao.addPaymentTo(group);
           if (group.payments == null) {
             paymentGroupDao.refresh(group);
           }
         } catch (SQLException e) {
           Logger.e(e);
         }
         break;
       }
   }
 }