File tree 6 files changed +31
-3
lines changed
java/com/arctouch/codechallenge/ui
6 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ android {
30
30
proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
31
31
}
32
32
}
33
+ kotlinOptions {
34
+ jvmTarget = " 1.8"
35
+ }
33
36
}
34
37
35
38
dependencies {
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ package com.arctouch.codechallenge.ui
2
2
3
3
import android.os.Bundle
4
4
import androidx.appcompat.app.AppCompatActivity
5
+ import androidx.navigation.findNavController
5
6
import androidx.navigation.fragment.NavHostFragment
7
+ import androidx.navigation.ui.AppBarConfiguration
8
+ import androidx.navigation.ui.setupWithNavController
6
9
import com.arctouch.codechallenge.R
7
10
import kotlinx.android.synthetic.main.activity_main.*
8
11
@@ -11,6 +14,14 @@ class MainActivity : AppCompatActivity() {
11
14
override fun onCreate (savedInstanceState : Bundle ? ) {
12
15
super .onCreate(savedInstanceState)
13
16
setContentView(R .layout.activity_main)
17
+ setSupportActionBar(my_toolbar)
18
+ configActionBar()
19
+ }
20
+
21
+ private fun configActionBar () {
22
+ val navController = findNavController(R .id.nav_host_fragment)
23
+ val appBarConfiguration = AppBarConfiguration (navController.graph)
24
+ my_toolbar.setupWithNavController(navController, appBarConfiguration)
14
25
}
15
26
16
27
override fun onSupportNavigateUp () =
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import android.view.LayoutInflater
5
5
import android.view.View
6
6
import android.view.ViewGroup
7
7
import android.widget.ImageView
8
+ import androidx.appcompat.app.AppCompatActivity
8
9
import androidx.core.content.ContextCompat
9
10
import androidx.fragment.app.Fragment
10
11
import androidx.lifecycle.LifecycleOwner
@@ -41,6 +42,7 @@ class DetailsFragment : Fragment() {
41
42
private fun getMovieByArguments () {
42
43
arguments?.let {
43
44
val safeArgs = DetailsFragmentArgs .fromBundle(it)
45
+ (activity as AppCompatActivity ).supportActionBar?.title = safeArgs.movie.title
44
46
mViewModel.getMovie(safeArgs.movie.id.toLong())
45
47
}
46
48
}
Original file line number Diff line number Diff line change 4
4
android : layout_width =" match_parent"
5
5
android : layout_height =" match_parent" >
6
6
7
+ <androidx .appcompat.widget.Toolbar
8
+ android : id =" @+id/my_toolbar"
9
+ android : layout_width =" match_parent"
10
+ android : layout_height =" ?attr/actionBarSize"
11
+ android : background =" ?attr/colorPrimary"
12
+ android : elevation =" 4dp"
13
+ android : theme =" @style/ThemeOverlay.AppCompat.Dark.ActionBar"
14
+ app : popupTheme =" @style/ThemeOverlay.AppCompat.Light"
15
+ app : layout_constraintTop_toTopOf =" parent"
16
+ app : layout_constraintEnd_toEndOf =" parent"
17
+ app : layout_constraintStart_toStartOf =" parent" />
18
+
7
19
<fragment
8
20
android : id =" @+id/nav_host_fragment"
9
21
android : name =" androidx.navigation.fragment.NavHostFragment"
13
25
app : layout_constraintBottom_toBottomOf =" parent"
14
26
app : layout_constraintEnd_toEndOf =" parent"
15
27
app : layout_constraintStart_toStartOf =" parent"
16
- app : layout_constraintTop_toTopOf = " parent "
28
+ app : layout_constraintTop_toBottomOf = " @+id/my_toolbar "
17
29
app : navGraph =" @navigation/nav_graph" />
18
30
19
31
</androidx .constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change 8
8
<fragment
9
9
android : id =" @+id/homeFragment"
10
10
android : name =" com.arctouch.codechallenge.ui.home.HomeFragment"
11
- android : label =" home_activity "
11
+ android : label =" @string/app_name "
12
12
tools : layout =" @layout/fragment_home" >
13
13
<action
14
14
android : id =" @+id/action_homeFragment_to_detailsFragment"
Original file line number Diff line number Diff line change 1
1
<resources >
2
2
3
- <style name =" AppTheme" parent =" Theme.AppCompat.Light.DarkActionBar " >
3
+ <style name =" AppTheme" parent =" Theme.AppCompat.Light.NoActionBar " >
4
4
<item name =" colorPrimary" >@color/colorPrimary</item >
5
5
<item name =" colorPrimaryDark" >@color/colorPrimaryDark</item >
6
6
<item name =" colorAccent" >@color/colorAccent</item >
You can’t perform that action at this time.
0 commit comments