Fixed
Status Update
Comments
d....@gmail.com <d....@gmail.com> #2
Another workaround, getting the ActionBar size at run-time:
TypedValue typed_value = new TypedValue();
getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typed_value, true);
swipe_refresh_layout.setProgressViewOffset(false, 0, getResources().getDimensionPixelSize(typed_value.resourceId));
TypedValue typed_value = new TypedValue();
getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typed_value, true);
swipe_refresh_layout.setProgressViewOffset(false, 0, getResources().getDimensionPixelSize(typed_value.resourceId));
an...@gmail.com <an...@gmail.com> #4
Another workaround might help
handler.postDelayed(new Runnable() {
@Override
public void run() {
initiateRefresh();
}
}, 1000);
handler.postDelayed(new Runnable() {
@Override
public void run() {
initiateRefresh();
}
}, 1000);
d....@gmail.com <d....@gmail.com> #6
Same issue here. I am calling an AsyncTask (that calls setRefreshing) from onResume.
d....@gmail.com <d....@gmail.com> #7
Same here. android.support.v4 v 21.0.0
am...@google.com <am...@google.com> #8
Problem still exists with android.support.v4:21.0.3.
d....@gmail.com <d....@gmail.com> #9
[Comment deleted]
do...@gmail.com <do...@gmail.com> #10
[Comment deleted]
gi...@gmail.com <gi...@gmail.com> #11
FWIW: a workaround that seems to work (even without the delay):
final boolean refreshing = true;
swipeToRefreshLayout.post(new Runnable() {
@Override public void run() {
swipeToRefreshLayout.setRefreshing(refreshing);
}
});
final boolean refreshing = true;
swipeToRefreshLayout.post(new Runnable() {
@Override public void run() {
swipeToRefreshLayout.setRefreshing(refreshing);
}
});
tw...@gmail.com <tw...@gmail.com> #12
[Comment deleted]
mr...@gmail.com <mr...@gmail.com> #13
[Comment deleted]
[Deleted User] <[Deleted User]> #14
The same problem.
[Deleted User] <[Deleted User]> #15
The post() workaround works when loading programmatically, but the gesture down is still broken.
[Deleted User] <[Deleted User]> #16
It seems the gesture doesn't work if the view doesn't have a ScrollView widget in its hierarchy.
[Deleted User] <[Deleted User]> #17
My solution is to override SwipeRefreshLayout
private boolean mMeasured = false;
private boolean mPreMeasureRefreshing = false;
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (!mMeasured) {
mMeasured = true;
setRefreshing(mPreMeasureRefreshing);
}
}
@Override
public void setRefreshing(boolean refreshing) {
if (mMeasured) {
super.setRefreshing(refreshing);
} else {
mPreMeasureRefreshing = refreshing;
}
}
private boolean mMeasured = false;
private boolean mPreMeasureRefreshing = false;
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (!mMeasured) {
mMeasured = true;
setRefreshing(mPreMeasureRefreshing);
}
}
@Override
public void setRefreshing(boolean refreshing) {
if (mMeasured) {
super.setRefreshing(refreshing);
} else {
mPreMeasureRefreshing = refreshing;
}
}
Description
Version used: 25.1.0
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: every devices I tested on, for example : Sony Xperia Z3 tablet, Samsung Galaxy Tab S2.
It seems related to other issues being reported about fragment replace transactions, but this one does not use the replace method.
Steps to reproduce :
- Add a fragment with a simple transaction :
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
.add(R.id.fragment_container, new TestFragment())
.commit()
- Remove the fragment using a simple remove, and just after start a new activity :
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (fragment != null) {
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
.remove(fragment)
.commit();
startActivity(new Intent(this, MainActivity.class));
}
- Go back to the old activity
What should happen : the fragment that was added should not be here anymore.
What happens : the fragment is still here. But the thing is it's only some sort of "ghost view" : it's impossible to reach it in debug using the view hierarchy. I even tried to activate the debug option "show layout bounds", which does not shows the bound on the fragment view. The view is not clickable, if I call removeAllViews() on the container it's still here.
Another thing : even with this view still here, if I re-add a fragment it will be added below the "ghost view". Everything works, but the old view is still here.
I attached a sample project to reproduce this issue. The "remove fragment" button is just here to validate the behaviour without starting another activity. You can see the bug using :
- "Add fragment"
- "Remove fragment and start activity"
- Press the back button
The old fragment is still here. If you press the add fragment button, another fragment will appear behing the old fragment, which should not be possible.
If you use the "show layout bounds" option, the bug is really visible :
- Start from scratch (kill the app)
- "Add fragment"
- Enable the "show layout bounds" option.
- "Remove fragment and start activity"
- Press the back button
Here everything seems normal except for the fragment still being here. But if you disable the "show layout bounds" option, the fragment view will stay unchanged, with layout bounds displayed. As if it were a cached view not recognized by the system.
I also attached a screenshot of this behavior. You can see the "show layout bounds" option is disabled, but it still shows on the fragment view.
All this does not happen with support lib 25.0.1.