Comments (12)
It's the last missing piece for the 0.8.0 release and will be targeted next. I can't give any time frame.
from thirtyinch.
I don't really understand why TiFragment#onDestroy()
has all that logic to decide whether or not to destroy the Presenter.
If config.shouldRetainPresenter()
is true, which is the default, then the fragment has setRetainInstance(true)
set in its onCreate()
anyway, so the Fragment won't get destroyed on a normal configuration change. If Fragment.onDestroy()
is being called by the framework, it's because the Fragment really is being properly destroyed and will not be recreated, so we should destroy the presenter too.
from thirtyinch.
Good catch, will investigate it
from thirtyinch.
I can verify this problem exists. But the fix isn't as easy always calling Presenter.destroy()
in TiFragment#onDestroy()
. The following states must be tested:
- with/without savior
- with/without retain
- don't keep activities enabled/disabled
- fragment in backstack
- fragment attached/detached
for the following usecases:
- call
finish()
- bring Activity in background and back to foreground
- orientation change
Overall 72 cases, which should be tested. It was easier for the Activity where only 8 states are possible for 3 usecases (24 test). One reason I don't use Fragments anymore 😈
This also requires a delegate for TiFragment
, otherwise it's not testable.
//cc #20
from thirtyinch.
Interestingly, there is a bugfix in SupportLibrary 25.1.0
Fragment.onDestroy()
not called for fragment in backstack
Maybe this caused some of the troubles
from thirtyinch.
@passsy onDestroy()
is reliably called each time a fragment gets popped off the back stack. Even in support library version 24.2.1
which is currently used by ThirtyInch.
Sadly the bugfix description does not provide any helpful informations (for example under what conditions onDestroy()
was not called) :(. Nevertheless the memory leak which is described in this issue can be verified and needs to be fixed.
from thirtyinch.
^ s/@passy/@passsy/ :)
from thirtyinch.
Because I run into the same issue I want to share some stuff.
We have a simple MasterDetail-Activity.
On phones we display the MasterFragment. On click we replace
it with the DetailFragment.
On back press we pop it (because of backstack stuff).
In tablets landscape we display the MasterFragment on the left side and when we click on an item we put the DetailFragment on the right side.
On tablets portrait we have the same behaviour like phones.
Which means we have to detect the orientation change on rotation and:
Land -> Port: Remove
the DetailFragment form the DetailContainer and replace
it to the MasterContainer
Port -> Land: Remove
the DetailFragment from the MasterContainer and replace
it to the DetailContainer.
On our DetailPresenter I've put the following logic to fix the destroying:
@Override
public void onDestroy() {
// Destroy presenter on phones (because they got detached). Otherwise they don't will destroy on backstackpress.
// On tablets we put on orientation change the fragment from one container to another.
// So we don't have to destroy the presenter but when the activity got finished
// see https://git.io/vMzfA
if (Utils.isPhone(getContext())) {
MLog.d(TAG, "Destroy on Phones");
getPresenter().destroy();
}
if (!mChangingConfigurations && Utils.isTablet(getContext())) {
getPresenter().destroy();
MLog.d(TAG, "Destroy on Tablets only when no configuration changed!");
}
super.onDestroy();
}
@Override
public void onStop() {
super.onStop();
mChangingConfigurations = ((TiActivity) getActivity()).isActivityChangingConfigurations();
}
Everything is tested with AppCompat 25.1.0
from thirtyinch.
Do we have an estimate for when a fix might be available? If it's not within the next 2-3 weeks, I'll have to find an alternative solution. :(
from thirtyinch.
Just to bump this issue:
@gborland As you may have noticed we are working hard on fixing (#78) this issue. Please feel free to try it out and provide your feedback.
from thirtyinch.
#78 is finally merged into master.
Thank you @gborland for the report and the testing 👍
We will publish a new release soon.
from thirtyinch.
v0.8.0-rc4 published
from thirtyinch.
Related Issues (20)
- Debugging a @CallOnMainThread annotated method crashes the app HOT 2
- Create Kotlin module/extensions HOT 2
- Switch from compileOnly to implementation HOT 1
- [Discussion] Should manageViewDisposable() throw an exception
- Support for AndroidX HOT 4
- BackstackReader doesn't work with AndroidX HOT 3
- "Don't add observers when the presenter reached the DESTROYED state" EXCEPTION HOT 1
- sendToView HOT 4
- Lint warning with sendToView, but not with deliverToView
- Why saving the Presenter on orientation change HOT 1
- Problems with @CallOnMainThread
- Lint does not report by abstract classes without implementation View
- Crash using AndroidX with ProGuard enabled HOT 2
- Lint reports: Obsolete custom lint check
- bundle[buildType] was replaced with AGP 3.2.0
- Package thirtyinch-kotlin-coroutines not published HOT 3
- Plugin module not available with version 0.9.5 HOT 2
- Release for androidx HOT 2
- Restore old BackstackReader.isInBackstack() implementation once AndroidX Fragment 1.2.1 is released HOT 1
- Migrate away from JCenter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thirtyinch.