Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KGregPFerenc
AndroidOnlabKviz2018
Commits
189c6d35
Commit
189c6d35
authored
Apr 12, 2018
by
fpeterfalvi
Browse files
QuizUpActivity bug fixes
parent
201e2c79
Changes
7
Hide whitespace changes
Inline
Side-by-side
KvizClient/app/src/main/AndroidManifest.xml
View file @
189c6d35
...
...
@@ -36,7 +36,8 @@
<activity
android:name=
".GameActivity"
android:screenOrientation=
"portrait"
></activity>
<activity
android:name=
".QuizUpActivity"
></activity>
<activity
android:name=
".QuizUpActivity"
android:screenOrientation=
"portrait"
></activity>
</application>
</manifest>
\ No newline at end of file
KvizServer/app/src/main/AndroidManifest.xml
View file @
189c6d35
...
...
@@ -35,7 +35,8 @@
android:screenOrientation=
"landscape"
android:theme=
"@style/AppTheme.NoActionBar"
/>
<activity
android:name=
".GameActivity"
/>
<activity
android:name=
".QuizUpActivity"
></activity>
<activity
android:name=
".QuizUpActivity"
>
</activity>
</application>
</manifest>
\ No newline at end of file
KvizServer/app/src/main/java/onlab/kvizserver/GameActivity.java
View file @
189c6d35
...
...
@@ -53,6 +53,8 @@ public class GameActivity extends AppCompatActivity {
String
questionString
;
TextView
correctAnswerTextView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -88,6 +90,7 @@ public class GameActivity extends AppCompatActivity {
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer2TextView
));
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer3TextView
));
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer4TextView
));
correctAnswerTextView
=
(
TextView
)
findViewById
(
R
.
id
.
CorrectAnswerTextView
);
final
LinearLayout
playerAnswersLinearLayout
=
(
LinearLayout
)
findViewById
(
R
.
id
.
PlayerAnswers
);
numberOfPlayers
=
ClientHolder
.
size
();
...
...
@@ -122,6 +125,7 @@ public class GameActivity extends AppCompatActivity {
MultipleChoiceQuestion
question
=
questions
.
get
(
questionIndex
);
questionString
=
question
.
getQuestionText
();
questionText
.
setText
(
questionString
);
correctAnswerTextView
.
setText
(
"Correct answer: "
+
question
.
getCorrectAnswer
());
for
(
int
i
=
0
;
i
<
numberOfPlayers
;
i
++)
{
playerAnswers
[
i
]
=
-
1
;
...
...
KvizServer/app/src/main/java/onlab/kvizserver/LobbyActivity.java
View file @
189c6d35
...
...
@@ -18,6 +18,7 @@ import android.util.Log;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
...
...
@@ -105,18 +106,22 @@ public class LobbyActivity extends AppCompatActivity {
startGameBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
exit
=
false
;
serverThread
.
interrupt
();
commThread
.
interrupt
();
ClientHolder
.
addAll
(
clients
);
Intent
intent
;
if
(
gameMode
.
equals
(
"normal"
))
{
intent
=
new
Intent
(
getApplicationContext
(),
GameActivity
.
class
);
if
(
gameMode
.
equals
(
"quizup"
)
&&
(
clients
.
size
()
!=
2
))
{
Toast
.
makeText
(
getApplicationContext
(),
"QuizUp mode requires exactly 2 players!"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
intent
=
new
Intent
(
getApplicationContext
(),
QuizUpActivity
.
class
);
exit
=
false
;
serverThread
.
interrupt
();
commThread
.
interrupt
();
ClientHolder
.
addAll
(
clients
);
Intent
intent
;
if
(
gameMode
.
equals
(
"normal"
))
{
intent
=
new
Intent
(
getApplicationContext
(),
GameActivity
.
class
);
}
else
{
intent
=
new
Intent
(
getApplicationContext
(),
QuizUpActivity
.
class
);
}
intent
.
putExtra
(
"QUESTION_FILE_NAME"
,
questionFileName
);
startActivity
(
intent
);
}
intent
.
putExtra
(
"QUESTION_FILE_NAME"
,
questionFileName
);
startActivity
(
intent
);
}
});
}
...
...
KvizServer/app/src/main/java/onlab/kvizserver/QuizUpActivity.java
View file @
189c6d35
...
...
@@ -5,9 +5,7 @@ import android.support.v7.app.AppCompatActivity;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
...
...
@@ -44,13 +42,14 @@ public class QuizUpActivity extends AppCompatActivity {
private
final
List
<
TextView
>
playerScoreTextViews
=
new
ArrayList
<>();
private
TextView
questionText
;
private
List
<
TextView
>
answerTextViews
;
private
TextView
correctAnswerTextView
;
private
Handler
updateConversationHandler
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_
game
);
setContentView
(
R
.
layout
.
activity_
quiz_up
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
Bundle
extras
=
getIntent
().
getExtras
();
...
...
@@ -82,6 +81,7 @@ public class QuizUpActivity extends AppCompatActivity {
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer2TextView
));
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer3TextView
));
answerTextViews
.
add
((
TextView
)
findViewById
(
R
.
id
.
Answer4TextView
));
correctAnswerTextView
=
(
TextView
)
findViewById
(
R
.
id
.
CorrectAnswerTextView
);
final
LinearLayout
playerAnswersLinearLayout
=
(
LinearLayout
)
findViewById
(
R
.
id
.
PlayerAnswers
);
numberOfPlayers
=
ClientHolder
.
size
();
...
...
@@ -126,7 +126,6 @@ public class QuizUpActivity extends AppCompatActivity {
newthread
.
start
();
}
sendNextQuestionDelayed
(
5000
);
sendTextMessageDelayed
(
"Round 1"
,
3500
);
sendNextQuestionDelayed
(
5000
);
}
...
...
@@ -154,6 +153,8 @@ public class QuizUpActivity extends AppCompatActivity {
}
}
correctAnswerTextView
.
setText
(
"The correct answer: "
);
for
(
int
i
=
0
;
i
<
outputs
.
size
();
i
++)
{
playerAnswerTextViews
.
get
(
i
).
setText
(
"The answer of the "
+
Integer
.
toString
(
i
+
1
)
+
". player: "
);
String
message
=
"question##"
+
Integer
.
toString
(
playerScores
[
i
])
+
"##"
...
...
@@ -206,6 +207,7 @@ public class QuizUpActivity extends AppCompatActivity {
}
private
void
sendResults
()
{
updateConversationHandler
.
post
(
new
QuizUpActivity
.
updateUIThread
(-
1
,
""
));
//show correct answer
for
(
int
i
=
0
;
i
<
outputs
.
size
();
i
++)
{
String
message
=
"answer##"
+
Integer
.
toString
(
playerScores
[
i
])
+
"##"
+
Integer
.
toString
(
playerScores
[
1
-
i
])
+
"##"
+
questionString
...
...
@@ -261,7 +263,7 @@ public class QuizUpActivity extends AppCompatActivity {
playerAnswers
[
index
]
=
answerInt
;
if
(
playerAnswers
[
index
]
==
correctAnswer
)
{
int
gainedScore
=
(
int
)
(
21
-
Double
.
parseDouble
(
strings
[
1
]));
if
(
round
<
6
)
{
if
(
round
<
7
)
{
playerScores
[
index
]
+=
gainedScore
;
}
else
{
playerScores
[
index
]
+=
2
*
gainedScore
;
...
...
@@ -298,9 +300,13 @@ public class QuizUpActivity extends AppCompatActivity {
@Override
public
void
run
()
{
playerAnswerTextViews
.
get
(
index
).
setText
(
"The answer of the "
+
Integer
.
toString
(
index
+
1
)
+
". player: "
+
msg
);
playerScoreTextViews
.
get
(
index
).
setText
(
"The score of the "
+
Integer
.
toString
(
index
+
1
)
+
". player: "
+
Integer
.
toString
(
playerScores
[
index
]));
if
(
index
==
-
1
)
{
correctAnswerTextView
.
setText
(
"The correct answer: "
+
answers
.
get
(
correctAnswer
));
}
else
{
playerAnswerTextViews
.
get
(
index
).
setText
(
"The answer of the "
+
Integer
.
toString
(
index
+
1
)
+
". player: "
+
msg
);
playerScoreTextViews
.
get
(
index
).
setText
(
"The score of the "
+
Integer
.
toString
(
index
+
1
)
+
". player: "
+
Integer
.
toString
(
playerScores
[
index
]));
}
}
}
...
...
KvizServer/app/src/main/res/layout/activity_game.xml
View file @
189c6d35
...
...
@@ -14,38 +14,39 @@
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"The place of the question."
android:id=
"@+id/QuestionText"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Answer1"
android:id=
"@+id/Answer1TextView"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Answer2"
android:id=
"@+id/Answer2TextView"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Answer3"
android:id=
"@+id/Answer3TextView"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Answer4"
android:id=
"@+id/Answer4TextView"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/CorrectAnswerTextView"
android:textSize=
"30sp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
KvizServer/app/src/main/res/layout/activity_quiz_up.xml
View file @
189c6d35
...
...
@@ -41,6 +41,12 @@
android:id=
"@+id/Answer4TextView"
android:textSize=
"30sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/CorrectAnswerTextView"
android:textSize=
"30sp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment