Open ben-ying opened 8 years ago
Reappear this issue in your main page demo. But in listview or gridview demo it works.
I fixed the issue by cloning the project and added it as a library, but it doesn't by adding "com.daimajia.swipelayout:library:1.2.0@aar" in gradle file.
I solved it by commenting line safeBottomView() in method onLayout():
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int childCount = getChildCount();
if (childCount != 2) {
throw new IllegalStateException("You need 2 views in SwipeLayout");
}
if (!(getChildAt(0) instanceof ViewGroup) || !(getChildAt(1) instanceof ViewGroup)) {
throw new IllegalArgumentException("The 2 children in SwipeLayout must be an instance of ViewGroup");
}
if (mShowMode == ShowMode.PullOut)
layoutPullOut();
else if (mShowMode == ShowMode.LayDown)
layoutLayDown();
// safeBottomView();
if (mOnLayoutListeners != null)
for (int i = 0; i < mOnLayoutListeners.size(); i++) {
mOnLayoutListeners.get(i).onLayout(this);
}
}
This problem is reproduced in Lenovo A5500-H
Confirmed that above fix works.
safeBottomView(); if i comment this onclick item and longpress and double tap function dont work properly as swipe layout comes every time .
I also found this issue when I swipe to open item, it auto closed in Lollipop 5.0
红米note2,也是这个问题。
it shakes when i swipe left to open ,acting like a bug.I test on Meizu MX5(Chinese cellphone,which phone seems to modify much android ui,may be it is the reason it happened so)
private void updateBottomViews() {
View currentBottomView = getCurrentBottomView();
if(currentBottomView != null) {
if(mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
mDragDistance = currentBottomView.getMeasuredWidth() - dp2px(getCurrentOffset());
} else {
mDragDistance = currentBottomView.getMeasuredHeight() - dp2px(getCurrentOffset());
}
}
if(mShowMode == ShowMode.PullOut) {
layoutPullOut();
} else if(mShowMode == ShowMode.LayDown) {
layoutLayDown();
}
//safeBottomView();
}
Same error on Conkertab SX5. Some solutions? I need longpress too.
Hi, I have the same error in a Lenovo Tablet, Does this library have a new update to solve the problem?
thanks
@fh127 do what I did -_-
I have resolved this issue but whitout change the code as Zhuinden said. I followed the instructions "how to use" and "SwipeAdapter usage" and It worked good. I didn't use the component as It must be used. Now It works good.
The only question is sometimes (randomly) I can't swipe the layout to open the options. But It's absolutly random and I don't know why.
You have to add a SwipeListener and a GlobalLayoutListener to your SwipeLayout Add an GlobalLayoutListener to your swipeLayout and keep a variable with the value isOpening> Example
swipeLayout.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onStartOpen(SwipeLayout layout) {
isOpenSwipeLayout = true;
}
@Override
public void onStartClose(SwipeLayout layout) {
isOpenSwipeLayout = false;
}
});
swipeGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (isOpenSwipeLayout) {
// Opens the layout without animation
swipeLayout.open(false);
}
}
};
swipeLayout.getViewTreeObserver().addOnGlobalLayoutListener(swipeGlobalLayoutListener);
I also faced the issue, what to do unable to understand.
@EpariNigam do what I did
@Zhuinden I already commented that line still facing issue.
@Zhuinden You have to do two things. 1:
2:
If you still don't understand this method please reply with a github link to your code.
Greetings, Thijs van Schaik
Had same problem on acer b3-a30 10" tablet. @ThijsmvSchaik solution worked like a charm, the only draw back is that i have to giveup the animation.
I simply removed the safeBottomView() and it works like a charm.
how did you remove the safe bottom view? i think the library has the files locked
By cloning the library and adding it to my project and removing the line
i have tried this solution and many others but whenever i call textview.settext in onUpdate method the swipe closes itself automatically. I have even added the library as a module in my project and commented the method safeBottomViews() in updateBottomViews() in SwipeLayout.java but nothing seems to work. This library is very good no doubt but this issue is getting on my nerves now. Please if anyone got a solution then let me know. Thanks.
@aik117 I used this library because we needed it to work on API 10, but now that even the support library doesn't work below API 14, it's probably best if you just implement this behavior yourself with https://github.com/blipinsk/ViewPropertyObjectAnimator and translate
@Zhuinden thanks for replying i have been trying alot with this library. Now i will try this viewproperty library and see how to fix it in my code and will let you know.
reproduced bug on meizu m2 note, why fix @Zhuinden still didn't add to library? I don't want to fork(
This isn't my library 😄
when I swipe to open item, it auto closed in some phones? BTW, are there any methods to prevent close listview item when I call adapter.notifyDataChanged?