From 4597e888a5d68d43691923e6f21846d5358044ad Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 4 Feb 2018 21:01:43 +0100 Subject: [PATCH] try fixing TransactionTooLargeException on Android Nougat --- .../gallery/adapters/MyPagerAdapter.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt index 0317a1b36..c6f7776ab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.adapters import android.os.Bundle +import android.os.Parcelable import android.support.v4.app.Fragment import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentStatePagerAdapter @@ -47,11 +48,18 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m super.destroyItem(container, position, any) } - fun getCurrentFragment(position: Int) = fragments.get(position) + fun getCurrentFragment(position: Int) = fragments[position] fun toggleFullscreen(isFullscreen: Boolean) { for ((pos, fragment) in fragments) { fragment.fullscreenToggled(isFullscreen) } } + + // try fixing TransactionTooLargeException crash on Android Nougat, tip from https://stackoverflow.com/a/43193425/1967672 + override fun saveState(): Parcelable? { + val bundle = super.saveState() as Bundle? + bundle!!.putParcelableArray("states", null) + return bundle + } }