use of de.bahnhoefe.deutschlands.bahnhofsfotos.db.CustomAdapter in project RSAndroidApp by RailwayStations.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
BaseApplication baseApplication = (BaseApplication) getApplication();
dbAdapter = baseApplication.getDbAdapter();
firstAppStart = baseApplication.getFirstAppStart();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.fab_email)));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.fab_subject));
startActivity(Intent.createChooser(emailIntent, getString(R.string.fab_chooser_title)));
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
handleGalleryNavItem();
View header = navigationView.getHeaderView(0);
TextView tvUpdate = (TextView) header.findViewById(R.id.tvUpdate);
if (firstAppStart == false) {
Intent introSliderIntent = new Intent(MainActivity.this, IntroSliderActivity.class);
startActivity(introSliderIntent);
finish();
}
try {
lastUpdateDate = loadUpdateDateFromFile("updatedate.txt");
} catch (Exception e) {
Log.e(TAG, "Cannot load last update", e);
}
if (!lastUpdateDate.equals("")) {
tvUpdate.setText("Letzte Aktualisierung am: " + lastUpdateDate);
} else {
disableNavItem();
tvUpdate.setText(R.string.no_stations_in_database);
}
cursor = dbAdapter.getStationsList(false);
customAdapter = new CustomAdapter(this, cursor, 0);
ListView listView = (ListView) findViewById(R.id.lstStations);
assert listView != null;
listView.setAdapter(customAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
Bahnhof bahnhof = dbAdapter.fetchBahnhofByRowId(id);
Class cls = DetailsActivity.class;
Intent intentDetails = new Intent(MainActivity.this, cls);
intentDetails.putExtra(DetailsActivity.EXTRA_BAHNHOF, bahnhof);
startActivity(intentDetails);
finish();
}
});
// Initialize FirebaseAuth
mFirebaseAuth = FirebaseAuth.getInstance();
Intent searchIntent = getIntent();
if (Intent.ACTION_SEARCH.equals(searchIntent.getAction())) {
String query = searchIntent.getStringExtra(SearchManager.QUERY);
Toast.makeText(MainActivity.this, query, Toast.LENGTH_SHORT).show();
}
bindToStatus();
}
Aggregations