use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country in project RSAndroidApp by RailwayStations.
the class BahnhofsDbAdapter method createCountryFromCursor.
@NonNull
private Country createCountryFromCursor(@NonNull Cursor cursor) {
String countryShortCode = cursor.getString(cursor.getColumnIndexOrThrow(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYSHORTCODE));
String countryName = cursor.getString(cursor.getColumnIndexOrThrow(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYNAME));
String email = cursor.getString(cursor.getColumnIndexOrThrow(Constants.DB_JSON_CONSTANTS.KEY_EMAIL));
String twitterTags = cursor.getString(cursor.getColumnIndexOrThrow(Constants.DB_JSON_CONSTANTS.KEY_TWITTERTAGS));
Country country = new Country();
country.setCountryShortCode(countryShortCode);
country.setCountryName(countryName);
country.setEmail(email);
country.setTwitterTags(twitterTags);
return country;
}
use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country in project RSAndroidApp by RailwayStations.
the class BahnhofsDbAdapter method insertCountries.
public void insertCountries(List<Country> countries) {
if (countries.isEmpty()) {
// nothing todo
return;
}
// soll die Performance verbessern, heißt's.
db.beginTransaction();
try {
deleteCountries();
for (Country country : countries) {
ContentValues values = new ContentValues();
values.put(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYSHORTCODE, country.getCountryShortCode());
values.put(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYNAME, country.getCountryName());
values.put(Constants.DB_JSON_CONSTANTS.KEY_EMAIL, country.getEmail());
values.put(Constants.DB_JSON_CONSTANTS.KEY_TWITTERTAGS, country.getTwitterTags());
db.insert(DATABASE_TABLE_LAENDER, null, values);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country in project RSAndroidApp by RailwayStations.
the class TimetableTest method createTimetableIntentWithId.
@Test
public void createTimetableIntentWithId() {
final Country country = new Country();
country.setTimetableUrlTemplate("https://example.com/{id}/blah");
assertEquals("https://example.com/4711/blah", new Timetable().createTimetableIntent(country, station).getData().toString());
}
use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country in project RSAndroidApp by RailwayStations.
the class TimetableTest method createTimetableIntentWithTitle.
@Test
public void createTimetableIntentWithTitle() {
final Country country = new Country();
country.setTimetableUrlTemplate("https://example.com/{title}/blah");
assertEquals("https://example.com/Some Famous Station/blah", new Timetable().createTimetableIntent(country, station).getData().toString());
}
use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country in project RSAndroidApp by RailwayStations.
the class BahnhofsDbAdapter method fetchCountryByCountryShortCode.
public Country fetchCountryByCountryShortCode(String countryShortCode) {
Cursor cursor = db.query(DATABASE_TABLE_LAENDER, null, Constants.DB_JSON_CONSTANTS.KEY_COUNTRYSHORTCODE + "=?", new String[] { countryShortCode + "" }, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
Country country = createCountryFromCursor(cursor);
cursor.close();
return country;
} else
return null;
}
Aggregations