Skip to content

Commit 07aee7a

Browse files
committed
fix NPE in weather forecast fragment
1 parent 456521b commit 07aee7a

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

app/src/main/java/fi/kroon/vadret/presentation/main/MainActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class MainActivity : AppCompatActivity() {
6363
super.onCreate(savedInstanceState)
6464
Timber.d("ON CREATE")
6565

66-
binding = MainActivityBinding.inflate(layoutInflater)
67-
setContentView(binding.root)
6866
/**
6967
* on runtime theme needs to be applied before
7068
* setContentView has run. But we cant run
@@ -73,6 +71,8 @@ class MainActivity : AppCompatActivity() {
7371
*/
7472
preSetupEvents()
7573

74+
binding = MainActivityBinding.inflate(layoutInflater)
75+
setContentView(binding.root)
7676
setupSupportActionBar()
7777

7878
if (savedInstanceState == null) {
@@ -119,6 +119,7 @@ class MainActivity : AppCompatActivity() {
119119

120120
private fun setupSupportActionBar() {
121121
setSupportActionBar(binding.toolBar)
122+
//setActionBar()
122123
}
123124

124125
private fun setupPreferences() {

app/src/main/java/fi/kroon/vadret/presentation/weatherforecast/WeatherForecastFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class WeatherForecastFragment : Fragment() {
185185
*/
186186
recyclerViewParcelable?.run {
187187
putParcelable(SCROLL_POSITION_KEY, this)
188-
} ?: binding.weatherForecastRecyclerView.layoutManager?.run {
188+
} ?: _binding?.weatherForecastRecyclerView?.layoutManager?.run {
189189
putParcelable(
190190
SCROLL_POSITION_KEY,
191191
(this as LinearLayoutManager)

0 commit comments

Comments
 (0)