use of io.requery.android.example.app.model.PersonEntity in project requery by requery.
the class PersonEditActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_person);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Edit Person");
}
data = ((PeopleApplication) getApplication()).getData();
int personId = getIntent().getIntExtra(EXTRA_PERSON_ID, -1);
if (personId == -1) {
// creating a new person
person = new PersonEntity();
binding.setPerson(person);
} else {
data.findByKey(PersonEntity.class, personId).subscribeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<PersonEntity>() {
@Override
public void accept(PersonEntity person) {
PersonEditActivity.this.person = person;
binding.setPerson(person);
}
});
}
}
use of io.requery.android.example.app.model.PersonEntity in project requery by requery.
the class CreatePeople method call.
@Override
public Observable<Iterable<Person>> call() {
String[] firstNames = new String[] { "Alice", "Bob", "Carol", "Chloe", "Dan", "Emily", "Emma", "Eric", "Eva", "Frank", "Gary", "Helen", "Jack", "James", "Jane", "Kevin", "Laura", "Leon", "Lilly", "Mary", "Maria", "Mia", "Nick", "Oliver", "Olivia", "Patrick", "Robert", "Stan", "Vivian", "Wesley", "Zoe" };
String[] lastNames = new String[] { "Hall", "Hill", "Smith", "Lee", "Jones", "Taylor", "Williams", "Jackson", "Stone", "Brown", "Thomas", "Clark", "Lewis", "Miller", "Walker", "Fox", "Robinson", "Wilson", "Cook", "Carter", "Cooper", "Martin" };
Random random = new Random();
final Set<Person> people = new TreeSet<>(new Comparator<Person>() {
@Override
public int compare(Person lhs, Person rhs) {
return lhs.getName().compareTo(rhs.getName());
}
});
// creating many people (but only with unique names)
for (int i = 0; i < 3000; i++) {
PersonEntity person = new PersonEntity();
String first = firstNames[random.nextInt(firstNames.length)];
String last = lastNames[random.nextInt(lastNames.length)];
person.setName(first + " " + last);
person.setUUID(UUID.randomUUID());
person.setEmail(Character.toLowerCase(first.charAt(0)) + last.toLowerCase() + "@gmail.com");
AddressEntity address = new AddressEntity();
address.setLine1("123 Market St");
address.setZip("94105");
address.setCity("San Francisco");
address.setState("CA");
address.setCountry("US");
person.setAddress(address);
people.add(person);
}
return data.insert(people).toObservable();
}
Aggregations