Skip to content

Commit

Permalink
some small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shrewduser committed Mar 2, 2016
1 parent 73367de commit 367ef2c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -26,21 +26,24 @@ public class SwipeDeckActivity extends AppCompatActivity {
private SwipeDeck cardStack;
private Context context = this;

private SwipeDeckAdapter adapter;
private ArrayList<String> testData;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_swipe_deck);
cardStack = (SwipeDeck) findViewById(R.id.swipe_deck);
cardStack.setHardwareAccelerationEnabled(true);

final ArrayList<String> testData = new ArrayList<>();
testData = new ArrayList<>();
testData.add("0");
testData.add("1");
testData.add("2");
testData.add("3");
testData.add("4");

final SwipeDeckAdapter adapter = new SwipeDeckAdapter(testData, this);
adapter = new SwipeDeckAdapter(testData, this);
cardStack.setAdapter(adapter);

cardStack.setEventCallback(new SwipeDeck.SwipeEventCallback() {
Expand Down Expand Up @@ -70,7 +73,6 @@ public void cardActionUp() {
}

});

cardStack.setLeftImage(R.id.left_image);
cardStack.setRightImage(R.id.right_image);

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
maven {url "https://clojars.org/repo/"}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
Expand Down
10 changes: 7 additions & 3 deletions cardstack/build.gradle
Expand Up @@ -13,7 +13,7 @@ ext {
siteUrl = 'https://github.com/aaronbond/Swipe-Deck'
gitUrl = 'https://github.com/aaronbond/Swipe-Deck.git'

libraryVersion = '0.2.9'
libraryVersion = '0.2.12'

developerId = 'aaronbond'
developerName = 'Aaron Bond'
Expand All @@ -28,11 +28,15 @@ android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

repositories {
maven {url "https://clojars.org/repo/"}
}

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 19
versionName "0.2.9"
versionCode 22
versionName "0.2.12"
}
buildTypes {
release {
Expand Down
19 changes: 13 additions & 6 deletions cardstack/src/main/java/com/daprlabs/cardstack/SwipeDeck.java
Expand Up @@ -9,6 +9,7 @@
import android.os.Parcelable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class SwipeDeck extends FrameLayout {
private SwipeListener swipeListener;
private int leftImageResource;
private int rightImageResource;
private boolean cardInteraction;

public SwipeDeck(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down Expand Up @@ -101,7 +103,7 @@ public Parcelable onSaveInstanceState()
{
//when persisting this piece of state need to roll it back by the child count
//so those children get restored later instead of skipped over
nextAdapterCard = nextAdapterCard - getChildCount();
//nextAdapterCard = nextAdapterCard - getChildCount();
return Icepick.saveInstanceState(this, super.onSaveInstanceState());
}

Expand Down Expand Up @@ -201,18 +203,15 @@ private void removeTopCard() {
if (child != null) {
child.setOnTouchListener(null);
swipeListener = null;
//this will also check to see if cards are depleted
removeViewWaitForAnimation(child);
}

//if there are no more children left after top card removal let the callback know
if (getChildCount() <= 0 && eventCallback != null) {
eventCallback.cardsDepleted();
}
}

private void removeViewWaitForAnimation(View child) {
new RemoveViewOnAnimCompleted().execute(child);


}

@Override
Expand Down Expand Up @@ -395,11 +394,14 @@ public void cardOffScreen() {
@Override
public void cardActionDown() {
if(eventCallback!=null) eventCallback.cardActionDown();
cardInteraction = true;
}

@Override
public void cardActionUp() {

if(eventCallback!=null) eventCallback.cardActionUp();
cardInteraction = false;
}

}, initialX, initialY, ROTATION_DEGREES, OPACITY_END);
Expand Down Expand Up @@ -492,6 +494,11 @@ protected View doInBackground(View... params) {
protected void onPostExecute(View view) {
super.onPostExecute(view);
removeView(view);

//if there are no more children left after top card removal let the callback know
if (getChildCount() <= 0 && eventCallback != null) {
eventCallback.cardsDepleted();
}
}
}
}
Expand Down
Expand Up @@ -69,6 +69,8 @@ public boolean onTouch(View v, MotionEvent event) {
//gesture has begun
float x;
float y;
//cancel any current animations
v.clearAnimation();

mActivePointerId = event.getPointerId(0);

Expand Down

0 comments on commit 367ef2c

Please sign in to comment.