Exemple #1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.saveNew:
       int can = 1;
       if (activityName.getText().toString().length() == 0) {
         can = 0;
       }
       if (activityTime.getText().toString().length() == 0) {
         can = 0;
       }
       if (can == 1) {
         fileUtils.saveContent(
             addNew.this, activityName.getText().toString(), Content.getText().toString());
         Contact contact = new Contact();
         contact.setTime(activityTime.getText().toString());
         contact.setName(activityName.getText().toString());
         myDatebaseHelper.insert(contact);
         Intent intent = new Intent(addNew.this, jishiben.class);
         startActivity(intent);
         addNew.this.finish();
       } else {
         Toast.makeText(addNew.this, "Please enter a valid time and theme", Toast.LENGTH_SHORT)
             .show();
       }
       break;
   }
 }
  public ArrayList<Contact> getAllContacts() {

    ArrayList<Contact> contactList = new ArrayList<Contact>();

    String selectQuery = "SELECT  * FROM " + TABLE_DETAILS;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    if (cursor.moveToFirst()) { // if (cursor != null)
      do {
        Contact contact = new Contact();
        contact.setName(cursor.getString(1));
        contact.setAddress(cursor.getString(4));
        contact.setPhone(cursor.getString(5));

        String interest = getInterest(cursor.getInt(0));
        contact.setInterest(interest);

        contactList.add(contact);

      } while (cursor.moveToNext());
    }
    return contactList;
  }
  public ArrayList<Contact> getCustomizedContacts(String interest, String city, String area) {

    ArrayList<Contact> contactList = new ArrayList<Contact>();

    boolean flag = true;

    String selectQuery =
        "select * from " + TABLE_DETAILS + " as a" + " natural join " + TABLE_INTEREST + " as b ";

    if (interest.compareTo("ALL") != 0) {
      if (flag) {
        selectQuery += " where ";
        flag = false;
      } else selectQuery += " and ";

      selectQuery += " a.Sr = b.sr and b.Interest = '" + interest + "'";
    }

    if (city.compareTo("ALL") != 0) {
      if (flag) {
        selectQuery += " where ";
        flag = false;
      } else selectQuery += " and ";

      selectQuery += " a.City = '" + city + "'";
    }

    if (area.compareTo("ALL") != 0) {
      if (flag) {
        selectQuery += " where ";
        flag = false;
      } else selectQuery += " and ";

      selectQuery += " a.Area = '" + area + "'";
    }

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    if (cursor.moveToFirst()) { // if (cursor != null)
      do {
        Contact contact = new Contact();
        contact.setName(cursor.getString(1));
        contact.setAddress(cursor.getString(4));
        contact.setPhone(cursor.getString(5));
        contact.setInterest(cursor.getString(6));

        contactList.add(contact);

      } while (cursor.moveToNext());
    }
    return contactList;
  }
  /** @return the existing or newly created Contact */
  public Contact ensure(String name, Contact owner, String address) {
    Contact contact = (Contact) getNameColumn().firstWhereEq(name);
    if (contact != null) return contact;
    else {
      contact = (Contact) newPersistent();
      contact.setName(name);
      contact.setOwner(owner);
      contact.setAddress(address);

      return (Contact) getNameColumn().ensure(contact);
    }
  }
 @Test
 public void testIndexedCollectionOfElements() throws Exception {
   Sale sale = new Sale();
   Contact contact = new Contact();
   contact.setName("Emmanuel");
   sale.getContacts().add(contact);
   Session s = openSession();
   s.getTransaction().begin();
   s.save(sale);
   s.flush();
   s.get(Sale.class, sale.getId());
   assertEquals(1, sale.getContacts().size());
   s.getTransaction().rollback();
   s.close();
 }
Exemple #6
0
 public void action() {
   Contact contact = new Contact();
   String name, phone;
   name = JOptionPane.showInputDialog("Ange namn");
   contact.setName(name);
   phone = JOptionPane.showInputDialog("Ange hemtelefon");
   contact.setPhone(phone);
   contact.setMobile(JOptionPane.showInputDialog("Ange mobil"));
   contact.setEmail(JOptionPane.showInputDialog("Ange mail-adress"));
   JOptionPane.showMessageDialog(null, contact.toString());
   JOptionPane.showMessageDialog(
       null,
       contact.getName()
           + "\n"
           + contact.getPhone()
           + "\n"
           + contact.getMobile()
           + "\n"
           + contact.getEmail());
 }
  private void getUpdatedContactInfo(Contact currentContact) {

    EditText editText = (EditText) this.findViewById(R.id.contactName);
    currentContact.setName(editText.getText().toString());

    EditText aliasText = (EditText) this.findViewById(R.id.alias);
    currentContact.setAlias(aliasText.getText().toString());

    EditText businessText = (EditText) this.findViewById(R.id.business_edit);
    currentContact.setBusiness(businessText.getText().toString());

    final EditText phoneText = (EditText) this.findViewById(R.id.phone_edit);
    final Spinner phoneOptions = (Spinner) this.findViewById(R.id.phone_spinner);
    currentContact.setPhone(new HashMap<String, String>());
    currentContact
        .getPhone()
        .put(phoneOptions.getSelectedItem().toString(), phoneText.getText().toString());

    final EditText emailText = (EditText) this.findViewById(R.id.email_edit);
    final Spinner emailOptions = (Spinner) this.findViewById(R.id.email_spinner);
    currentContact.setEmail(new HashMap<String, String>());
    currentContact
        .getEmail()
        .put(emailOptions.getSelectedItem().toString(), emailText.getText().toString());

    final EditText streetText = (EditText) this.findViewById(R.id.address1_edit);
    final EditText cityText = (EditText) this.findViewById(R.id.address_city_edit);
    final EditText zipText = (EditText) this.findViewById(R.id.zip_code_edit);
    final Spinner stateOptions = (Spinner) this.findViewById(R.id.state_spinner);
    final Spinner addressOptions = (Spinner) this.findViewById(R.id.address_spinner);
    currentContact.setAddresses(new HashMap<String, Address>());
    currentContact
        .getAddresses()
        .put(
            addressOptions.getSelectedItem().toString(),
            new Address(
                streetText.getText().toString(),
                cityText.getText().toString(),
                stateOptions.getSelectedItem().toString(),
                zipText.getText().toString()));
  }
