commit
5bf1189d1c
|
|
@ -1,174 +0,0 @@
|
|||
package com.daimajia.swipedemo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
|
||||
public class MyActivity extends Activity {
|
||||
|
||||
private SwipeLayout sample1, sample2, sample3;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
// SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.godfather);
|
||||
// swipeLayout.setDragEdge(SwipeLayout.DragEdge.Bottom); // Set in XML
|
||||
|
||||
//sample1
|
||||
|
||||
sample1 = (SwipeLayout) findViewById(R.id.sample1);
|
||||
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right);
|
||||
// When using multiple drag edges it's a good idea to pass the ids of the views that you're using for the left, right, top bottom views (-1 if you're not using a particular view)
|
||||
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, -1, -1);
|
||||
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
|
||||
@Override
|
||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample1.findViewById(R.id.trash2).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample1.findViewById(R.id.magnifier2).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
//sample2
|
||||
|
||||
sample2 = (SwipeLayout) findViewById(R.id.sample2);
|
||||
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
sample2.setDragEdge(SwipeLayout.DragEdge.Right);
|
||||
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample2.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample2.findViewById(R.id.magnifier).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample2.findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
//sample3
|
||||
|
||||
sample3 = (SwipeLayout) findViewById(R.id.sample3);
|
||||
sample3.setDragEdge(SwipeLayout.DragEdge.Top);
|
||||
sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {
|
||||
@Override
|
||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||
View star = child.findViewById(R.id.star);
|
||||
float d = child.getHeight() / 2 - star.getHeight() / 2;
|
||||
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"));
|
||||
child.setBackgroundColor(c);
|
||||
}
|
||||
});
|
||||
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.my, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_listview) {
|
||||
startActivity(new Intent(this, ListViewExample.class));
|
||||
return true;
|
||||
} else if (id == R.id.action_gridview) {
|
||||
startActivity(new Intent(this, GridViewExample.class));
|
||||
return true;
|
||||
<<<<<<< HEAD
|
||||
} else if (id == R.id.action_nexted) {
|
||||
=======
|
||||
} else if (id == R.id.action_nested) {
|
||||
>>>>>>> upstream/master
|
||||
startActivity(new Intent(this, NestedExample.class));
|
||||
return true;
|
||||
} else if (id == R.id.action_recycler) {
|
||||
startActivity(new Intent(this, RecyclerViewExample.class));
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/*
|
||||
Color transition method.
|
||||
*/
|
||||
public Object evaluate(float fraction, Object startValue, Object endValue) {
|
||||
int startInt = (Integer) startValue;
|
||||
int startA = (startInt >> 24) & 0xff;
|
||||
int startR = (startInt >> 16) & 0xff;
|
||||
int startG = (startInt >> 8) & 0xff;
|
||||
int startB = startInt & 0xff;
|
||||
|
||||
int endInt = (Integer) endValue;
|
||||
int endA = (endInt >> 24) & 0xff;
|
||||
int endR = (endInt >> 16) & 0xff;
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
xmlns:swipe="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/swipe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
swipe:horizontalSwipeOffset="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<<<<<<< HEAD
|
||||
android:layout_height="wrap_content"
|
||||
swipe:leftEdgeSwipeOffset="25dp"
|
||||
swipe:rightEdgeSwipeOffset="25dp"
|
||||
>
|
||||
=======
|
||||
android:layout_height="80dp"
|
||||
android:background="#FF5534"
|
||||
android:gravity="center"
|
||||
android:tag="Bottom3"
|
||||
android:weightSum="10">
|
||||
>>>>>>> upstream/master
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/trash"
|
||||
android:layout_width="27dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/trash" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5"
|
||||
android:text="Delete Item?"
|
||||
android:textColor="#fff"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="4"
|
||||
android:background="#ffffff"
|
||||
android:text="Yes,Delete"
|
||||
android:textColor="#FF5534" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/item_selector"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_data"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:tag="Hover"
|
||||
android:text="Do not, for one repulse, forgo the purpose that you resolved to effort. " />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue