Comments (15)
To follow up, that work around I proposed above gave me jerky animations while the list item is removed. I went with a workaround of making every list element equal height.
from swipeactionadapter.
This issue is similar to #26
Recycling views is very important to retain good performance. It is no accident that google made this pattern mandatory in their new recyclerview.
The proper solution is probably to inspect the new item in getView and adjust the backgrounds if necessary, either by reinflating or redrawing them with new parameters.
I'll need to experiment with this to see how all of it works together.
from swipeactionadapter.
I've been trying to reproduce this behaviour for quite some time now in the demo app, but I can't.
When I explicitly set the height in getView everything works out just fine.
For safety I would give your backgrounds a height of match_parent
and do a requestLayout() on your output view if you changed its height.
from swipeactionadapter.
I have set height to match_parent
and adding requestLayout()
didn't fix it.
I have worked around by keeping my variable text field at 1 line and adding dialog but it would be great if I could get this working so I'm happy to help debug.
Gist with with relevant code: https://gist.github.com/MatthewDailey/8ac2b26fee9a23ac46f9
Video of the error: https://www.youtube.com/watch?v=FBj4lFtOtWA
from swipeactionadapter.
The behaviour in the video is indeed due to the recycling of the row Views.
I went through your gist but couldn't quite see how you got the first item to be higher than the others.
In any case, if you want different items to have different heights, I think you'll have to set the height in getView
using convertView.getLayoutParameters().height
.
The idea is that your ListView rows are all very similar, any difference between them (such as the content of the fields or, in this case, the height of the row) you should account for in getView
.
from swipeactionadapter.
Ok thanks! I'll give it a shot in a bit.
from swipeactionadapter.
Did you resolve your issue?
from swipeactionadapter.
Nope the work around I had is sufficient for now.
from swipeactionadapter.
Hello, i'm trying to use your library to delete some items from my listview.
It works perfect appart from the height resizing of the items.
I'm using the same layout in each getView(), but with height set as wrap_content. I need my rows to adapt to the textview content so i can't solve it with by fixing the height.
Could you help me on that ?
from swipeactionadapter.
I never got this to work reliably in the past.
Basically you'll have to remeasure and invalidate the row view each time you bind new data in it.
It should be doable but I haven't figured out the right incantation for it.
I don't think changed to the actual library will be required, but let me know if you need any help there.
from swipeactionadapter.
Well, i'm new to android so it took me 5mn to integrate the lib and making it work, and the whole day trying to find a way to remeasure the views after the animation is done.
No success so far. If you could give me a code snippet of what you have in mind you would save my day!
from swipeactionadapter.
Basically what i do is this :
@Override
public void onSwipe(int[] positionList, int[] directionList) {
for (int i = 0; i < positionList.length; i++) {
int direction = directionList[i];
int position = positionList[i];
if (direction == SwipeDirections.DIRECTION_FAR_LEFT
|| direction == SwipeDirections.DIRECTION_NORMAL_LEFT) {
Card card = wrappedAdapter.getItem(position);
wrappedAdapter.remove(card);
swipeAdapter.notifyDataSetChanged();
}
}
}
even if i try to add getListView().invalidateViews(); there, it doesn't make any difference. Could it be because this is called before the animation start and not when it's actually done?
I guess the problems come from this part of the lib :
ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
// Reset view presentation
pendingDismiss.view.setAlpha(1f);
pendingDismiss.view.setTranslationX(0);
lp = pendingDismiss.view.getLayoutParams();
lp.height = originalHeight;
pendingDismiss.view.setLayoutParams(lp);
}
Do you think there's any way to set the lp.height to the new layout's height taking it's place?
(Offtopic : By the way is it possible to disable the right swipe?)
from swipeactionadapter.
Oh.. Turns out it was pretty simple :
When the animation is done just set it back to WRAP_CONTENT instead of "originalHeight"
Only fix I could find, though i had to modify the lib.
pendingDismiss.view.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
from swipeactionadapter.
Nice work!
I'll try this out when I have some time and add the change to the library.
Disabling swipes by direction is an often requested feature. I have an idea on how to do it, but need to find the time really.
from swipeactionadapter.
I did a pull request with those two change (row heights bug + swipe direction enabling settings)
None of the swipe directions are enabled by default - enables on addBackground or addDirection (for use with no background).
from swipeactionadapter.
Related Issues (20)
- NoClassDefFoundError HOT 3
- Have three textviews, and a image view, hence a custom listview HOT 2
- Action Mode for listview not working properly when I use SwipeActionAdapter HOT 1
- java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.View$OnTouchListener.onTouch(android.view.View, android.view.MotionEvent)' on a null object reference HOT 5
- Custom view HOT 1
- Problem with static background HOT 10
- mAdapter.setFadeOut(true)
- Is there an undo action possible? If not already built in, what is the best way to get this implemented? HOT 1
- Not working with PullToRefresh HOT 2
- Problems with SwipeRefreshLayout HOT 1
- Issue with ExpandableListView HOT 1
- Using of SwipeActionAdapter with custom list of AutoCompleteTextView
- Render problem HOT 4
- Align of elements in background row HOT 2
- Mixed list HOT 3
- No way to stop animations HOT 1
- error when i try to filter my adapter HOT 2
- SwipeRefreshLayout touch events collide with SwipeActionAdapter
- Custom adapter HOT 1
- Cannot resolve method setListAdapter HOT 3
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 swipeactionadapter.