Skip to content

Commit

Permalink
Rejoin game when game activity resumed
Browse files Browse the repository at this point in the history
  • Loading branch information
OrdonTeam committed Jan 6, 2015
1 parent a4c008f commit 516ae82
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
</activity>
<activity android:name=".activity.GameActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait"
android:keepScreenOn="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ class GameActivity extends AbstractGamesMatchActivity implements CardsRow.OnCard
}

@Override
void onConnected(Bundle bundle) {
if (invId) {
void onConnected(Bundle connectionHint) {
match = connectionHint?.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH) as TurnBasedMatch;
if (match != null) {
onTurnBasedMatchReceived(match);
} else if (invId) {
Games.TurnBasedMultiplayer.acceptInvitation(client, invId).setResultCallback(this.&initiateMatchResult)
Games.TurnBasedMultiplayer.registerMatchUpdateListener(client, this)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ordonteam.hanabi.gms

import android.os.Bundle
import android.util.Log
import android.view.Window
import android.view.WindowManager
import com.google.android.gms.games.Games
import com.google.android.gms.games.multiplayer.turnbased.OnTurnBasedMatchUpdateReceivedListener
Expand All @@ -12,11 +13,6 @@ import groovy.transform.CompileStatic
abstract class AbstractGamesMatchActivity extends AbstractGamesActivity implements OnTurnBasedMatchUpdateReceivedListener{
protected TurnBasedMatch match

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
protected void leaveMatch() {
if (isMyTurn()) {
Games.TurnBasedMultiplayer.leaveMatchDuringTurn(client, match.getMatchId(), nextPlayerId())
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/ordonteam/hanabi/view/DeckView.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ordonteam.hanabi.view

import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import android.widget.TextView
import com.ordonteam.hanabi.R
Expand All @@ -10,8 +11,8 @@ import groovy.transform.CompileStatic
class DeckView extends LinearLayout {
private TextView textView;

DeckView(Context context) {
super(context)
DeckView(Context context, AttributeSet attrs) {
super(context, attrs)
setBackground( getResources().getDrawable(R.drawable.ic_launcher))

textView = new BigTextView(context, "50")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GameInfoView extends LinearLayout {
thunderImage = new ImageView(context)
thundersNumberText = new TextView(context, attrs)

deck = new DeckView(context)
deck = new DeckView(context, attrs)
knownCards = new CardView(context, attrs)

tipsImgage.setImageResource(R.drawable.question)
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/game_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:alpha="0.5"
android:background="@color/wallet_bright_foreground_holo_light"
android:alpha="0.5">
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wait for other players"
android:id="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
android:text="Wait for other players" />
</RelativeLayout>

</RelativeLayout>

0 comments on commit 516ae82

Please sign in to comment.