Java tutorial
//*H**************************************************************************** // FILENAME: History_NitrateActivity_Item.java // // DESCRIPTION: // a class to handle the information for a incident report in the history // // A list of names of copyright information is provided in the README // // This file is part of RiverWatch. // // RiverWatch is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // RiverWatch is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RiverWatch. If not, see <http://www.gnu.org/licenses/>. // // CHANGES: // DATE WHO DETAILS // 20/11/1995 George Added header. // //*H* package com.vuw.project1.riverwatch.ui; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.vuw.project1.riverwatch.R; import com.vuw.project1.riverwatch.database.Database; import com.vuw.project1.riverwatch.objects.Nitrate_Report; public class History_NitrateActivity_Item extends AppCompatActivity { long id; double latitude; double longitude; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_container); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } Bundle extras = getIntent().getExtras(); id = 0; latitude = 0; longitude = 0; if (extras != null) { id = extras.getLong("id", 0); latitude = extras.getDouble("latitude", 0); longitude = extras.getDouble("longitude", 0); } final String[] titles = new String[] { "Info", "Map" }; ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { switch (position) { case 0: return History_NitrateActivityFragment_Info.newInstance(id); case 1: return History_ActivityFragment_Map.newInstance(latitude, longitude); default: return History_NitrateActivityFragment_Info.newInstance(-1); } } @Override public CharSequence getPageTitle(int position) { return titles[position]; } @Override public int getCount() { return titles.length; } }); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout.setupWithViewPager(viewPager); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed(); return true; } return super.onOptionsItemSelected(item); } }