mirror of
https://github.com/Skysamara/android-kotlin-fundamentals-apps.git
synced 2025-12-06 06:16:03 +00:00
Task: Change the Back button's destination
This commit is contained in:
parent
aa3d64ff29
commit
452c69c318
@ -25,6 +25,7 @@ import androidx.databinding.DataBindingUtil
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import com.example.android.navigation.databinding.FragmentGameBinding
|
import com.example.android.navigation.databinding.FragmentGameBinding
|
||||||
|
import java.security.cert.LDAPCertStoreParameters
|
||||||
|
|
||||||
class GameFragment : Fragment() {
|
class GameFragment : Fragment() {
|
||||||
data class Question(
|
data class Question(
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.findNavController
|
||||||
import com.example.android.navigation.databinding.FragmentGameOverBinding
|
import com.example.android.navigation.databinding.FragmentGameOverBinding
|
||||||
|
|
||||||
class GameOverFragment : Fragment() {
|
class GameOverFragment : Fragment() {
|
||||||
@ -30,6 +31,11 @@ class GameOverFragment : Fragment() {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
val binding: FragmentGameOverBinding = DataBindingUtil.inflate(
|
val binding: FragmentGameOverBinding = DataBindingUtil.inflate(
|
||||||
inflater, R.layout.fragment_game_over, container, false)
|
inflater, R.layout.fragment_game_over, container, false)
|
||||||
|
// Add OnClick Handler for Try Again button
|
||||||
|
binding.tryAgainButton.setOnClickListener { view ->
|
||||||
|
view.findNavController().
|
||||||
|
navigate(R.id.action_gameOverFragment_to_gameFragment)
|
||||||
|
}
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.findNavController
|
||||||
import com.example.android.navigation.databinding.FragmentGameWonBinding
|
import com.example.android.navigation.databinding.FragmentGameWonBinding
|
||||||
|
|
||||||
|
|
||||||
@ -31,6 +32,11 @@ class GameWonFragment : Fragment() {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
val binding: FragmentGameWonBinding = DataBindingUtil.inflate(
|
val binding: FragmentGameWonBinding = DataBindingUtil.inflate(
|
||||||
inflater, R.layout.fragment_game_won, container, false)
|
inflater, R.layout.fragment_game_won, container, false)
|
||||||
|
// Add OnClick Handler for Next Match button
|
||||||
|
binding.nextMatchButton.setOnClickListener { view: View ->
|
||||||
|
view.findNavController().
|
||||||
|
navigate(R.id.action_gameWonFragment_to_gameFragment)
|
||||||
|
}
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,19 +21,35 @@
|
|||||||
tools:layout="@layout/fragment_game">
|
tools:layout="@layout/fragment_game">
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_gameFragment_to_gameOverFragment"
|
android:id="@+id/action_gameFragment_to_gameOverFragment"
|
||||||
app:destination="@id/gameOverFragment" />
|
app:destination="@id/gameOverFragment"
|
||||||
|
app:popUpTo="@id/gameFragment"
|
||||||
|
app:popUpToInclusive="true" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_gameFragment_to_gameWonFragment"
|
android:id="@+id/action_gameFragment_to_gameWonFragment"
|
||||||
app:destination="@id/gameWonFragment" />
|
app:destination="@id/gameWonFragment"
|
||||||
|
app:popUpTo="@id/gameFragment"
|
||||||
|
app:popUpToInclusive="true" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/gameOverFragment"
|
android:id="@+id/gameOverFragment"
|
||||||
android:name="com.example.android.navigation.GameOverFragment"
|
android:name="com.example.android.navigation.GameOverFragment"
|
||||||
android:label="fragment_game_over"
|
android:label="fragment_game_over"
|
||||||
tools:layout="@layout/fragment_game_over" />
|
tools:layout="@layout/fragment_game_over" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_gameOverFragment_to_gameFragment"
|
||||||
|
app:destination="@id/gameFragment"
|
||||||
|
app:popUpTo="@id/titleFragment"
|
||||||
|
app:popUpToInclusive="false" />
|
||||||
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/gameWonFragment"
|
android:id="@+id/gameWonFragment"
|
||||||
android:name="com.example.android.navigation.GameWonFragment"
|
android:name="com.example.android.navigation.GameWonFragment"
|
||||||
android:label="fragment_game_won"
|
android:label="fragment_game_won"
|
||||||
tools:layout="@layout/fragment_game_won" />
|
tools:layout="@layout/fragment_game_won" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_gameWonFragment_to_gameFragment"
|
||||||
|
app:destination="@id/gameFragment"
|
||||||
|
app:popUpTo="@id/titleFragment"
|
||||||
|
app:popUpToInclusive="false" />
|
||||||
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
||||||
@ -20,7 +20,7 @@ buildscript {
|
|||||||
navigationVersion = '1.0.0-rc02'
|
navigationVersion = '1.0.0-rc02'
|
||||||
kotlin_version = '1.3.11'
|
kotlin_version = '1.3.11'
|
||||||
archLifecycleVersion = '1.1.1'
|
archLifecycleVersion = '1.1.1'
|
||||||
gradleVersion = '3.3.1'
|
gradleVersion = '3.6.1'
|
||||||
supportlibVersion = '1.0.0-rc03'
|
supportlibVersion = '1.0.0-rc03'
|
||||||
dataBindingCompilerVersion = gradleVersion // Always need to be the same.
|
dataBindingCompilerVersion = gradleVersion // Always need to be the same.
|
||||||
navigationVersion = '1.0.0-rc02'
|
navigationVersion = '1.0.0-rc02'
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#Mon Jan 14 23:13:44 IST 2019
|
#Mon Mar 02 16:33:07 MSK 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
android.databinding.enableV2=true
|
android.databinding.enableV2=true
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user