Search in sources :

Example 1 with Country

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;
}
Also used : Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country) NonNull(android.support.annotation.NonNull)

Example 2 with 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();
    }
}
Also used : ContentValues(android.content.ContentValues) Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country)

Example 3 with Country

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());
}
Also used : Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 4 with Country

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());
}
Also used : Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 5 with Country

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;
}
Also used : Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country) Cursor(android.database.Cursor)

Aggregations

Country (de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country)10 ArrayAdapter (android.widget.ArrayAdapter)3 MediumTest (androidx.test.filters.MediumTest)3 Test (org.junit.Test)3 Cursor (android.database.Cursor)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 SearchView (androidx.appcompat.widget.SearchView)2 TargetApi (android.annotation.TargetApi)1 SearchManager (android.app.SearchManager)1 TaskStackBuilder (android.app.TaskStackBuilder)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Point (android.graphics.Point)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Log (android.util.Log)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1