flschweiger / swipestack Goto Github PK
View Code? Open in Web Editor NEWA simple, customizable and easy to use swipeable view stack for Android.
License: Apache License 2.0
A simple, customizable and easy to use swipeable view stack for Android.
License: Apache License 2.0
Hello,
Is there any way to set overlay image on swipe action like on left swipe to set "DISLIKE" overlay image and also on right for "LIKE" ?
Thanks.
I don't know what is happening but mSwipeStack.setAdapter(mAdapter) is not calling any of my methods in the adapter class even though the mData.size() > 0 in my case and when I replace mSwipeStack with a listview, everything works fine. Anyone experiencing this issue?
All cards get added to the bottom of the stack, which is great. However, I'd like to add both from the top and the bottom of the stack. Is there a way to add to top of stack? I've been trying to modify the source code but can't understand how I could change that.
It'd be great if anyone could give me an idea of how I could modify the source code to add to top of stack.
Thanks!
Are there any guidelines when using within a viewpager ?
can we do the opposite swipe to get the card back?
i want set "SAVE" and "NEXT" field on textview when swipe the cardstack. but text set on 3rd position of cardstack, what is an issue?
cardStack.setSwipeProgressListener(new SwipeStack.SwipeProgressListener() {
@OverRide
public void onSwipeStart(int position) {
}
@Override
public void onSwipeProgress(int position, float progress) {
if (progress < 0) {
mHolder.textViewSave.setText(getItem(position).getSave());
} else {
mHolder.textViewSave.setText(getItem(position).getNull());
}
if (progress > 0) {
mHolder.textViewNext.setText(getItem(position).getNext());
} else {
mHolder.textViewNext.setText(getItem(position).getNull());
}
}
@Override
public void onSwipeEnd(int position) {
}
});
I put a surfaceview to play video in each item,but I simply can't change the size of it in mediaplayer's OnVideoSizeChangedListener
How can I set the views of cards like 3rd image?
hello
thanks for your best library ;
i want remove card from view, how i can do this?
`mData.remove(position);
mAdapter.notifyDataSetChanged();`
this not work
Let me know what do you think about it :)
mAdapter.setData(cardsList);
public void setData(List<Card> cards) { this.mData = cards; notifyDataSetChanged(); }
At first my cards list size was 3 then i removed 1 card from list and set it again to adapter and call notifyDataSetChanged(); but it is not refreshing list.
It should show two cards stack. but still it is showing 3 cards in stack.
How can I dynamically add mapview/supportedmapfragment to the CardView under getView in the Adapter? I attempted to add the following code:
@OverRide
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
}
TextView textViewCard = (TextView) convertView.findViewById(R.id.textViewCard);
textViewCard.setText(mData.get(position));
// NEW CODE ADDED
FragmentManager fm = getChildFragmentManager();
SupportMapFragment supportMapFragment = SupportMapFragment.newInstance();
fm.beginTransaction().replace(R.id.mapContainer, supportMapFragment).commit();
return convertView;
}
And in the card.xml file a FrameLayout was added like this:
android:id="@+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Even with the above changes, I am only able to get the Test message to print on the Swipe cards. I am looking to get a map on each of the cards that get created. Any help would be appreciated.
Thanks!
How can you return the last swiped card back on top of the stack? And how do you activate endless looping the views. Will those features be available in a future release?
I can't seem to vertically center the SwipeStack inside any ViewGroup. I've tried inside a FrameLayout, RelativeLayout and LinearLayout.
Is it possible? If not, any hints on how I can modify the SwipeStack implementation to achieve this?
is it possible to swipe to a specific position? for instance to go back one card
mSwipeStack.setSwipeProgressListener(new SwipeStack.SwipeProgressListener() {
@OverRide
public void onSwipeStart(int position) {
}
@Override
public void onSwipeProgress(int position, float progress) {
System.out.println("progress...."+progress);
View mView = mSwipeStack.getTopView();
if (progress < 0) {
mView.setBackgroundColor(getResources().getColor(R.color.continue_button_color));
} else {
mView.setBackgroundColor(getResources().getColor(R.color.bel_red_text));
}
}
@Override
public void onSwipeEnd(int position) {
}
});
I tried this but not working
I want the list of items to be changed dynamically. So when the list of items are changed, the swipe stack doesn't take effect instantly. When the number of items in the list is changed, notifyDataSetChanged is called on the adapter associated with it. But it doesn't take effect in the swipe stack. It doesn't update the stack as per the change in adapter.
holder.op1 = (Button) convertView.findViewById(R.id.option1_card);
holder.op2 = (Button) convertView.findViewById(R.id.option2_card);
holder.op3 = (Button) convertView.findViewById(R.id.option3_card);
holder.op4 = (Button) convertView.findViewById(R.id.option4_card);
holder.op1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("op1","clicked");
holder.op1.setBackgroundColor(Color.WHITE);
holder.op1.setTextColor(Color.BLACK);
}
});
On clicking button of 1st card, properties of 3rd card gets changed.
Is it possible to disable all events until a certain another event?
Hello,
I am not getting a card sequence according to list data array. I am fetching a issue. Is there any solution for that?
Thanks!
This is my code, I want to update view with notifydatasetchanged, but it is not working
arrDriverOrders.get(position).getOrderMaster().setDriverAccepted(Constant.ORDER_ACCEPT_CODE); mAdapter.notifyDataSetChanged();
It is not possible to use a ViewPager inside a card due to the swipe gestures. But also the click on a TabLayout item does not change the ViewPager's page. Any reasons or fixes on this?
uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [link.fls:swipestack:0.3.0] E:\kaishuapp_android\kaishustory\app\build\intermediates\exploded-aar\link.fls\swipestack\0.3.0\AndroidManifest.xml
can't swipe when I set onClick listener to a child view in adapter
notifyDataSetChange doesn't refresh UI
How to make the width of the swipe stack descending same the demo.
Thank you!
I want to use swipestack like the one used in latest Linkedin application. I want to disable swipe on up and down. Need to add an attribute so that I up and down swipe won't effect the swipe stack.
hi. great library.
i have a problem for getCount of item after swipe and remove item of view!!
after remove view count of getCount do not decrease?
and when i remove from my list two item of adapter remove. for example if i have 6 item after remove 3 item of my list in swipeRight or left onEmpty method call!!!
how can i fix this bug?
my card.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/elevation_large">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ivCard"
android:src="@drawable/placeholder" />
<TextView
android:id="@+id/textViewCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="44sp"
android:text="@string/dummy_text"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
my adapter
...
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.ivCard = (ImageView) convertView.findViewById(R.id.ivCard);
Picasso.with(mContext).load(mData.get(position).getUrl()).resize(480, 480).centerCrop().into(holder.ivCard);
Log.e("555",mData.get(position).getUrl());
holder.tvCard = (TextView) convertView.findViewById(R.id.textViewCard);
holder.tvCard.setText(mData.get(position).getWho());
return convertView;
}
public class ViewHolder {
ImageView ivCard;
TextView tvCard;
}
...
it only display the text (from the internet but no luck with ImageView to display image (from URL) via Picasso)
Hi,
thanks for the awesome lib. I've tried to reproduce your code, and just noticed that getLayoutInflater()
is not a method from BaseAdapter
nor CardStackAdapter
.
Instead, I had to obtain the LayoutInflater
from the Context
, so another parameter of type Context
is needed in the constructor.
If you want, I can provide you a pull request updating the documentation, and also the code if you're interested.
Keep up the good work!
Hi,
We have a use case where when we swipe left, we need to show the previous card. Is there a way to do this in the library.
Can you please help.
Thank you
I can't change the card after it is created. Can't add items programmatically. Nothing happens. Can you give me advice?
Here is a small example:
public class SwipeStackAdapter extends BaseAdapte
......
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
}
final LinearLayout linearLayout = (LinearLayout) convertView.findViewById(R.id.linearLayout);
linearLayout.post(new Runnable() {
@Override
public void run() {
TextView textView = new TextView(getApplication());
textView.setText("I am a Text");
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
linearLayout.addView(textView);
}
});
return convertView;
}
for some reason the gradle dependency works fine but when running the sample code the app crashes over a class not found exception
I want to load more cards as the stack gets emptied.
I want to populate the list with new items and reset the stack.
Calling resetStack causes an animation of returning card which in the end the stack is empty
i dont want my card to move top and bottom but only limited to left and right.
Hi, thank you for a superb library. I got a crash report today from Android 4.4.2. Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
at android.view.MotionEvent.getX(MotionEvent.java:1979)
at link.fls.SwipeHelper.onTouch(SwipeHelper.java:55)
at android.view.View.dispatchTouchEvent(View.java:7772)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2316)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2013)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1985)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1541)
at android.app.Activity.dispatchTouchEvent(Activity.java:2491)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
at android.view.View.dispatchPointerEvent(View.java:7973)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4392)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4263)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3859)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3828)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3935)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3836)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3992)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3859)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3828)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3836)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6124)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6104)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6058)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6254)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
I tried to set a width using android:width="480dp"
in my card.xml file. But because I use an imageview on the card, and use img.setResource(R.drawable.img);
to set image on the card stack then resizes the card according to the width of the image, any fix?
This isn't so much of an issue, but a enhancement suggestion.
Do you know if SwipeStack has ever been used in a Nativescript application? I think it would benefit a lot of users if a 'port' was created that was compatible with Nativescript.
Every time a card has to be displayed convertView is null and has to be inflated. getViewTypeCount and getItemViewType are never called
I am having around 50 items in my stack. Sometimes when I click on swipe right button, 1 extra item gets swiped automatically. Any idea on this?
When I am using SwipeStack in a recyclerview it is taking only the swipe action and not able to scroll the list when touching the swipestack.
if item view setOnClick,it doesn't work
Thanks for an awesome library.
Can we implement functionality for top and bottom swipe dismiss?
How can we achieve that?
If i set onClickListener to the swipeStack then i cannot be able to swipe left or right?
Hi, sometimes when randomly swiping I get this
java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(Native Method)
at android.view.MotionEvent.getX(MotionEvent.java:2072)
at link.fls.swipestack.SwipeHelper.onTouch(SwipeHelper.java:58)
at android.view.View.dispatchTouchEvent(View.java:9335)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2581)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2559)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2453)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1755)
at android.app.Activity.dispatchTouchEvent(Activity.java:2776)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2402)
at android.view.View.dispatchPointerEvent(View.java:9590)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4436)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4292)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3816)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3875)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3841)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3971)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3849)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4028)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3821)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3875)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3841)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3849)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3821)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6150)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6118)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6072)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6253)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:216)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.refl
Might be related to Baseflow/PhotoView#31, was thinking can fix this by adding a try catch to SwipeHelper.OnTouch()
Any ideas would be great!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.