Skip to content

Commit

Permalink
Selector for buttons onClick (bugged), need fix
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow committed Feb 5, 2015
1 parent 32a565e commit 50bb53a
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 50 deletions.
Binary file modified bin/SpeedTrain.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/DBHelper.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/Game.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/MainMenu.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$drawable.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$id.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$layout.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$menu.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$string.class
Binary file not shown.
Binary file modified bin/classes/com/example/speedtrain/R$style.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
43 changes: 23 additions & 20 deletions gen/com/example/speedtrain/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,29 @@ public static final class dimen {
}
public static final class drawable {
public static final int button=0x7f020000;
public static final int buttonclicked=0x7f020001;
public static final int combo=0x7f020002;
public static final int ds=0x7f020003;
public static final int fail=0x7f020004;
public static final int h=0x7f020005;
public static final int header_game=0x7f020006;
public static final int ic_launcher=0x7f020007;
public static final int main_menu=0x7f020008;
public static final int manual1=0x7f020009;
public static final int manual2=0x7f02000a;
public static final int menu=0x7f02000b;
public static final int menu_clicked=0x7f02000c;
public static final int o=0x7f02000d;
public static final int pause=0x7f02000e;
public static final int r=0x7f02000f;
public static final int records_title=0x7f020010;
public static final int success=0x7f020011;
public static final int text=0x7f020012;
public static final int textclicked=0x7f020013;
public static final int x=0x7f020014;
public static final int button_grey_big=0x7f020001;
public static final int button_grey_small=0x7f020002;
public static final int button_yellow_small=0x7f020003;
public static final int buttonclicked=0x7f020004;
public static final int combo=0x7f020005;
public static final int ds=0x7f020006;
public static final int fail=0x7f020007;
public static final int h=0x7f020008;
public static final int header_game=0x7f020009;
public static final int ic_launcher=0x7f02000a;
public static final int main_menu=0x7f02000b;
public static final int manual1=0x7f02000c;
public static final int manual2=0x7f02000d;
public static final int menu=0x7f02000e;
public static final int menu_clicked=0x7f02000f;
public static final int o=0x7f020010;
public static final int pause=0x7f020011;
public static final int r=0x7f020012;
public static final int records_title=0x7f020013;
public static final int success=0x7f020014;
public static final int text=0x7f020015;
public static final int textclicked=0x7f020016;
public static final int x=0x7f020017;
}
public static final class id {
public static final int action_settings=0x7f090029;
Expand Down
6 changes: 6 additions & 0 deletions res/drawable-xhdpi/button_grey_big.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/buttonclicked"
android:state_pressed="true" />
<item android:drawable="@drawable/button" />
</animation-list>
6 changes: 6 additions & 0 deletions res/drawable-xhdpi/button_grey_small.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/textclicked"
android:state_pressed="true" />
<item android:drawable="@drawable/text" />
</animation-list>
6 changes: 6 additions & 0 deletions res/drawable-xhdpi/button_yellow_small.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/menu_clicked"
android:state_pressed="true" />
<item android:drawable="@drawable/menu" />
</animation-list>
18 changes: 9 additions & 9 deletions res/layout/game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/button"
android:background="@drawable/button_grey_big"
android:clickable="false"
android:text="No" />

Expand All @@ -90,7 +90,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/button"
android:background="@drawable/button_grey_big"
android:clickable="false"
android:text="Yes" />
</LinearLayout>
Expand Down Expand Up @@ -170,7 +170,7 @@
android:id="@+id/btnStart"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/button"
android:background="@drawable/button_grey_big"
android:clickable="true"
android:text="Touch to star" />
</LinearLayout>
Expand All @@ -194,23 +194,23 @@
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/text"
android:background="@drawable/button_grey_small"
android:text="Resume" />

<Button
android:id="@+id/textRestart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/text"
android:background="@drawable/button_grey_small"
android:text="Restart" />

<Button
android:id="@+id/textQuit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/text"
android:background="@drawable/button_grey_small"
android:text="Quit" />
</LinearLayout>

Expand All @@ -228,7 +228,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button"
android:background="@drawable/button_grey_big"
android:clickable="false"
android:orientation="vertical"
android:visibility="visible" >
Expand Down Expand Up @@ -283,7 +283,7 @@
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/text"
android:background="@drawable/button_grey_small"
android:text="Finish"
android:textAppearance="?android:attr/textAppearanceLarge" />

Expand All @@ -293,7 +293,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:background="@drawable/text"
android:background="@drawable/button_grey_small"
android:text="TryAgain"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Expand Down
6 changes: 3 additions & 3 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:background="@drawable/menu"
android:background="@drawable/button_yellow_small"
android:clickable="true"
android:gravity="center"
android:text="Train"
Expand All @@ -53,7 +53,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:background="@drawable/menu"
android:background="@drawable/button_yellow_small"
android:clickable="true"
android:gravity="center"
android:text="Records"
Expand All @@ -66,7 +66,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:background="@drawable/menu"
android:background="@drawable/button_yellow_small"
android:clickable="true"
android:gravity="center"
android:text="Quit"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/records.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
android:id="@+id/btnBack"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/button"
android:background="@drawable/button_grey_big"
android:clickable="true"
android:text="Back"
android:textSize="30sp" />
Expand Down
12 changes: 7 additions & 5 deletions src/com/example/speedtrain/DBHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

public class DBHelper extends SQLiteOpenHelper {
private static DBHelper instance;
final String TABLE_RECORDS = "records";
final String ROW_SCRORE = "score";

private DBHelper(Context context) {
super(context, "speedTrainDB", null, 1);
Expand All @@ -25,7 +27,7 @@ public static DBHelper getInstance(Context context) {

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE records (id INTEGER PRIMARY KEY AUTOINCREMENT,date LONG,score INTEGER);");
db.execSQL("CREATE TABLE "+ TABLE_RECORDS +" (id INTEGER PRIMARY KEY AUTOINCREMENT,date LONG,"+ ROW_SCRORE +" INTEGER);");
}

@Override
Expand All @@ -36,19 +38,19 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
public void setNewRecord(int record) {
ContentValues cv = new ContentValues();
cv.put("date", SystemClock.uptimeMillis());
cv.put("score", record);
this.getWritableDatabase().insert("records", null, cv);
cv.put(ROW_SCRORE, record);
this.getWritableDatabase().insert(TABLE_RECORDS, null, cv);
this.close();
}

public ArrayList<Integer> getRecords() {
Cursor c = this.getWritableDatabase().query("records",
new String[] { "score" }, null, null, null, null, "score DESC");
new String[] { ROW_SCRORE }, null, null, null, null, ROW_SCRORE + " DESC");
ArrayList<Integer> records = new ArrayList<Integer>();
if (c.moveToFirst()) {
int i = 0;
do {
int scoreColIndex = c.getColumnIndex("score");
int scoreColIndex = c.getColumnIndex(ROW_SCRORE);
records.add(i, c.getInt(scoreColIndex)) ;
i++;
} while (c.moveToNext());
Expand Down
14 changes: 7 additions & 7 deletions src/com/example/speedtrain/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,25 @@ public void onClick(View v) {
pause.setClickable(true);
break;
case R.id.textResume:
textResume.setBackgroundResource(R.drawable.textclicked);
//textResume.setBackgroundResource(R.drawable.textclicked);
pause.setVisibility(View.INVISIBLE);
backToGame();
break;
case R.id.textRestart:
textRestart.setBackgroundResource(R.drawable.textclicked);
//textRestart.setBackgroundResource(R.drawable.textclicked);
restart();
break;
case R.id.textQuit:
textQuit.setBackgroundResource(R.drawable.textclicked);
//textQuit.setBackgroundResource(R.drawable.textclicked);
finish();
break;
case R.id.textFinish:
textFinish.setBackgroundResource(R.drawable.textclicked);
// textFinish.setBackgroundResource(R.drawable.textclicked);
DBHelper.getInstance(this).setNewRecord(score);
finish();
break;
case R.id.textRestart2:
textRestart2.setBackgroundResource(R.drawable.textclicked);
// textRestart2.setBackgroundResource(R.drawable.textclicked);
restart();
break;
}
Expand Down Expand Up @@ -273,8 +273,8 @@ private void pause() {
timePause = SystemClock.uptimeMillis();
customHandler.removeCallbacks(updateTimerThread);
shadow.setVisibility(View.VISIBLE);
textRestart.setBackgroundResource(R.drawable.text);
textResume.setBackgroundResource(R.drawable.text);
// textRestart.setBackgroundResource(R.drawable.text);
// textResume.setBackgroundResource(R.drawable.text);
game.setClickable(false);
textPause.setClickable(false);
btnYes.setClickable(false);
Expand Down
10 changes: 5 additions & 5 deletions src/com/example/speedtrain/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public void onCreate(Bundle savedInstanceState) {
public void onClick(View v) {
switch (v.getId()){
case R.id.train:
textPlay.setBackgroundResource(R.drawable.menu_clicked);
// textPlay.setBackgroundResource(R.drawable.menu_clicked);
Intent intentGame = new Intent(this, Game.class);
startActivity(intentGame);
break;
case R.id.records:
textRecords.setBackgroundResource(R.drawable.menu_clicked);
// textRecords.setBackgroundResource(R.drawable.menu_clicked);
Intent intentRecords = new Intent(this, Records.class);
startActivity(intentRecords);
break;
case R.id.quit:
textQuit.setBackgroundResource(R.drawable.menu_clicked);
// textQuit.setBackgroundResource(R.drawable.menu_clicked);
finish();
break;
}
Expand All @@ -52,7 +52,7 @@ public void onClick(View v) {
@Override
public void onResume(){
super.onResume();
textPlay.setBackgroundResource(R.drawable.menu);
textRecords.setBackgroundResource(R.drawable.menu);
// textPlay.setBackgroundResource(R.drawable.menu);
// textRecords.setBackgroundResource(R.drawable.menu);
}
}

0 comments on commit 50bb53a

Please sign in to comment.