Search in sources :

Example 11 with Bahnhof

use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof in project RSAndroidApp by RailwayStations.

the class MapsAllActivity method onInfoWindowClick.

@Override
public void onInfoWindowClick(Marker marker) {
    BaseApplication baseApplication = (BaseApplication) getApplication();
    String countryShortCode = baseApplication.getCountryShortCode();
    Class cls = DetailsActivity.class;
    Intent intent = new Intent(MapsAllActivity.this, cls);
    long id = Long.valueOf(marker.getSnippet());
    Bahnhof bahnhof = dbAdapter.fetchBahnhofByBahnhofId(id);
    intent.putExtra(DetailsActivity.EXTRA_BAHNHOF, bahnhof);
    startActivity(intent);
}
Also used : Bahnhof(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof) Intent(android.content.Intent)

Example 12 with Bahnhof

use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof in project RSAndroidApp by RailwayStations.

the class NearbyNotificationService method checkNearestStation.

private void checkNearestStation() {
    double minDist = 3e3;
    Bahnhof nearest = null;
    for (Bahnhof bahnhof : nearStations) {
        double dist = calcDistance(bahnhof);
        if (dist < minDist) {
            nearest = bahnhof;
            minDist = dist;
        }
    }
    if (nearest != null && minDist < MIN_NOTIFICATION_DISTANCE) {
        notifyNearest(nearest, minDist);
        Log.i(TAG, "Issued notification to user");
    } else {
        Log.d(TAG, "No notification - nearest station was " + minDist + " km away: " + nearest);
    }
}
Also used : Bahnhof(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof)

Example 13 with Bahnhof

use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof in project RSAndroidApp by RailwayStations.

the class BahnhofsDbAdapter method getAllBahnhoefe.

// Getting All Bahnhoefe
public List<Bahnhof> getAllBahnhoefe(boolean withPhoto) {
    List<Bahnhof> bahnhofList = new ArrayList<Bahnhof>();
    // Select All Query without any baseLocationValues (myCurrentLocation)
    String selectQuery = "SELECT " + KEY_ID + ", " + Constants.DB_JSON_CONSTANTS.KEY_TITLE + ", " + Constants.DB_JSON_CONSTANTS.KEY_LAT + ", " + Constants.DB_JSON_CONSTANTS.KEY_LON + ", " + Constants.DB_JSON_CONSTANTS.KEY_PHOTOFLAG + " FROM " + DATABASE_TABLE + " WHERE " + Constants.DB_JSON_CONSTANTS.KEY_PHOTOFLAG + " IS " + (withPhoto ? "NOT" : "") + " NULL";
    Log.d(TAG, selectQuery.toString());
    Cursor cursor = db.rawQuery(selectQuery, null);
    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
        do {
            Bahnhof bahnhof = createBahnhofFromCursor(cursor);
            // Adding bahnhof to list
            bahnhofList.add(bahnhof);
            if (Log.isLoggable(TAG, Log.DEBUG))
                Log.d(TAG, "Bahnhof #" + bahnhofList.size() + " " + bahnhof);
        } while (cursor.moveToNext());
    }
    cursor.close();
    // return bahnhof list
    return bahnhofList;
}
Also used : Bahnhof(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Aggregations

Bahnhof (de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof)13 Intent (android.content.Intent)4 Cursor (android.database.Cursor)4 Toolbar (android.support.v7.widget.Toolbar)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 LatLng (com.google.android.gms.maps.model.LatLng)2 ArrayList (java.util.ArrayList)2 ContentValues (android.content.ContentValues)1 NonNull (android.support.annotation.NonNull)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 NavigationView (android.support.design.widget.NavigationView)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 SearchView (android.support.v7.widget.SearchView)1 Window (android.view.Window)1 GridView (android.widget.GridView)1 ListView (android.widget.ListView)1 SupportMapFragment (com.google.android.gms.maps.SupportMapFragment)1