Skip to content

Commit

Permalink
FIX: currentFragment can be null - casting to not nullable type cause…
Browse files Browse the repository at this point in the history
…d crashes
  • Loading branch information
Tomas Havlicek committed Dec 3, 2018
1 parent d7299c2 commit a672579
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class BaseMainActivity : AppCompatActivity() {

override fun onBackPressed() {
val currentFragment = BaseApp.instance.fragmentManager.currentIFragment
if (currentFragment.onBackPressed()) {
if (currentFragment?.onBackPressed() == true) {
Log.d("BaseMainActivity", "BackPressed Handled by Fragment: " + currentFragment.javaClass.canonicalName)
} else if (onHandleBackPressed()) {
Log.d("BaseMainActivity", "BackPressed Handled by Child Activity")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ class BaseFragmentManager {
/**
* @return Fragment to IFragment casted instance
*/
val currentIFragment: IFragment<*>
get() = currentFragment as IFragment<*>
val currentIFragment: IFragment<*>?
get() = currentFragment as IFragment<*>?

/**
* Get current fragment
Expand Down

0 comments on commit a672579

Please sign in to comment.