├── Animals.java ├── BestTime.java ├── DatabaseAccess.java ├── DatabaseOpenHelper.java ├── HomePage.java ├── Information.java ├── ListOfParks.java ├── Map.java ├── SetLocation.java └── SetText.java /Animals.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.view.View; 10 | import android.widget.ArrayAdapter; 11 | import android.widget.ListView; 12 | import android.widget.TextView; 13 | 14 | import java.util.ArrayList; 15 | 16 | public class Animals extends AppCompatActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_animals); 22 | Intent receiver=getIntent(); 23 | String park = receiver.getStringExtra("park"); 24 | TextView txt=(TextView)findViewById(R.id.textViewAnimals); 25 | //FIre Query 26 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 27 | databaseAccess.open(); 28 | String text=databaseAccess.getAnimalsFound(park); 29 | txt.setText(text); 30 | databaseAccess.close(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BestTime.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.widget.TextView; 7 | 8 | import org.w3c.dom.Text; 9 | 10 | public class BestTime extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_best_time); 16 | TextView content=(TextView)findViewById(R.id.textViewBestTimeContent); 17 | Intent receiver=getIntent(); 18 | String park = receiver.getStringExtra("park"); 19 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 20 | databaseAccess.open(); 21 | //Fire Query here 22 | String str=databaseAccess.getActivities(park); 23 | content.setText(str); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DatabaseAccess.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.database.sqlite.SQLiteOpenHelper; 8 | import android.database.sqlite.SQLiteStatement; 9 | import android.graphics.Bitmap; 10 | import android.graphics.BitmapFactory; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class DatabaseAccess { 16 | private SQLiteOpenHelper openHelper; 17 | private SQLiteDatabase db; 18 | private static DatabaseAccess instance; 19 | Cursor c=null; 20 | 21 | private DatabaseAccess(Context context) 22 | { 23 | this.openHelper = new DatabaseOpenHelper(context); 24 | } 25 | 26 | public static DatabaseAccess getInstance(Context context) { 27 | if (instance == null) { 28 | instance = new DatabaseAccess(context); 29 | } 30 | return instance; 31 | } 32 | 33 | public void open() 34 | { 35 | this.db = openHelper.getWritableDatabase(); 36 | } 37 | 38 | 39 | public void close() 40 | { 41 | if (db != null) { 42 | this.db.close(); 43 | } 44 | } 45 | public ArrayList getParks() 46 | { 47 | SQLiteDatabase db1=openHelper.getReadableDatabase(); 48 | // SQLiteDatabase db = SQLiteDatabase.openDatabase("/data/data/com.package.name/databases/database.db", null, SQLiteDatabase.OPEN_READWRITE); 49 | Cursor ct=db1.rawQuery("select parkname from nationalparks",null); 50 | ArrayList list=new ArrayList(); 51 | while(ct.moveToNext()) 52 | { 53 | list.add(ct.getString(0)); 54 | } 55 | return list; 56 | } 57 | public ArrayList getParkbyState(String s) 58 | { 59 | c=db.rawQuery("select parkname from nationalparks where state='"+s+"'",new String[]{}); 60 | ArrayList list=new ArrayList(); 61 | while(c.moveToNext()) 62 | { 63 | list.add(c.getString(0)); 64 | } 65 | return list; 66 | } 67 | public ArrayList getParkbyAnimal(String s) 68 | { 69 | c=db.rawQuery("select parkname from nationalparks where animalsfound like'%"+s+"%'",new String[]{}); 70 | ArrayList list=new ArrayList(); 71 | while(c.moveToNext()) 72 | { 73 | list.add(c.getString(0)); 74 | } 75 | return list; 76 | } 77 | public String getHistory(String s) 78 | { 79 | c=db.rawQuery("select history from nationalparks where parkname='"+s+"'",new String[]{}); 80 | String str=null; 81 | if(c.moveToFirst()) 82 | { 83 | str=c.getString(0); 84 | } 85 | return str; 86 | } 87 | public String getDescription(String s) 88 | { 89 | c=db.rawQuery("select description from nationalparks where parkname='"+s+"'",new String[]{}); 90 | String str=null; 91 | if(c.moveToFirst()) 92 | { 93 | str=c.getString(0); 94 | } 95 | return str; 96 | } 97 | public String getActivities(String s) 98 | { 99 | c=db.rawQuery("select activities from nationalparks where parkname='"+s+"'",new String[]{}); 100 | String str=null; 101 | if(c.moveToFirst()) 102 | { 103 | str=c.getString(0); 104 | } 105 | return str; 106 | } 107 | public String getAnimalsFound(String s) 108 | { 109 | c=db.rawQuery("select animalsfound from nationalparks where parkname='"+s+"'",new String[]{}); 110 | String str=null; 111 | if(c.moveToFirst()) 112 | { 113 | str=c.getString(0); 114 | } 115 | return str; 116 | } 117 | public String getTimings(String s) 118 | { 119 | c=db.rawQuery("select timings from nationalparks where parkname='"+s+"'",new String[]{}); 120 | String str=null; 121 | if(c.moveToFirst()) 122 | { 123 | str=c.getString(0); 124 | } 125 | return str; 126 | } 127 | public String getBestTimeToVisit(String s) 128 | { 129 | c=db.rawQuery("select besttimetovisit from nationalparks where parkname='"+s+"'",new String[]{}); 130 | String str=null; 131 | if(c.moveToFirst()) 132 | { 133 | str=c.getString(0); 134 | } 135 | return str; 136 | } 137 | public String getHotels(String s) 138 | { 139 | c=db.rawQuery("select hotelsnearby from nationalparks where parkname='"+s+"'",new String[]{}); 140 | String str=null; 141 | if(c.moveToFirst()) 142 | { 143 | str=c.getString(0); 144 | } 145 | return str; 146 | } 147 | public String getDND(String s) 148 | { 149 | c=db.rawQuery("select dosanddonts from nationalparks where parkname='"+s+"'",new String[]{}); 150 | String str=null; 151 | if(c.moveToFirst()) 152 | { 153 | str=c.getString(0); 154 | } 155 | return str; 156 | } 157 | public String getContactUs(String s) 158 | { 159 | c=db.rawQuery("select contactus from nationalparks where parkname='"+s+"'",new String[]{}); 160 | String str=null; 161 | if(c.moveToFirst()) 162 | { 163 | str=c.getString(0); 164 | } 165 | return str; 166 | } 167 | public String getLocation(String s) 168 | { 169 | c=db.rawQuery("select location from nationalparks where parkname='"+s+"'",new String[]{}); 170 | String str=null; 171 | if(c.moveToFirst()) 172 | { 173 | str=c.getString(0); 174 | } 175 | return str; 176 | } 177 | public Double getLat(String s) 178 | { 179 | c=db.rawQuery("select latitude from nationalparks where parkname='"+s+"'",new String[]{}); 180 | Double lat=0.0; 181 | if(c.moveToFirst()) 182 | { 183 | lat=c.getDouble(0); 184 | } 185 | return lat; 186 | } 187 | public Double getLang(String s) 188 | { 189 | c=db.rawQuery("select longitude from nationalparks where parkname='"+s+"'",new String[]{}); 190 | Double lang=0.0; 191 | if(c.moveToFirst()) 192 | { 193 | lang=c.getDouble(0); 194 | } 195 | return lang; 196 | } 197 | public String getURL(String s) 198 | { 199 | c=db.rawQuery("select ticketbookings from nationalparks where parkname='"+s+"'",new String[]{}); 200 | String str=null; 201 | if(c.moveToFirst()) 202 | { 203 | str=c.getString(0); 204 | } 205 | return str; 206 | } 207 | public Bitmap getImage1(String s) 208 | { 209 | Bitmap images=null; 210 | c=db.rawQuery("select image1 from nationalparks where parkname='"+s+"'",new String[]{}); 211 | if(c.moveToNext()) 212 | { 213 | byte img[]=c.getBlob(0); 214 | images=BitmapFactory.decodeByteArray(img,0,img.length); 215 | 216 | } 217 | return images; 218 | } 219 | public Bitmap getImage2(String s) 220 | { 221 | Bitmap images=null; 222 | c=db.rawQuery("select image2 from nationalparks where parkname='"+s+"'",new String[]{}); 223 | if(c.moveToNext()) 224 | { 225 | byte img[]=c.getBlob(0); 226 | images=BitmapFactory.decodeByteArray(img,0,img.length); 227 | 228 | } 229 | return images; 230 | } 231 | public Bitmap getImage3(String s) 232 | { 233 | Bitmap images=null; 234 | c=db.rawQuery("select image3 from nationalparks where parkname='"+s+"'",new String[]{}); 235 | if(c.moveToNext()) 236 | { 237 | byte img[]=c.getBlob(0); 238 | images=BitmapFactory.decodeByteArray(img,0,img.length); 239 | 240 | } 241 | return images; 242 | } 243 | public Bitmap getImage4(String s) 244 | { 245 | Bitmap images=null; 246 | c=db.rawQuery("select image4 from nationalparks where parkname='"+s+"'",new String[]{}); 247 | if(c.moveToNext()) 248 | { 249 | byte img[]=c.getBlob(0); 250 | images=BitmapFactory.decodeByteArray(img,0,img.length); 251 | 252 | } 253 | return images; 254 | } 255 | public Bitmap getImage5(String s) 256 | { 257 | Bitmap images=null; 258 | c=db.rawQuery("select image5 from nationalparks where parkname='"+s+"'",new String[]{}); 259 | if(c.moveToNext()) 260 | { 261 | byte img[]=c.getBlob(0); 262 | images=BitmapFactory.decodeByteArray(img,0,img.length); 263 | 264 | } 265 | return images; 266 | } 267 | 268 | } 269 | -------------------------------------------------------------------------------- /DatabaseOpenHelper.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Context; 4 | 5 | import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; 6 | 7 | public class DatabaseOpenHelper extends SQLiteAssetHelper { 8 | private static final String DATABASE_NAME = "database.db"; 9 | private static final int DATABASE_VERSION = 1; 10 | 11 | public DatabaseOpenHelper(Context context) { 12 | super(context, DATABASE_NAME, null, DATABASE_VERSION); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HomePage.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuInflater; 8 | import android.view.MenuItem; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.widget.AdapterView; 12 | import android.widget.ArrayAdapter; 13 | import android.widget.SearchView; 14 | import android.widget.Spinner; 15 | import android.widget.TextView; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | public class HomePage extends AppCompatActivity { 22 | ArrayAdapter dataAdapter1; 23 | ArrayAdapter dataAdapter2; 24 | Spinner spinner2,spinner1; 25 | Intent goToPark; 26 | SearchView srcv; 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_home_page); 31 | createSpin1(); 32 | createSpin2(); 33 | spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 34 | @Override 35 | public void onItemSelected(AdapterView adapterView, View view, int i, long l) { 36 | if(i!=0) 37 | { 38 | 39 | goToPark=new Intent().setClass(getApplicationContext(), ListOfParks.class); 40 | String selected=adapterView.getItemAtPosition(i).toString(); 41 | goToPark.putExtra("state",selected); 42 | startActivity(goToPark); 43 | 44 | } 45 | } 46 | 47 | @Override 48 | public void onNothingSelected(AdapterView adapterView) { 49 | 50 | } 51 | }); 52 | 53 | spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 54 | @Override 55 | public void onItemSelected(AdapterView adapterView, View view, int i, long l) { 56 | if(i!=0) 57 | { 58 | 59 | goToPark=new Intent().setClass(getApplicationContext(), Information.class); 60 | String selected2=adapterView.getItemAtPosition(i).toString(); 61 | goToPark.putExtra("park",selected2); 62 | startActivity(goToPark); 63 | 64 | } 65 | } 66 | 67 | @Override 68 | public void onNothingSelected(AdapterView adapterView) { 69 | 70 | } 71 | }); 72 | } 73 | public void createSpin1() 74 | { 75 | spinner1 = (Spinner) findViewById(R.id.spinnerStates); 76 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 77 | ArrayList states = new ArrayList(); 78 | states.add("Uttarakhand"); 79 | states.add("West Bengal"); 80 | states.add("Rajasthan"); 81 | states.add("Gujarat"); 82 | states.add("Assam"); 83 | states.add("Madhya Pradesh"); 84 | states.add("Haryana"); 85 | states.add("Kerala"); 86 | Collections.sort(states); 87 | states.add(0,"Select by State"); 88 | dataAdapter1 = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, states); 89 | dataAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 90 | spinner1.setAdapter(dataAdapter1); 91 | 92 | } 93 | public void createSpin2() 94 | { 95 | spinner2 = (Spinner) findViewById(R.id.spinnerParks); 96 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 97 | ArrayList parks= databaseAccess.getParks(); 98 | Collections.sort(parks); 99 | parks.add(0,"Select by Wildlife Sanctuary"); 100 | dataAdapter2 = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, parks); 101 | dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 102 | spinner2.setAdapter(dataAdapter2); 103 | } 104 | 105 | @Override 106 | public boolean onCreateOptionsMenu(Menu menu) { 107 | SearchView srcv=(SearchView)findViewById(R.id.searchMenuAnimal); 108 | srcv.setMaxWidth(Integer.MAX_VALUE); 109 | srcv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { 110 | @Override 111 | public boolean onQueryTextSubmit(String s) 112 | { 113 | goToPark=new Intent().setClass(getApplicationContext(), ListOfParks.class); 114 | goToPark.putExtra("animal",s); 115 | startActivity(goToPark); 116 | return false; 117 | } 118 | 119 | @Override 120 | public boolean onQueryTextChange(String s) { 121 | 122 | return false; 123 | } 124 | }); 125 | return super.onCreateOptionsMenu(menu); 126 | } 127 | 128 | 129 | } 130 | -------------------------------------------------------------------------------- /Information.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.graphics.Color; 7 | import android.media.Image; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.provider.MediaStore; 11 | import android.support.design.widget.FloatingActionButton; 12 | import android.support.design.widget.Snackbar; 13 | import android.support.v7.app.AppCompatActivity; 14 | import android.support.v7.widget.Toolbar; 15 | import android.text.Spannable; 16 | import android.text.SpannableString; 17 | import android.text.Spanned; 18 | import android.text.method.LinkMovementMethod; 19 | import android.text.style.ClickableSpan; 20 | import android.text.style.ForegroundColorSpan; 21 | import android.view.View; 22 | import android.view.animation.Animation; 23 | import android.view.animation.AnimationUtils; 24 | import android.widget.Button; 25 | import android.widget.ImageView; 26 | import android.widget.LinearLayout; 27 | import android.widget.TextView; 28 | import android.widget.ViewFlipper; 29 | 30 | public class Information extends AppCompatActivity { 31 | 32 | ViewFlipper viewFlipper; 33 | TextView history,description,timings,bestTimes; 34 | ImageView img1,img2,img3,img4,img5; 35 | Button bestTime,animals,ticket,hotels,timing,activity; 36 | LinearLayout l1; 37 | String park; 38 | LinearLayout l; 39 | Intent receiver; 40 | static int c1=0,c2=0; 41 | DatabaseAccess databaseAccess; 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_information); 46 | img1=(ImageView) findViewById(R.id.imageOne); 47 | img2=(ImageView) findViewById(R.id.imageTwo); 48 | img3=(ImageView) findViewById(R.id.imageThree); 49 | img4=(ImageView) findViewById(R.id.imageFour); 50 | img5=(ImageView)findViewById(R.id.imageFive); 51 | history=(TextView)findViewById(R.id.textViewHistory); 52 | description=(TextView)findViewById(R.id.textViewDescription); 53 | viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper); 54 | bestTime=(Button)findViewById(R.id.buttonBestTime); 55 | animals=(Button)findViewById(R.id.buttonAnimals); 56 | hotels=(Button)findViewById(R.id.buttonHotels); 57 | ticket=(Button)findViewById(R.id.buttonTicketBooking); 58 | timing=(Button)findViewById(R.id.buttonTimings); 59 | activity=(Button)findViewById(R.id.buttonActivities); 60 | timings=(TextView)findViewById(R.id.textViewTimings); 61 | bestTimes=(TextView)findViewById(R.id.textViewBestTimes); 62 | l=(LinearLayout)findViewById(R.id.linearLayoutVisibility); 63 | 64 | receiver=getIntent(); 65 | park=receiver.getStringExtra("park"); 66 | databaseAccess = DatabaseAccess.getInstance(getApplicationContext()); 67 | databaseAccess.open(); 68 | 69 | flip(); 70 | setText(); 71 | 72 | timing.setOnClickListener(new View.OnClickListener() { 73 | @Override 74 | public void onClick(View view) { 75 | c1++; 76 | setTiming(); 77 | } 78 | }); 79 | 80 | bestTime.setOnClickListener(new View.OnClickListener() { 81 | @Override 82 | public void onClick(View view) { 83 | c2++; 84 | setBestTime(); 85 | } 86 | }); 87 | 88 | } 89 | public void flip() //Flipping Image to be changed 90 | { 91 | img1.setImageBitmap(databaseAccess.getImage1(park)); 92 | img2.setImageBitmap(databaseAccess.getImage2(park)); 93 | img3.setImageBitmap(databaseAccess.getImage3(park)); 94 | img4.setImageBitmap(databaseAccess.getImage4(park)); 95 | img5.setImageBitmap(databaseAccess.getImage5(park)); 96 | viewFlipper.setAutoStart(true); 97 | viewFlipper.setFlipInterval(2000); 98 | Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); 99 | Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); 100 | viewFlipper.setInAnimation(in); 101 | viewFlipper.setOutAnimation(out); 102 | } 103 | 104 | 105 | public void setText() 106 | { 107 | //FIre Query for History 108 | databaseAccess.open(); 109 | String his=databaseAccess.getHistory(park); 110 | databaseAccess.close(); 111 | history.setText(his); 112 | databaseAccess.open(); 113 | String desc=databaseAccess.getDescription(park); 114 | databaseAccess.close(); 115 | description.setText(desc); 116 | ellipsize(history); 117 | ellipsize(description); 118 | } 119 | public void ellipsize(final TextView txt) //Ellipsizing Text 120 | { 121 | String inputText=txt.getText().toString(); 122 | if(inputText.length()>150) 123 | { 124 | String text=inputText.substring(0,150)+"..."; 125 | final String fulltext=inputText; 126 | 127 | final SpannableString ss = new SpannableString(text+"View More"); 128 | 129 | ClickableSpan span1 = new ClickableSpan() { 130 | @Override 131 | public void onClick(View textView) { 132 | // do some thing 133 | SpannableString ss1 = new SpannableString(fulltext+"Show Less"); 134 | ClickableSpan span2 = new ClickableSpan() { 135 | @Override 136 | public void onClick(View textView) { 137 | // do some thing 138 | txt.setText(ss); 139 | txt.setMovementMethod(LinkMovementMethod.getInstance()); 140 | 141 | } 142 | }; 143 | ss1.setSpan(span2, fulltext.length(), ss1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 144 | ss1.setSpan(new ForegroundColorSpan(Color.RED), fulltext.length(), ss1.length(), 145 | Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 146 | 147 | 148 | txt.setText(ss1); 149 | txt.setMovementMethod(LinkMovementMethod.getInstance()); 150 | } 151 | }; 152 | ss.setSpan(span1, 153, 162, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 153 | ss.setSpan(new ForegroundColorSpan(Color.RED), 153,162,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 154 | 155 | txt.setText(ss); 156 | txt.setMovementMethod(LinkMovementMethod.getInstance()); 157 | } 158 | else 159 | { 160 | txt.setText(inputText); 161 | } 162 | } 163 | 164 | 165 | public void setActivities(View view) 166 | { 167 | Intent goToBestTime=new Intent().setClass(getApplicationContext(),BestTime.class); 168 | goToBestTime.putExtra("park",park); 169 | startActivity(goToBestTime); 170 | } 171 | public void setAnimals(View view) 172 | { 173 | Intent goToAnimals=new Intent().setClass(getApplicationContext(),Animals.class); 174 | goToAnimals.putExtra("park",park); 175 | startActivity(goToAnimals); 176 | } 177 | 178 | 179 | public void setTiming() 180 | { 181 | if(c1%2!=0) 182 | { 183 | //Fire query for timing column 184 | databaseAccess.open(); 185 | String str=databaseAccess.getTimings(park); 186 | databaseAccess.close(); 187 | timings.setText(str); 188 | l.setVisibility(View.VISIBLE); 189 | timings.setVisibility(View.VISIBLE); 190 | } 191 | if(c1%2==0) 192 | { 193 | timings.setVisibility(View.INVISIBLE); 194 | if(c2%2==0) 195 | { 196 | l.setVisibility(View.GONE); 197 | } 198 | } 199 | 200 | } 201 | public void setBestTime() 202 | { 203 | 204 | if(c2%2!=0) 205 | { 206 | //Fire query for activities column 207 | databaseAccess.open(); 208 | String str=databaseAccess.getBestTimeToVisit(park); 209 | databaseAccess.close(); 210 | bestTimes.setText(str); 211 | 212 | l.setVisibility(View.VISIBLE); 213 | bestTimes.setVisibility(View.VISIBLE); 214 | } 215 | if(c2%2==0) 216 | { 217 | bestTimes.setVisibility(View.INVISIBLE); 218 | if(c1%2==0) 219 | { 220 | l.setVisibility(View.GONE); 221 | } 222 | 223 | } 224 | 225 | } 226 | 227 | 228 | public void setHotels(View view) 229 | { 230 | Intent goToSetText=new Intent().setClass(getApplicationContext(),SetText.class); 231 | goToSetText.putExtra("park",park); 232 | goToSetText.putExtra("button","hotels"); 233 | startActivity(goToSetText); 234 | } 235 | public void setTicketBooking(View view) 236 | { 237 | databaseAccess.open(); 238 | String url=databaseAccess.getURL(park); 239 | Intent viewIntent=new Intent("android.intent.action.VIEW",Uri.parse(url)); 240 | startActivity(viewIntent); 241 | } 242 | 243 | 244 | public void setDND(View view) 245 | { 246 | Intent goToSetText=new Intent().setClass(getApplicationContext(),SetText.class); 247 | goToSetText.putExtra("park",park); 248 | goToSetText.putExtra("button","DND"); 249 | startActivity(goToSetText); 250 | } 251 | public void setContactUs(View view) 252 | { 253 | Intent goToSetText=new Intent().setClass(getApplicationContext(),SetText.class); 254 | goToSetText.putExtra("park",park); 255 | goToSetText.putExtra("button","ContactUs"); 256 | startActivity(goToSetText); 257 | } 258 | 259 | public void setLocation(View view) 260 | { 261 | Intent goToSetLocation=new Intent().setClass(getApplicationContext(),SetLocation.class); 262 | goToSetLocation.putExtra("park",park); 263 | startActivity(goToSetLocation); 264 | } 265 | 266 | 267 | 268 | } 269 | -------------------------------------------------------------------------------- /ListOfParks.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.AdapterView; 8 | import android.widget.ArrayAdapter; 9 | import android.widget.ListView; 10 | import android.widget.TextView; 11 | import android.widget.Toast; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class ListOfParks extends AppCompatActivity { 17 | String incomingState = null, incomingAnimal = null; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_list_of_parks); 23 | Intent caller = getIntent(); 24 | incomingState = caller.getStringExtra("state"); 25 | incomingAnimal = caller.getStringExtra("animal"); 26 | ListView parklist = (ListView) findViewById(R.id.listViewParks); 27 | ArrayList lps = null; 28 | 29 | DatabaseAccess databaseAccess = DatabaseAccess.getInstance(getApplicationContext()); 30 | databaseAccess.open(); 31 | //Fire Query 32 | if (incomingState != null) { 33 | lps = databaseAccess.getParkbyState(incomingState); 34 | databaseAccess.close(); 35 | } 36 | if (incomingAnimal != null) { 37 | lps = databaseAccess.getParkbyAnimal(incomingAnimal); 38 | databaseAccess.close(); 39 | } 40 | ArrayAdapter aradpt = new ArrayAdapter(this, android.R.layout.simple_list_item_1, lps); 41 | 42 | parklist.setAdapter(aradpt); 43 | parklist.setOnItemClickListener(new AdapterView.OnItemClickListener() { 44 | @Override 45 | public void onItemClick(AdapterView adapterView, View view, int i, long l) { 46 | Intent goToInfo = new Intent().setClass(getApplicationContext(), Information.class); 47 | String str = adapterView.getItemAtPosition(i).toString(); 48 | goToInfo.putExtra("park", str); 49 | startActivity(goToInfo); 50 | 51 | } 52 | }); 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Map.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.Manifest; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.location.Location; 7 | import android.os.Build; 8 | import android.support.annotation.NonNull; 9 | import android.support.v4.app.ActivityCompat; 10 | import android.support.v4.app.FragmentActivity; 11 | import android.os.Bundle; 12 | 13 | import com.google.android.gms.maps.CameraUpdate; 14 | import com.google.android.gms.maps.CameraUpdateFactory; 15 | import com.google.android.gms.maps.GoogleMap; 16 | import com.google.android.gms.maps.OnMapReadyCallback; 17 | import com.google.android.gms.maps.SupportMapFragment; 18 | import com.google.android.gms.maps.model.LatLng; 19 | import com.google.android.gms.maps.model.MarkerOptions; 20 | 21 | public class Map extends FragmentActivity implements OnMapReadyCallback { 22 | 23 | private GoogleMap mMap; 24 | String parkName; 25 | Double lat,lang; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_map); 31 | Intent rcv = getIntent(); 32 | parkName = rcv.getStringExtra("park"); 33 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 34 | databaseAccess.open(); 35 | lat=databaseAccess.getLat(parkName); 36 | lang=databaseAccess.getLang(parkName); 37 | databaseAccess.close(); 38 | // Obtain the SupportMapFragment and get notified when the map is ready to be used. 39 | SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 40 | .findFragmentById(R.id.map); 41 | mapFragment.getMapAsync(this); 42 | } 43 | 44 | 45 | /** 46 | * Manipulates the map once available. 47 | * This callback is triggered when the map is ready to be used. 48 | * This is where we can add markers or lines, add listeners or move the camera. In this case, 49 | * we just add a marker near Sydney, Australia. 50 | * If Google Play services is not installed on the device, the user will be prompted to install 51 | * it inside the SupportMapFragment. This method will only be triggered once the user has 52 | * installed Google Play services and returned to the app. 53 | */ 54 | @Override 55 | public void onMapReady(GoogleMap googleMap) { 56 | mMap = googleMap; 57 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { 58 | String[] permissions = { 59 | "android.permission.ACCESS_NETWORK_STATE", 60 | "android.permission.INTERNET" 61 | }; 62 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 63 | requestPermissions(permissions,200); 64 | } 65 | } 66 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 67 | String[] permissions = { 68 | "android.permission.ACCESS_COARSE_LOCATION", 69 | "android.permission.ACCESS_FINE_LOCATION" 70 | }; 71 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 72 | requestPermissions(permissions,200); 73 | } 74 | } 75 | mMap.setMyLocationEnabled(true); 76 | mMap.setOnMyLocationClickListener(new GoogleMap.OnMyLocationClickListener() { 77 | @Override 78 | public void onMyLocationClick(@NonNull Location location) { 79 | CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude())); 80 | CameraUpdate zoom = CameraUpdateFactory.zoomTo(22); 81 | 82 | MarkerOptions mp = new MarkerOptions(); 83 | 84 | mp.position(new LatLng(location.getLatitude(), location.getLongitude())); 85 | 86 | mp.title("My Location"); 87 | 88 | mMap.addMarker(mp); 89 | mMap.moveCamera(center); 90 | mMap.animateCamera(zoom); 91 | 92 | } 93 | }); 94 | LatLng p=new LatLng(lat,lang); 95 | mMap.addMarker(new MarkerOptions().position(p).title(parkName)); 96 | mMap.moveCamera(CameraUpdateFactory.newLatLng(p)); 97 | mMap.setMapType(4); 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /SetLocation.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.media.Image; 5 | import android.support.v4.app.FragmentActivity; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | 13 | 14 | import org.w3c.dom.Text; 15 | 16 | public class SetLocation extends AppCompatActivity { 17 | String park; 18 | TextView content; 19 | ImageView img; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_set_location); 25 | content = (TextView) findViewById(R.id.textViewBestTimeContent); 26 | Intent receiver = getIntent(); 27 | park = receiver.getStringExtra("park"); 28 | //Fire Query to retrieve city location 29 | setLocation(); 30 | img=(ImageView)findViewById(R.id.imageLocation); 31 | img.setOnClickListener(new View.OnClickListener() { 32 | @Override 33 | public void onClick(View view) { 34 | Intent goToMap=new Intent(getApplicationContext(),Map.class); 35 | goToMap.putExtra("park",park); 36 | startActivity(goToMap); 37 | } 38 | }); 39 | } 40 | 41 | public void setLocation() { 42 | TextView location = (TextView) findViewById(R.id.textViewLocation); 43 | //Fire Query for retreival of location column 44 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 45 | databaseAccess.open(); 46 | String str=databaseAccess.getLocation(park); 47 | databaseAccess.close(); 48 | location.setText(str); 49 | } 50 | 51 | 52 | } -------------------------------------------------------------------------------- /SetText.java: -------------------------------------------------------------------------------- 1 | package com.example.birendra.wildlifeapp; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.widget.TextView; 7 | 8 | public class SetText extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_set_text); 14 | TextView content=(TextView)findViewById(R.id.textViewSetText); 15 | Intent receiver=getIntent(); 16 | String park = receiver.getStringExtra("park"); 17 | String button=receiver.getStringExtra("button"); 18 | DatabaseAccess databaseAccess=DatabaseAccess.getInstance(getApplicationContext()); 19 | databaseAccess.open(); 20 | switch(button) 21 | 22 | { 23 | case "hotels" : String hotel=databaseAccess.getHotels(park); 24 | content.setText(hotel); 25 | break; 26 | case "DND" : String DND=databaseAccess.getDND(park); 27 | content.setText(DND); 28 | break; 29 | case "ContactUs" : String contact=databaseAccess.getContactUs(park); 30 | content.setText(contact); 31 | break; 32 | } 33 | databaseAccess.close(); 34 | } 35 | } 36 | --------------------------------------------------------------------------------