Skip to content

Commit

Permalink
View Solutions feature added...
Browse files Browse the repository at this point in the history
  • Loading branch information
theMr17 committed Dec 13, 2022
1 parent 4c7093c commit 50808f5
Show file tree
Hide file tree
Showing 22 changed files with 537 additions and 47 deletions.
21 changes: 14 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,49 @@
android:theme="@style/Theme.Queezy"
tools:targetApi="31">
<activity
android:name=".StatsActivity"
android:name=".activity.SolutionsActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".QuizActivity"
android:name=".activity.StatsActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".CreateAccountActivity"
android:name=".activity.QuizActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".LoginActivity"
android:name=".activity.CreateAccountActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".WelcomeActivity"
android:name=".activity.LoginActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".SplashActivity"
android:name=".activity.WelcomeActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".activity.SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -63,7 +70,7 @@
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:name=".activity.MainActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.mr_17.queezy.R

class CreateAccountActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.mr_17.queezy.R

class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import android.app.Activity
import android.content.Intent
Expand All @@ -11,11 +11,12 @@ import android.widget.Spinner
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.mr_17.queezy.R
import com.mr_17.queezy.api.Api
import com.mr_17.queezy.api.ApiCount
import com.mr_17.queezy.api.QuizQuestions
import com.mr_17.queezy.api.Result
import com.mr_17.queezy.question.Question
import com.mr_17.queezy.model.Question
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand Down Expand Up @@ -152,17 +153,28 @@ class MainActivity : AppCompatActivity() {
}
Log.v("answers", q!!.Answer.toString())
}
}
q!!.question?.get(0)?.let { Log.v("question1", it) }
q!!.question!!.get(0)!!.let { Log.v("question1", it) }

loading!!.visibility = View.GONE
startQuizButton!!.visibility = View.VISIBLE
loading!!.visibility = View.GONE
startQuizButton!!.visibility = View.VISIBLE

val intent = Intent(this@MainActivity, QuizActivity::class.java)
intent.putExtra("question", q)
intent.putExtra("category", categorySpinner!!.selectedItem.toString())
intent.putExtra("difficulty", difficultySpinner!!.selectedItem.toString())
startActivity(intent)
}
else {
Toast.makeText(
applicationContext,
"No questions available in this particular Category & Difficulty",
Toast.LENGTH_SHORT
)
.show()
loading!!.visibility = View.GONE
startQuizButton!!.visibility = View.VISIBLE
}

val intent = Intent(this@MainActivity, QuizActivity::class.java)
intent.putExtra("question", q)
intent.putExtra("category", categorySpinner!!.selectedItem.toString())
intent.putExtra("difficulty", difficultySpinner!!.selectedItem.toString())
startActivity(intent)
}

override fun onFailure(call: Call<QuizQuestions?>, t: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.get
import com.google.android.material.progressindicator.CircularProgressIndicator
import com.mr_17.queezy.question.Question
import com.mr_17.queezy.R
import com.mr_17.queezy.model.Question

class QuizActivity : AppCompatActivity() {

Expand Down Expand Up @@ -54,6 +54,7 @@ class QuizActivity : AppCompatActivity() {
val intent = Intent(this@QuizActivity, StatsActivity::class.java)
intent.putExtra("qAndA", qAndA)
intent.putIntegerArrayListExtra("selectedOptions", selectedOptions)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent)
}
}
Expand Down
72 changes: 72 additions & 0 deletions app/src/main/java/com/mr_17/queezy/activity/SolutionsActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.mr_17.queezy.activity

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mr_17.queezy.R
import com.mr_17.queezy.adapter.SolutionsActivityRecyclerViewAdapter
import com.mr_17.queezy.model.Question
import com.mr_17.queezy.model.SolutionsActivityRecyclerViewModel

class SolutionsActivity : AppCompatActivity() {

private var qAndA: Question? = null

private var toolbar: Toolbar? = null

private var selectedOptions: ArrayList<Int>? = null
private var answer: ArrayList<Int>? = null

private var recyclerView: RecyclerView? = null
private var list: java.util.ArrayList<SolutionsActivityRecyclerViewModel>? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_solutions)

InitializeFields()
InitializeSolutionsRecyclerView()
}

private fun InitializeFields()
{
qAndA = intent.getSerializableExtra("qAndA") as Question?
selectedOptions = intent.getSerializableExtra("selectedOptions") as ArrayList<Int>?
answer = intent.getIntegerArrayListExtra("answers") as ArrayList<Int>

recyclerView = findViewById(R.id.recycler_view)

toolbar = findViewById(R.id.toolbar)
toolbar!!.setNavigationOnClickListener { onBackPressed() }

}

private fun InitializeSolutionsRecyclerView() {
recyclerView!!.layoutManager = LinearLayoutManager(this)
list = ArrayList()

for (i in answer!!.indices) {
list!!.add(SolutionsActivityRecyclerViewModel(
"Question " + (i+1).toString() + " of " + answer!!.size,
"",
qAndA!!.question!!.get(i),
qAndA!!.optA!!.get(i),
qAndA!!.optB!!.get(i),
qAndA!!.optC!!.get(i),
qAndA!!.optD!!.get(i),
answer!!.get(i),
selectedOptions!!.get(i)
)
)
}

// This will pass the ArrayList to our Adapter
val adapter = SolutionsActivityRecyclerViewAdapter(list!!)

// Setting the Adapter with the recyclerview
recyclerView!!.adapter = adapter
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import com.mr_17.queezy.R

class SplashActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import com.mr_17.queezy.question.Question
import com.mr_17.queezy.R
import com.mr_17.queezy.model.Question

class StatsActivity : AppCompatActivity() {

Expand All @@ -23,6 +26,8 @@ class StatsActivity : AppCompatActivity() {
private var completionPercentageTextView: TextView? = null
private var skippedTextView: TextView? = null

private var viewSolutionsButton: Button? = null
private var homeButton: Button? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -31,6 +36,19 @@ class StatsActivity : AppCompatActivity() {
InitializeFields()
GetStats()
SetStats()

viewSolutionsButton!!.setOnClickListener {
val intent = Intent(this@StatsActivity, SolutionsActivity::class.java)
intent.putExtra("qAndA", qAndA)
intent.putIntegerArrayListExtra("answers", answer)
intent.putIntegerArrayListExtra("selectedOptions", selectedOptions)
startActivity(intent)
}

homeButton!!.setOnClickListener {
val intent = Intent(this@StatsActivity, MainActivity::class.java)
startActivity(intent)
}
}

private fun InitializeFields()
Expand All @@ -44,6 +62,8 @@ class StatsActivity : AppCompatActivity() {
incorrectAnswerCountTextView = findViewById(R.id.incorrect_answers_count)
completionPercentageTextView = findViewById(R.id.completion_percent)
skippedTextView = findViewById(R.id.skipped_count)
viewSolutionsButton = findViewById(R.id.view_solutions_button)
homeButton = findViewById(R.id.home_button)
}

private fun GetStats()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.mr_17.queezy
package com.mr_17.queezy.activity

import android.app.Activity
import android.app.ProgressDialog
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import com.mr_17.queezy.R

class WelcomeActivity : AppCompatActivity() {

Expand Down
Loading

0 comments on commit 50808f5

Please sign in to comment.