Exemplo n.º 1
0
 /**
  * Synchronize raw wallets
  *
  * @param context The context of Authenticator Activity
  * @param entities The list of entities
  */
 public static synchronized void syncEntities(Context context, List<BaseEntity> entities) {
   Log.d(TAG, "In EntityManager");
   for (final BaseEntity entity : entities) {
     // add or update wallet
     try {
       DatabaseHelper.getHelper(context).genericCreateOrUpdate(context, entity);
     } catch (SQLException e) {
       Log.e(TAG, "SQL error in adding " + entity.getClass().getName(), e);
     }
   }
 }
Exemplo n.º 2
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    ArrayAdapter<Report> adapter = (ArrayAdapter<Report>) getListAdapter();
    Report report = adapter.getItem(info.position);

    switch (item.getItemId()) {
      case R.id.edit_report:
        ReportEdit.callMe(ReportList.this, report);
        return true;
      case R.id.delete_report:
        try {
          ((Dao<Report, Integer>) DatabaseHelper.getHelper(this).getMyDao(Report.class))
              .delete(report);
        } catch (SQLException e) {
          e.printStackTrace();
          throw new RuntimeException(e);
        }
        adapter.remove(report);
        return true;
    }
    return super.onContextItemSelected(item);
  }