activity.supportFragmentManager.popBackStackImmediate()
popBackStackImmediate can not remove Glide's SupportRequestManagerFragment, do you know why? and is there any other way I can remove the SupportRequestManagerFragment from fragments stack?
This case fragment use Activity context instead of fragment context for Glide.
Glide.with(getActivity()).load("url").into(imageView)
more details refer Here
If SupportRequestManagerFragment is getting added to backstack entry of your application fragments stack, then inside fragment call Glide method using base context so its not added and create problem for back press..
Glide.with(this.getActivity().getBaseContext()).load("url").into(imageView)
Because Glide's Fragment is not on the FragmentManager's operation backstack.
See code.
pendingSupportRequestManagerFragments.put(fm, current);
fm.beginTransaction().add(current, FRAGMENT_TAG).commitAllowingStateLoss(); // <-- no addToBackStack() call
You probably also shouldn't touch the internals of Glide without good reason, but technically you can call fragmentManager.getFragments()
, check for null (it can return null), iterate the list, check if(fragment instanceof SupportRequestManagerFragment)
, and if yes, then remove it with a fragment transaction. But it doesn't seem like a good idea. ^_^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With