Exemple #8
0
  // Getting All Contacts
  public List<Contact> getAllContactsName() {
    List<Contact> contactList = new ArrayList<Contact>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + TABLE_CONTACTS;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
      do {
        Contact contact = new Contact();
        contact.setName(cursor.getString(1));
        // Adding contact to list
        contactList.add(contact);
      } while (cursor.moveToNext());
    }

    // return contact list
    return contactList;
  }
 public void updateContactList() {
   for (RosterEntry entry : mConnectionManager.getEntries()) {
     String email = entry.getUser();
     if (!StringUtils.parseServer(email).equals(mConnectionManager.getDomain())) continue;
     if (email.equals(mConnectionManager.getUsernameEmail())) continue;
     Presence presence = mConnectionManager.getPresence(email);
     if (presence == null)
       return; // if disconnection happened we might get null, and in such case this method
     // execution can stop
     Contact contact;
     if (mContactsMap.containsKey(email)) {
       contact = mContactsList.get(getContactPosition(email));
       contact.update(presence);
     } else {
       contact = new Contact(presence);
       contact.setName(entry.getName());
       mContactsList.add(contact);
       mContactsMap.put(email, contact);
     }
   }
   Log.i(TAG, "updateContactList: " + mContactsList.toString());
   Collections.sort(mContactsList);
 }
Exemple #10
0
  public static void main(String[] args) {

    // Prepare the Xero Client
    XeroClient xeroClient = null;
    try {
      XeroClientProperties clientProperties = new XeroClientProperties();
      clientProperties.load(new FileInputStream("./xeroApi.properties"));
      xeroClient = new XeroClient(clientProperties);
    } catch (IOException ex) {
      ex.printStackTrace();
    }

    // Retrieve a list of Invoices
    try {

      ArrayOfInvoice arrayOfExistingInvoices = xeroClient.getInvoices();
      if (arrayOfExistingInvoices != null && arrayOfExistingInvoices.getInvoice() != null) {

        for (Invoice invoice : arrayOfExistingInvoices.getInvoice()) {
          System.out.println("Invoice: " + invoice.getInvoiceID());
        }

        // Retrieve an invoice as a PDF
        // (can be used to retrieve json too, just change application/pdf to application/json)
        if (!arrayOfExistingInvoices.getInvoice().isEmpty()) {
          xeroClient.getInvoiceAsPdf(arrayOfExistingInvoices.getInvoice().get(0).getInvoiceID());
        }
      }

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Create an Invoice
    Invoice invoice = null;
    try {

      ArrayOfInvoice arrayOfInvoice = new ArrayOfInvoice();
      List<Invoice> invoices = arrayOfInvoice.getInvoice();
      invoice = new Invoice();

      Contact contact = new Contact();
      contact.setName("Jane Smith");
      contact.setEmailAddress("*****@*****.**");
      invoice.setContact(contact);

      ArrayOfLineItem arrayOfLineItem = new ArrayOfLineItem();
      List<LineItem> lineItems = arrayOfLineItem.getLineItem();
      LineItem lineItem = new LineItem();
      lineItem.setAccountCode("200");
      BigDecimal qty = new BigDecimal("2");
      lineItem.setQuantity(qty);
      BigDecimal amnt = new BigDecimal("50.00");
      lineItem.setUnitAmount(amnt);
      lineItem.setDescription("Programming books");
      lineItem.setLineAmount(qty.multiply(amnt));
      lineItems.add(lineItem);
      invoice.setLineItems(arrayOfLineItem);

      invoice.setDate(Calendar.getInstance());
      Calendar due = Calendar.getInstance();
      due.set(due.get(Calendar.YEAR), due.get(Calendar.MONTH) + 1, 20);
      invoice.getLineAmountTypes().add("Inclusive");
      invoice.setDueDate(due);
      invoice.setInvoiceNumber("INV-API-001");
      invoice.setType(InvoiceType.ACCREC);
      invoice.setStatus(InvoiceStatus.AUTHORISED);
      invoices.add(invoice);

      xeroClient.postInvoices(arrayOfInvoice);
    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Create a new Contact
    try {

      ArrayOfContact arrayOfContact = new ArrayOfContact();
      List<Contact> contacts = arrayOfContact.getContact();

      Contact contact1 = new Contact();
      contact1.setName("John Smith");
      contact1.setEmailAddress("*****@*****.**");
      contacts.add(contact1);
      xeroClient.postContacts(arrayOfContact);

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Add a payment to an exisiting Invoice
    try {

      Invoice invoice1 = new Invoice();
      invoice1.setInvoiceNumber("INV-0038");

      Account account = new Account();
      account.setCode("090");

      Payment payment = new Payment();
      payment.setAccount(account);
      payment.setInvoice(invoice);
      payment.setAmount(new BigDecimal("20.00"));
      payment.setDate(Calendar.getInstance());

      ArrayOfPayment arrayOfPayment = new ArrayOfPayment();
      List<Payment> payments = arrayOfPayment.getPayment();
      payments.add(payment);

      xeroClient.postPayments(arrayOfPayment);

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }
  }