Skip to content

Commit

Permalink
statistics tab, fixed formatting on roster, color coding for wins/los…
Browse files Browse the repository at this point in the history
…ses/ties
  • Loading branch information
lsiegert committed Apr 13, 2011
1 parent 69082ce commit 5e0b6d2
Show file tree
Hide file tree
Showing 36 changed files with 204 additions and 111 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Expand Up @@ -3,7 +3,7 @@
package="com.lsiegert"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<application android:icon="@drawable/icon_terrible" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".NUHockey"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black">
Expand Down
Binary file modified assets/NUHockey.sqlite
Binary file not shown.
Binary file modified bin/NUHockey.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/com/lsiegert/DatabaseHelper.class
Binary file not shown.
Binary file modified bin/com/lsiegert/NUHockey.class
Binary file not shown.
Binary file modified bin/com/lsiegert/R$drawable.class
Binary file not shown.
Binary file modified bin/com/lsiegert/R$id.class
Binary file not shown.
Binary file modified bin/com/lsiegert/R$layout.class
Binary file not shown.
Binary file modified bin/com/lsiegert/R$string.class
Binary file not shown.
Binary file modified bin/com/lsiegert/RSSActivity.class
Binary file not shown.
Binary file modified bin/com/lsiegert/RosterActivity.class
Binary file not shown.
Binary file modified bin/com/lsiegert/RosterAdapter.class
Binary file not shown.
Binary file modified bin/com/lsiegert/ScheduleActivity.class
Binary file not shown.
Binary file modified bin/com/lsiegert/ScheduleAdapter.class
Binary file not shown.
Binary file modified bin/com/lsiegert/StatsActivity.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
76 changes: 42 additions & 34 deletions gen/com/lsiegert/R.java
Expand Up @@ -14,47 +14,55 @@ public static final class drawable {
public static final int ic_tab_artists_grey=0x7f020000;
public static final int ic_tab_artists_white=0x7f020001;
public static final int ic_tab_roster=0x7f020002;
public static final int ic_tab_rss=0x7f020003;
public static final int ic_tab_schedule=0x7f020004;
public static final int ic_tab_stats=0x7f020005;
public static final int icon=0x7f020006;
public static final int ic_tab_roster_grey=0x7f020003;
public static final int ic_tab_roster_white=0x7f020004;
public static final int ic_tab_rss=0x7f020005;
public static final int ic_tab_rss_gray=0x7f020006;
public static final int ic_tab_rss_grey=0x7f020007;
public static final int ic_tab_rss_white=0x7f020008;
public static final int ic_tab_schedule=0x7f020009;
public static final int ic_tab_stats=0x7f02000a;
public static final int icon=0x7f02000b;
public static final int icon_terrible=0x7f02000c;
}
public static final class id {
public static final int RosterListView=0x7f050001;
public static final int ScheduleListView=0x7f050009;
public static final int StatsListView=0x7f05000e;
public static final int TextView01=0x7f050008;
public static final int attended=0x7f05000d;
public static final int date=0x7f05000a;
public static final int hometown=0x7f050007;
public static final int RosterListView=0x7f050002;
public static final int ScheduleListView=0x7f05000a;
public static final int StatsListView=0x7f050010;
public static final int TextView01=0x7f050009;
public static final int attended=0x7f05000f;
public static final int date=0x7f05000c;
public static final int hometown=0x7f050008;
public static final int list_header_title=0x7f050000;
public static final int name=0x7f050004;
public static final int number=0x7f050003;
public static final int opponent=0x7f05000b;
public static final int position=0x7f050005;
public static final int score=0x7f05000c;
public static final int widget29=0x7f050002;
public static final int year=0x7f050006;
public static final int list_item_title=0x7f050001;
public static final int name=0x7f050005;
public static final int number=0x7f050004;
public static final int opponent=0x7f05000d;
public static final int position=0x7f050006;
public static final int score=0x7f05000e;
public static final int widget2=0x7f050003;
public static final int widget29=0x7f05000b;
public static final int year=0x7f050007;
}
public static final class layout {
public static final int list_header=0x7f030000;
public static final int main=0x7f030001;
public static final int roster=0x7f030002;
public static final int roster_row=0x7f030003;
public static final int rss=0x7f030004;
public static final int rss_row=0x7f030005;
public static final int schedule=0x7f030006;
public static final int schedule_row=0x7f030007;
public static final int stats=0x7f030008;
public static final int list_item=0x7f030001;
public static final int main=0x7f030002;
public static final int roster=0x7f030003;
public static final int roster_row=0x7f030004;
public static final int rss=0x7f030005;
public static final int rss_row=0x7f030006;
public static final int schedule=0x7f030007;
public static final int schedule_row=0x7f030008;
public static final int stats=0x7f030009;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int databaseVersion=0x7f040007;
public static final int hello=0x7f040000;
public static final int roster=0x7f040002;
public static final int rss=0x7f040004;
public static final int schedule=0x7f040003;
public static final int season_prompt=0x7f040006;
public static final int stats=0x7f040005;
public static final int app_name=0x7f040000;
public static final int databaseVersion=0x7f040006;
public static final int roster=0x7f040001;
public static final int rss=0x7f040003;
public static final int schedule=0x7f040002;
public static final int season_prompt=0x7f040005;
public static final int stats=0x7f040004;
}
}
4 changes: 2 additions & 2 deletions res/drawable/ic_tab_roster.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_artists_grey"
<item android:drawable="@drawable/ic_tab_roster_grey"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_artists_white" />
<item android:drawable="@drawable/ic_tab_roster_white" />
</selector>
Binary file added res/drawable/ic_tab_roster_grey.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/ic_tab_roster_white.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions res/drawable/ic_tab_rss.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_artists_grey"
<item android:drawable="@drawable/ic_tab_rss_gray"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_artists_white" />
<item android:drawable="@drawable/ic_tab_rss_white" />
</selector>
Binary file added res/drawable/ic_tab_rss_gray.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/ic_tab_rss_grey.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/ic_tab_rss_white.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/icon_terrible.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions res/layout/list_header.xml
Expand Up @@ -6,5 +6,6 @@
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
style="?android:attr/listSeparatorTextViewStyle" />
android:paddingLeft="5dip"
style="?android:attr/listSeparatorTextViewStyle"
android:textAppearance="?android:attr/textAppearanceLarge" />
11 changes: 11 additions & 0 deletions res/layout/list_item.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:paddingLeft="15dip"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
14 changes: 6 additions & 8 deletions res/layout/roster.xml
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ListView android:id="@+id/RosterListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ListView android:id="@+id/RosterListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
>
</ListView>
53 changes: 26 additions & 27 deletions res/layout/roster_row.xml
@@ -1,56 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget29"
<LinearLayout
android:id="@+id/widget2"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="100"
>
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/number"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Number"
android:gravity="left"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_weight="10"
>
</TextView>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Name"
android:layout_toRightOf="@+id/number"
android:layout_marginLeft="8px"
android:layout_weight="41"
>
</TextView>
<TextView
android:id="@+id/position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Position"
android:layout_below="@+id/number"
android:layout_alignParentLeft="true"
android:layout_weight="5"
>
</TextView>
<TextView
android:id="@+id/year"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Year"
android:layout_below="@+id/name"
android:layout_toRightOf="@+id/position"
android:layout_marginLeft="8px"
android:layout_weight="8"
>
</TextView>
<TextView
android:id="@+id/hometown"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Hometown"
android:layout_below="@+id/name"
android:layout_toRightOf="@+id/year"
android:layout_marginLeft="8px"
android:layout_weight="36"
>
</TextView>
</RelativeLayout>
</LinearLayout>
4 changes: 2 additions & 2 deletions res/layout/rss_row.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TextView01" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15sp"/>
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"/>
3 changes: 1 addition & 2 deletions res/values/strings.xml
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, NUHockey!</string>
<string name="app_name">Northeastern Hockey</string>
<string name="roster">Roster</string>
<string name="schedule">Schedule</string>
<string name="rss">RSS</string>
<string name="stats">Your Stats</string>
<string name="season_prompt">Select a season</string>
<item type="string" name="databaseVersion" format="integer">2</item>
<item type="string" name="databaseVersion" format="integer">3</item>
</resources>
49 changes: 41 additions & 8 deletions src/com/lsiegert/DatabaseHelper.java
Expand Up @@ -29,8 +29,7 @@ public class DatabaseHelper extends SQLiteOpenHelper{
* @param context
*/
public DatabaseHelper(Context context) {

super(context, DB_NAME, null, 1);
super(context, DB_NAME, null, R.string.databaseVersion);
this.myContext = context;
}

Expand All @@ -42,7 +41,7 @@ public void createDatabase() throws IOException{
boolean dbExists = checkDatabase();
SQLiteDatabase db_Read = null;

if(dbExists){
if(false){
//do nothing - database already exists
}else{
db_Read = this.getReadableDatabase();
Expand Down Expand Up @@ -145,7 +144,7 @@ public Cursor getGamesBySeason(String season) {
return myDb.query("Games", null, "season = ?", new String[]{season}, null, null, "date");
}

// W-L-T record across games the user has attended
// W-L-T record across all games the user has attended
public String getRecord() {
String wins = "select _id from Games where nuscore > oppscore and attended=1";
String losses = "select _id from Games where nuscore < oppscore and attended=1";
Expand All @@ -156,9 +155,43 @@ public String getRecord() {
return w + "-" + l + "-" + t;
}

// total number of goals in games the user has attended
public int getTotalGoalsSeen() {
Cursor goals = myDb.rawQuery("select sum(nuscore) from Games where attended=1", null);
return goals.getInt(0);
// W-L-T record across games the user has attended, by location
public String getRecordByLocation(String location){
String wins = "select _id from Games where nuscore > oppscore and attended=1 and location=?";
String losses = "select _id from Games where nuscore < oppscore and attended=1 and location=?";
String ties = "select _id from Games where nuscore = oppscore and attended=1 and location=?";
String[] args = new String[]{location};
int w = myDb.rawQuery(wins, args).getCount();
int l = myDb.rawQuery(losses, args).getCount();
int t = myDb.rawQuery(ties, args).getCount();
return w + "-" + l + "-" + t;
}

public int getNumOfTeams() {
String query = "select distinct opponent from Games where attended=1";
return myDb.rawQuery(query, null).getCount();
}

public int getNumOfGoals() {
String query = "select nuscore from Games where attended=1";
Cursor allGoals = myDb.rawQuery(query, null);
allGoals.moveToFirst();
int totalGoals = 0;
while (!allGoals.isAfterLast()) {
totalGoals = totalGoals + allGoals.getInt(0);
allGoals.moveToNext();
}
return totalGoals;
}

public int getNumOfShutouts() {
String query = "select _id from Games where attended=1 and oppscore=0";
return myDb.rawQuery(query, null).getCount();
}

public int getNumOfWinsAtAgganis() {
String query ="select _id from Games where attended=1 and " +
"nuscore>oppscore and opponent='boston university' and location='away'";
return myDb.rawQuery(query, null).getCount();
}
}
4 changes: 2 additions & 2 deletions src/com/lsiegert/ScheduleActivity.java
Expand Up @@ -25,18 +25,18 @@ public void onCreate(Bundle savedInstanceState) {

SeparatedListAdapter adapter = new SeparatedListAdapter(this);
Cursor seasons = dbHelper.getAllSeasons();
startManagingCursor(seasons);

seasons.moveToFirst();
while (!seasons.isAfterLast()) {
String season = seasons.getString(0);
Cursor games = dbHelper.getGamesBySeason(season);
startManagingCursor(games);
ScheduleAdapter scheduleAdapter = new ScheduleAdapter(this, R.layout.schedule_row, games, null, null, dbHelper);
adapter.addSection(season, scheduleAdapter);
seasons.moveToNext();
}

setListAdapter(adapter);
}


}
13 changes: 12 additions & 1 deletion src/com/lsiegert/ScheduleAdapter.java
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -62,7 +63,17 @@ else if (location.contains("away")) {
}

TextView gameScore = (TextView) convertView.findViewById(R.id.score);
gameScore.setText(games.getString(4) + "-" + games.getString(5));
int nuscore = games.getInt(4);
int oppscore = games.getInt(5);

gameScore.setText(nuscore + "-" + oppscore);
if (nuscore > oppscore) {
gameScore.setTextColor(Color.GREEN);
}
else if (nuscore < oppscore) {
gameScore.setTextColor(Color.RED);
}
else { gameScore.setTextColor(Color.WHITE); }

CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.attended);
checkBox.setTag(Integer.parseInt(this.games.getString(this.games.getColumnIndex("_id"))));
Expand Down

0 comments on commit 5e0b6d2

Please sign in to comment.