Refine search
private Contact from(io.swagger.annotations.Contact contactAnnotation) { Contact contact = new Contact() .name(emptyToNull(contactAnnotation.name())) .email(emptyToNull(contactAnnotation.email())) .url(emptyToNull(contactAnnotation.url())); if (contact.getName() == null && contact.getEmail() == null && contact.getUrl() == null) { contact = null; } return contact; }
ArrayList<Contact> data = new ArrayList<Contact>(); mJohn = new Contact("John", "+34123456789", "uri"); mJane = new Contact("Jane", "+34111222333", "uri"); data.add(mJohn); data.add(mJane); assertEquals("John was expected.", mJohn.getName(), ((Contact) mAdapter.getItem(0)).getName()); assertNotNull("Photo ImageView is null. ", photo); assertEquals("Names doesn't match.", mJohn.getName(), name.getText()); assertEquals("Numbers doesn't match.", mJohn.getNumber(), number.getText());
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) { Contact contact = params.contact; if (isNotBlank(contact.getName()) || isNotBlank(contact.getEmail())) { markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(Labels.CONTACT_INFORMATION)); MarkupDocBuilder paragraphBuilder = copyMarkupDocBuilder(markupDocBuilder); if (isNotBlank(contact.getName())) { paragraphBuilder.italicText(labels.getLabel(Labels.CONTACT_NAME)) .textLine(COLON + contact.getName()); } if (isNotBlank(contact.getEmail())) { paragraphBuilder.italicText(labels.getLabel(Labels.CONTACT_EMAIL)) .textLine(COLON + contact.getEmail()); } markupDocBuilder.paragraph(paragraphBuilder.toString(), true); } return markupDocBuilder; }
@Test public void testVersionInfoComponent() throws URISyntaxException { Contact contact = new Contact().name("TestName").email("test@test.de"); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new ContactInfoComponent(context).apply(markupDocBuilder, ContactInfoComponent.parameters( contact, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); } }
public List<Contact> getAllContacts() { 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.setID(Integer.parseInt(cursor.getString(0))); contact.setName(cursor.getString(1)); contact.setPhoneNumber(cursor.getString(2)); // Adding contact to list contactList.add(contact); } while (cursor.moveToNext()); } // return contact list return contactList; }
public void getAllContacts(ContentResolver cr) { Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while (phones.moveToNext()) { long id = phones.getLong(phones.getColumnIndex(ContactsContract.Data._ID)); String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); nameList.add(name); phoneList.add(phoneNumber); contactList.add(new Contact(id, name, phoneNumber)); } phones.close(); }
public void addContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.getName()); // Contact Name values.put(KEY_PH_NO, contact.getPhoneNumber()); // Contact Phone Number // Inserting Row db.insert(TABLE_CONTACTS, null, values); db.close(); // Closing database connection }
updateContact() // Updating single contact public int updateContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.getName()); values.put(KEY_PH_NO, contact.getPhoneNumber()); // updating row return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?", new String[] { String.valueOf(contact.getID()) }); }
public List<Contact> findContactsByAge() { List<Contact> contacts = new ArrayList<String>(); final String query = "SELECT * FROM contact c " " WHERE c.age > 18 AND " " ORDER BY c.name"; final Cursor cursor = database.rawQuery(query, null); cursor.moveToFirst(); while (!cursor.isAfterLast()) { Contact contact = new Contact(); contact.setName(cursor.getString(0)); contact.setAge(cursor.getString(1)); contacts.add(contact); cursor.moveToNext(); } cursor.close(); return contacts; }
private Contact fetchAndBuildContact(Context ctx, Uri uriContact){ // Getting cursorLookUpKey because contacts ID may not be correct all the time. Cursor cursorLookUpKey = ctx.getContentResolver().query(uriContact, new String[]{ContactsContract.Data.LOOKUP_KEY}, null, null, null); Contact contact = null; String lookupKey = null; if (cursorLookUpKey.moveToFirst()) { lookupKey = cursorLookUpKey.getString(cursorLookUpKey.getColumnIndex(ContactsContract.Data.LOOKUP_KEY)); if(null != lookupKey ){ contact = new Contact(); contact = buildConactPhoneDetails(lookupKey, ctx, contact); contact = buildEmailDetails(lookupKey, ctx, contact); contact = buildAddressDetails(lookupKey, ctx, contact); } } cursorLookUpKey.close(); return contact; }
public List<Contact> getAllContacts() { List<Contact> contactList = new ArrayList<Contact>(); try { String selectQuery = "SELECT * FROM " + TABLE_NAME+ " ORDER BY " + NAME + "ASC"; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor != null && cursor.getCount() > 0) { if (cursor.moveToFirst()) { do { Contact contact = new Contact(); contact.setID(Integer.parseInt(cursor.getString(0))); contact.setName(cursor.getString(1)); contact.setPhone(cursor.getString(2)); contactList.add(contact); } while (cursor.moveToNext()); } } } catch (Exception e) { e.printStackTrace(); } return contactList; }
private ContactList getDetails(){ ContactList contactList = new ContactList(RequestStatus.CONTACT_LIST); Uri uri = contactsContract.CommonDataKinds.Phone.CONTENT_URI; ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; Cursor names = getContentResolver().query(uri, projection, null, null, null); int indexName = names.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); int indexNumber = names.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); names.moveToFirst(); do { String name = names.getString(indexName); Log.e("Name new:", name); String number = names.getString(indexNumber); Log.e("Number new:","::"+number); contactList.addContact(new Contact(name,number)); } while (names.moveToNext()); return contactList; }
Cursor cur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); cur.moveToPosition(-1); boolean addNewContact; if (cur.getCount() > 0) { while (cur.moveToNext()) { String thumb = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI)); String id = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID)); String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); if (allContacts==null) allContacts = new Vector<Contact>(); addNewContact = true; for (Contact addedC:allContacts){ if (addedC.id.equals(id)) addNewContact = false; } if (addNewContact) { Contact c = new Contact(name, id); if (thumb != null) c.setThumb(cr, thumb); allContacts.add(c); } } }
ArrayList<Contact> listContacts = new ArrayList<Contact>(); // Select All Query String selectQuery = "SELECT * FROM " + CONTACT ; mDbHelper.getWritableDatabase(); Cursor cursor = mDb.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Contact contact = new Contact(); contact.setId((cursor.getLong(0))); contact.setName((cursor.getString(1))); contact.setDept(cursor.getString(2)); listContacts.add(note); } while (cursor.moveToNext()); } return listContacts;
//... db.execSQL(CREATE_CONTACTS_TABLE); ArrayList<Contact> toInsert = new ArrayList<Contact>(); toInsert.add(new Contact("10", "00", "0", "0", "0", "0", "0", "0")); toInsert.add(new Contact("04, "00", "0", "0", "0", "0", "0", "0")); toInsert.add(new Contact("05", "00", "0", "0", "0", "0", "0", "0")); toInsert.add(new Contact("07", "00", "0", "0", "0", "0", "0", "0")); for (int i = 0; i < toInsert.size(); i++) { ContentValues values = new ContentValues(); values.put(KEY_HOUR, toInsert.get(i).get_hours()); values.put(KEY_MINUTES, toInsert.get(i).get_minutes()); values.put(KEY_DAYSOFWEEK, toInsert.get(i).get_daysofweek()); values.put(KEY_ALARMTIME, toInsert.get(i).get_alramTime()); values.put(KEY_ENABLED, toInsert.get(i).get_enabled()); values.put(KEY_VIBRATE, toInsert.get(i).get_vibrate()); values.put(KEY_MESSAGE, toInsert.get(i).get_message()); values.put(KEY_ALERT, toInsert.get(i).get_alert()); db.insert(TABLE_CONTACTS, null, values); }
/** Used to get Contact data from Cursor to Memo Object. */ private Contact cursorToContact(Cursor cursor) { Contact contact = new Contact(); contact.setId(cursor.getLong(0)); contact.setFirstName(cursor.getString(1)); contact.setLastName(cursor.getString(2)); return contact; }
db.beginTransaction(); try{ for(Contact contact : contacts) { ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.getName()); values.put(KEY_PH_NO, contact.getPhoneNumber()); db.insert(tablename,values,null,null); } db.setTransactionSuccessful();// marks a commit } finally{ db.endTransaction(); }
public void init() { if (!config.isConfigOk()) { return; } swagger = new Swagger(); swagger.setHost(config.getHost()); swagger.setBasePath("/"); swagger.addScheme(HTTP); swagger.addScheme(HTTPS); Info swaggerInfo = new Info(); swaggerInfo.setDescription(config.getDescription()); swaggerInfo.setVersion(config.getVersion()); swaggerInfo.setTitle(config.getTitle()); swaggerInfo.setTermsOfService(config.getTermsOfService()); Contact contact = new Contact(); contact.setName(config.getContactName()); contact.setEmail(config.getContactEmail()); contact.setUrl(config.getContactUrl()); swaggerInfo.setContact(contact); License license = new License(); license.setName(config.getLicenseName()); license.setUrl(config.getLicenseUrl()); swaggerInfo.setLicense(license); swagger.setInfo(swaggerInfo); List<Class> classes = ClassScanner.scanClassByAnnotation(RequestMapping.class, false); Reader.read(swagger, classes); }