Created
November 14, 2016 20:07
-
-
Save claraj/79a75094e7521b0a3c60b558ade3131b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.bignerdranch.android.scavengerhunttemp; | |
| import android.app.DownloadManager; | |
| import android.content.Intent; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.view.View; | |
| import android.widget.ArrayAdapter; | |
| import android.widget.Button; | |
| import android.widget.ListView; | |
| import android.widget.TextView; | |
| import java.util.ArrayList; | |
| public class MainActivity extends AppCompatActivity { | |
| Button mStartButton; | |
| Button mNewHuntButton; | |
| ListView mHuntListView; | |
| Firebase mFirebase; | |
| ArrayList mHuntList; | |
| private static final String NEW_HUNT_KEY = "new hunt"; | |
| private static final int NEW_HUNT_CODE = 0; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| mStartButton = (Button) findViewById(R.id.start_hunt_button); | |
| mHuntListView = (ListView) findViewById(R.id.hunt_list_view); | |
| mNewHuntButton = (Button) findViewById(R.id.new_hunt_button); | |
| ArrayAdapter arrayAdapter = new ArrayAdapter(MainActivity.this, R.layout.list_view, R.id.list_view_text); | |
| mHuntListView.setAdapter(arrayAdapter); | |
| mFirebase = new Firebase(); | |
| mFirebase.getAllScavengerLists(); | |
| mNewHuntButton.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| Intent intent = new Intent(MainActivity.this, HuntEntryScreen.class); | |
| startActivityForResult(intent, NEW_HUNT_CODE); | |
| } | |
| }); | |
| mStartButton.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| //figure out what was selected in the list | |
| //get the ScavengertHunt object that was selected | |
| //start new activity with the selected ScavengerHunt | |
| //create an example ScavengerHunt. | |
| // Replace the example with actual hunt once list of hunts, obtained from Firebase, is working | |
| ScavengerHunt hunt = new ScavengerHunt(); | |
| ArrayList<Item> items = new ArrayList<>(); | |
| Item item1 = new Item("IDS Center", 43, -90.9); | |
| Item item2 = new Item("MCTC", 44, -93.9); | |
| Item item3 = new Item("Loring Park", 42.4, -90); | |
| Item item4 = new Item("Starbucks", 47.4, -92.3); | |
| items.add(item1); | |
| items.add(item2); | |
| items.add(item3); | |
| items.add(item4); | |
| hunt.setPlaces(items); | |
| hunt.setHuntName("Hunt 1"); | |
| Intent intent = new Intent(MainActivity.this, ActiveHuntActivity.class); | |
| intent.putExtra("HUNT", hunt); //todo make constant variable for key | |
| startActivity(intent); | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment