Skip to content
Merged
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
42 changes: 14 additions & 28 deletions demo/src/main/java/com/daimajia/swipedemo/MyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import android.view.View;
import android.widget.Toast;

import com.daimajia.swipe.SimpleSwipeListener;
import com.daimajia.swipe.SwipeLayout;
import com.nineoldandroids.view.ViewHelper;

public class MyActivity extends Activity {

private SwipeLayout sample1, sample2,sample3;
private SwipeLayout sample1, sample2, sample3;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -26,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {

//sample1

sample1 = (SwipeLayout)findViewById(R.id.sample1);
sample1 = (SwipeLayout) findViewById(R.id.sample1);
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
sample1.setDragEdge(SwipeLayout.DragEdge.Left);
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
Expand All @@ -38,7 +39,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int

//sample2

sample2 = (SwipeLayout)findViewById(R.id.sample2);
sample2 = (SwipeLayout) findViewById(R.id.sample2);
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
Expand All @@ -65,34 +66,19 @@ public void onClick(View v) {
sample2.findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo",Toast.LENGTH_SHORT).show();
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
}
});
sample1.addSwipeListener(new SwipeLayout.SwipeListener() {
@Override
public void onClose(SwipeLayout layout) {

}

@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {

}

sample1.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onOpen(SwipeLayout layout) {

}

@Override
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {

Toast.makeText(MyActivity.this, "Opened", Toast.LENGTH_SHORT).show();
}
});

//sample3

sample3 = (SwipeLayout)findViewById(R.id.sample3);
sample3 = (SwipeLayout) findViewById(R.id.sample3);
sample3.setDragEdge(SwipeLayout.DragEdge.Top);
sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {
@Override
Expand All @@ -102,7 +88,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
ViewHelper.setTranslationY(star, d * fraction);
ViewHelper.setScaleX(star, fraction + 0.6f);
ViewHelper.setScaleY(star, fraction + 0.6f);
int c = (Integer)evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B"));
int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B"));
child.setBackgroundColor(c);
}
});
Expand Down Expand Up @@ -131,7 +117,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.action_listview) {
startActivity(new Intent(this, ListViewExample.class));
return true;
}else if(id == R.id.action_gridview){
} else if (id == R.id.action_gridview) {
startActivity(new Intent(this, GridViewExample.class));
return true;
}
Expand All @@ -154,9 +140,9 @@ public Object evaluate(float fraction, Object startValue, Object endValue) {
int endG = (endInt >> 8) & 0xff;
int endB = endInt & 0xff;

return (int)((startA + (int)(fraction * (endA - startA))) << 24) |
(int)((startR + (int)(fraction * (endR - startR))) << 16) |
(int)((startG + (int)(fraction * (endG - startG))) << 8) |
(int)((startB + (int)(fraction * (endB - startB))));
return (int) ((startA + (int) (fraction * (endA - startA))) << 24) |
(int) ((startR + (int) (fraction * (endR - startR))) << 16) |
(int) ((startG + (int) (fraction * (endG - startG))) << 8) |
(int) ((startB + (int) (fraction * (endB - startB))));
}
}
24 changes: 24 additions & 0 deletions library/src/main/java/com/daimajia/swipe/SimpleSwipeListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.daimajia.swipe;

/**
* Created by sbaiget on 29/08/2014.
*/
public class SimpleSwipeListener implements SwipeLayout.SwipeListener {


@Override
public void onClose(SwipeLayout layout) {
}

@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
}

@Override
public void onOpen(SwipeLayout layout) {
}

@Override
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
}
}