├── settings.gradle ├── AndroidBootcamp ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── assets │ │ │ └── treasures │ │ │ │ ├── Treasures1.jpg │ │ │ │ ├── Treasures2.jpg │ │ │ │ ├── Treasures3.jpg │ │ │ │ ├── Treasures4.jpg │ │ │ │ ├── Treasures5.jpg │ │ │ │ ├── Treasures6.jpg │ │ │ │ ├── Treasures7.jpg │ │ │ │ └── Treasures8.jpg │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── layout │ │ │ │ ├── activity_hello.xml │ │ │ │ ├── fragment_map.xml │ │ │ │ ├── fragment_treasure_list.xml │ │ │ │ ├── activity_whoami.xml │ │ │ │ └── fragment_high_scores.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── menu │ │ │ │ ├── who_am_i.xml │ │ │ │ └── hello_android.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── thoughtworks │ │ │ │ └── androidbootcamp │ │ │ │ ├── util │ │ │ │ ├── Properties.java │ │ │ │ ├── TreasureService.java │ │ │ │ ├── FileUtils.java │ │ │ │ └── TreasureLoader.java │ │ │ │ ├── model │ │ │ │ ├── Locatable.java │ │ │ │ ├── Score.java │ │ │ │ ├── Attempt.java │ │ │ │ ├── Treasure.java │ │ │ │ └── Game.java │ │ │ │ └── controller │ │ │ │ ├── WhoAmIActivity.java │ │ │ │ ├── adapter │ │ │ │ ├── HighScoreAdapter.java │ │ │ │ └── TreasureListAdapter.java │ │ │ │ ├── fragment │ │ │ │ ├── HighScoresFragment.java │ │ │ │ ├── TreasureMapFragment.java │ │ │ │ └── TreasureListFragment.java │ │ │ │ └── HelloAndroid.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ ├── libs │ │ └── espresso-1.0-SNAPSHOT-bundled.jar │ │ └── java │ │ └── com │ │ └── thoughtworks │ │ └── androidbootcamp │ │ └── test │ │ ├── helpers │ │ ├── Given.java │ │ └── When.java │ │ └── HelloAndroidTest.java └── build.gradle ├── .gitignore ├── AndroidBootcampTest ├── .gitignore ├── src │ └── test │ │ ├── resources │ │ └── org.robolectric.Config.properties │ │ └── java │ │ └── com │ │ └── thoughtworks │ │ └── androidbootcamp │ │ ├── model │ │ ├── AttemptTest.java │ │ └── GameTest.java │ │ └── controller │ │ ├── adapter │ │ └── TreasureListAdapterTest.java │ │ ├── fragment │ │ └── TreasureListFragmentTest.java │ │ └── HelloAndroidUnitTest.java └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew.bat ├── BDDinAS.md ├── gradlew └── README.md /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':AndroidBootcamp', ':AndroidBootcampTest' -------------------------------------------------------------------------------- /AndroidBootcamp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea/ 3 | .DS_Store 4 | *.iml 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/ 4 | .DS_Store 5 | *.iml 6 | -------------------------------------------------------------------------------- /AndroidBootcampTest/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | .gradle 3 | /local.properties 4 | /.idea/ 5 | .DS_Store 6 | *.iml -------------------------------------------------------------------------------- /AndroidBootcampTest/src/test/resources/org.robolectric.Config.properties: -------------------------------------------------------------------------------- 1 | manifest=../AndroidBootcamp/src/main/AndroidManifest.xml -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures1.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures2.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures3.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures4.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures5.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures6.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures7.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/assets/treasures/Treasures8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/assets/treasures/Treasures8.jpg -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidBootcamp/src/androidTest/libs/espresso-1.0-SNAPSHOT-bundled.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThoughtWorksAustralia/AndroidBootcampProject/HEAD/AndroidBootcamp/src/androidTest/libs/espresso-1.0-SNAPSHOT-bundled.jar -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F68E2D 4 | #FFFFFF 5 | #F6E9DD 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 19 23:03:56 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip 7 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/util/Properties.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.util; 2 | 3 | /** 4 | * Created by trogdor on 2/04/14. 5 | */ 6 | public class Properties { 7 | public static String SERVICE_URL = "http://android-bootcamp-rest-server.herokuapp.com"; 8 | } 9 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/layout/activity_hello.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/model/Locatable.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.model; 2 | 3 | /** 4 | * Created by macosgrove on 27/04/2014. 5 | */ 6 | public interface Locatable { 7 | public double getLatitude(); 8 | public double getLongitude(); 9 | public void setCoordinates(double latitude, double longitude); 10 | public String getName(); 11 | } 12 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/layout/fragment_map.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/menu/who_am_i.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/menu/hello_android.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /AndroidBootcampTest/src/test/java/com/thoughtworks/androidbootcamp/model/AttemptTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.model; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | import static org.hamcrest.core.IsEqual.equalTo; 7 | 8 | /** 9 | * Created by macosgrove on 4/05/2014. 10 | */ 11 | public class AttemptTest { 12 | 13 | @Test 14 | public void nameShouldIncludeCountAndDistance() { 15 | Attempt attempt = new Attempt(1, 2, "", 7); 16 | attempt.setDistance(53); 17 | assertThat(attempt.getName(), equalTo("Attempt 7: 53m")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 24dp 7 | 8 | 36sp 9 | 24sp 10 | 20sp 11 | 160dp 12 | 10dp 13 | 14 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/util/TreasureService.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.util; 2 | 3 | import com.thoughtworks.androidbootcamp.model.Score; 4 | import com.thoughtworks.androidbootcamp.model.Treasure; 5 | 6 | import java.util.List; 7 | 8 | import retrofit.Callback; 9 | import retrofit.http.Body; 10 | import retrofit.http.GET; 11 | import retrofit.http.POST; 12 | 13 | /** 14 | * Created by trogdor on 2/04/14. 15 | */ 16 | public interface TreasureService { 17 | @GET("/treasures") 18 | List listTreasures(); 19 | 20 | @GET("/players/top/10") 21 | List listHighScores(); 22 | 23 | @POST("/players") 24 | void postScore(@Body Score score, Callback scoreCallback); 25 | } 26 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/androidTest/java/com/thoughtworks/androidbootcamp/test/helpers/Given.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.test.helpers; 2 | 3 | import com.thoughtworks.androidbootcamp.R; 4 | 5 | import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView; 6 | import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click; 7 | import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.typeText; 8 | import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId; 9 | 10 | /** 11 | * Created by macosgrove on 4/01/2014. 12 | * Setup methods to make the functional tests more readable, in BDD style 13 | */ 14 | public class Given { 15 | public static void thePlayerHasEnteredTheirName() { 16 | onView(withId(R.id.player_field)).perform(typeText("Joe")); 17 | onView(withId(R.id.player_ok_button)).perform(click()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AndroidBootcamp 5 | Treasure List 6 | High Scores 7 | Map 8 | Settings 9 | Who Am I 10 | What is your name? 11 | OK 12 | Find these treasures: 13 | High Scores: 14 | Map: 15 | Hello blank fragment 16 | Finish the Game! 17 | 18 | Good game! Your final score was %d. \nCheck out the Treasure Map to see where all the treasures are. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/androidTest/java/com/thoughtworks/androidbootcamp/test/helpers/When.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.test.helpers; 2 | 3 | import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData; 4 | import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView; 5 | import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click; 6 | import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText; 7 | import static org.hamcrest.core.AllOf.allOf; 8 | import static org.hamcrest.core.Is.is; 9 | import static org.hamcrest.core.IsInstanceOf.instanceOf; 10 | 11 | /** 12 | * Created by macosgrove on 4/01/2014. 13 | * Action methods to make the functional tests more readable, in BDD style 14 | */ 15 | public class When { 16 | public static void iOpenTheMenuAndSelectItem(String menuItem) { 17 | onView(withText("Treasure List")).perform(click()); 18 | onData(allOf(is(instanceOf(String.class)), is(menuItem))) 19 | .perform(click()); 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AndroidBootcampTest/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenLocal() 4 | mavenCentral() 5 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.7.+' 9 | classpath 'com.novoda:gradle-android-test-plugin:0.9.8-SNAPSHOT' 10 | } 11 | } 12 | 13 | repositories { 14 | mavenLocal() 15 | mavenCentral() 16 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 17 | } 18 | 19 | apply plugin: 'java' 20 | apply plugin: 'android-test' 21 | 22 | android { 23 | projectUnderTest ':AndroidBootcamp' 24 | } 25 | 26 | dependencies { 27 | testCompile 'org.hamcrest:hamcrest-all:1.3' 28 | testCompile 'com.android.support:support-v4:19.0.1' 29 | testCompile 'com.google.collections:google-collections:1.0' 30 | testCompile 'junit:junit:4.11' 31 | testCompile 'org.mockito:mockito-core:1.9.5' 32 | testCompile 'com.squareup:fest-android:1.0.7' 33 | testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 34 | } 35 | -------------------------------------------------------------------------------- /AndroidBootcamp/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.9.+' 7 | classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.9.+' 8 | } 9 | } 10 | apply plugin: 'android-sdk-manager' 11 | apply plugin: 'android' 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | android { 18 | compileSdkVersion 19 19 | buildToolsVersion '19.0.3' 20 | 21 | defaultConfig { 22 | minSdkVersion 17 23 | targetSdkVersion 19 24 | testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" 25 | } 26 | } 27 | 28 | dependencies { 29 | compile 'com.android.support:appcompat-v7:+' 30 | compile 'com.android.support:support-v4:+' 31 | compile 'com.squareup.picasso:picasso:+' 32 | compile 'com.squareup.retrofit:retrofit:1.5.0' 33 | compile 'com.google.collections:google-collections:1.0' 34 | compile 'com.google.android.gms:play-services:4.3.23' 35 | androidTestCompile fileTree(dir: 'src/androidTest/libs', includes: ['*.jar']) 36 | } 37 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/controller/WhoAmIActivity.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.controller; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.EditText; 8 | 9 | import com.thoughtworks.androidbootcamp.R; 10 | 11 | public class WhoAmIActivity extends Activity { 12 | 13 | public static final String PLAYER_DATA = "com.thoughtworks.androidbootcamp.PLAYER_DATA"; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_whoami); 19 | } 20 | 21 | public void returnPlayer(View view) { 22 | 23 | Intent returnIntent = new Intent(); 24 | returnIntent.putExtra(WhoAmIActivity.PLAYER_DATA, getPlayerName()); 25 | 26 | setResult(RESULT_OK, returnIntent); 27 | 28 | finish(); 29 | } 30 | 31 | private String getPlayerName() { 32 | View playerField = findViewById(R.id.player_field); 33 | return ((EditText) playerField).getText().toString(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/layout/fragment_treasure_list.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 15 | 25 | 26 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.util; 2 | 3 | import android.os.Environment; 4 | import android.util.Log; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | 11 | /** 12 | * Created by alex on 11/03/2014. 13 | */ 14 | public class FileUtils { 15 | 16 | private static final String TAG = "FileUtils"; 17 | 18 | public static File getExternalPublicFile(String type, String folder) throws IOException { 19 | File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory( 20 | type), folder); 21 | 22 | if (!mediaStorageDir.exists()) { 23 | if (!mediaStorageDir.mkdirs()) { 24 | Log.d(TAG, "failed to create directory"); 25 | return null; 26 | } 27 | } 28 | 29 | // Create a media file name 30 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 31 | 32 | return File.createTempFile( 33 | "IMG_" + timeStamp, /* prefix */ 34 | ".jpg", /* suffix */ 35 | mediaStorageDir /* directory */ 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/model/Score.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by macosgrove on 21/04/2014. 7 | */ 8 | public class Score implements Serializable { 9 | //For best performance, implement Parcelable rather than Serializable 10 | //See http://www.developerphil.com/parcelable-vs-serializable/, for example 11 | private int gameVersion; 12 | private String id; 13 | private String name; 14 | private int score; 15 | 16 | public Score(String name, int score, int gameVersion) { 17 | this.name = name; 18 | this.score = score; 19 | this.gameVersion = gameVersion; 20 | } 21 | 22 | public int getGameVersion() { 23 | return gameVersion; 24 | } 25 | 26 | public void setGameVersion(int gameVersion) { 27 | this.gameVersion = gameVersion; 28 | } 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public void setId(String id) { 35 | this.id = id; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public int getScore() { 47 | return score; 48 | } 49 | 50 | public void setScore(int score) { 51 | this.score = score; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/java/com/thoughtworks/androidbootcamp/controller/adapter/HighScoreAdapter.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.androidbootcamp.controller.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.TextView; 8 | 9 | import com.thoughtworks.androidbootcamp.model.Score; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by macosgrove on 21/04/2014. 15 | */ 16 | public class HighScoreAdapter extends BaseAdapter { 17 | Context mContext; 18 | List mHighScores; 19 | 20 | public HighScoreAdapter(Context context, List highScores) { 21 | this.mContext = context; 22 | this.mHighScores = highScores; 23 | } 24 | 25 | @Override 26 | public int getCount() { 27 | return mHighScores.size(); 28 | } 29 | 30 | @Override 31 | public Object getItem(int i) { 32 | return mHighScores.get(i); 33 | } 34 | 35 | @Override 36 | public long getItemId(int i) { 37 | return mHighScores.get(i).hashCode(); 38 | } 39 | 40 | @Override 41 | public View getView(int i, View view, ViewGroup viewGroup) { 42 | TextView textView = (view == null) ? new TextView(mContext) : (TextView) view; 43 | Score score = mHighScores.get(i); 44 | textView.setText(score.getName() + " : " + score.getScore()); 45 | return textView; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /AndroidBootcamp/src/main/res/layout/activity_whoami.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 15 | 16 | 24 |