Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert 1 master #197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Travis master: [![Build Status](https://travis-ci.org/Diolor/Swipecards.svg?bran
A Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content.
The library creates a similar effect to Tinder's swipable cards with Fling animation.

It was inspired by [Kikoso's Swipeable-Cards] but I decided to create a more simple and fresh approach with less bugs.

It handles greatly asynchronous loading of adapter's data and uses the same layout parameters as FrameLayout (you may use `android:layout_gravity` in your layout xml file).

![ ](/screenshot.gif)
Expand Down
17 changes: 9 additions & 8 deletions example/src/main/java/com/lorentzos/swipecards/MyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class MyActivity extends Activity {
private ArrayAdapter<String> arrayAdapter;
private int i;

@InjectView(R.id.frame) SwipeFlingAdapterView flingContainer;
@InjectView(R.id.frame)
SwipeFlingAdapterView flingContainer;


@Override
Expand All @@ -43,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
al.add("css");
al.add("javascript");

arrayAdapter = new ArrayAdapter<>(this, R.layout.item, R.id.helloText, al );
arrayAdapter = new ArrayAdapter<>(this, R.layout.item, R.id.helloText, al);


flingContainer.setAdapter(arrayAdapter);
Expand Down Expand Up @@ -73,16 +74,18 @@ public void onRightCardExit(Object dataObject) {
public void onAdapterAboutToEmpty(int itemsInAdapter) {
// Ask for more data here
al.add("XML ".concat(String.valueOf(i)));
arrayAdapter.notifyDataSetChanged();
// arrayAdapter.notifyDataSetChanged();
Log.d("LIST", "notified");
i++;
}

@Override
public void onScroll(float scrollProgressPercent) {
View view = flingContainer.getSelectedView();
view.findViewById(R.id.item_swipe_right_indicator).setAlpha(scrollProgressPercent < 0 ? -scrollProgressPercent : 0);
view.findViewById(R.id.item_swipe_left_indicator).setAlpha(scrollProgressPercent > 0 ? scrollProgressPercent : 0);
view.findViewById(R.id.item_swipe_right_indicator).setAlpha(scrollProgressPercent < 0 ?
-scrollProgressPercent : 0);
view.findViewById(R.id.item_swipe_left_indicator).setAlpha(scrollProgressPercent > 0 ?
scrollProgressPercent : 0);
}
});

Expand All @@ -97,7 +100,7 @@ public void onItemClicked(int itemPosition, Object dataObject) {

}

static void makeToast(Context ctx, String s){
static void makeToast(Context ctx, String s) {
Toast.makeText(ctx, s, Toast.LENGTH_SHORT).show();
}

Expand All @@ -116,6 +119,4 @@ public void left() {
}




}