Skip to content
This repository has been archived by the owner on Apr 19, 2018. It is now read-only.

Updated gitignore for gradle builds and add gradle configuration #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ out
.classpath
.project
.settings
build/
21 changes: 2 additions & 19 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.swipedismiss"
android:versionCode="1"
android:versionName="1.0"
>

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />

<application android:label="Swipe To Dismiss Demo">

<activity
android:label="Swipe2Dimiss"
android:name=".MainActivity"
android:icon="@drawable/icon">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

</application>

</manifest>
<application/>
</manifest>
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'android-library'

dependencies {
repositories {
mavenCentral()
}
compile 'com.nineoldandroids:library:2.4.0'
}

android {
compileSdkVersion project.hasProperty("android_build_compileSdkVersion")?Integer.parseInt(project.android_build_compileSdkVersion):19
buildToolsVersion project.hasProperty("android_build_buildToolsVersion")?project.android_build_buildToolsVersion:'19.0.1'

defaultConfig {
minSdkVersion project.hasProperty("android_build_minSdkVersion")?Integer.parseInt(project.android_build_minSdkVersion):8
targetSdkVersion project.hasProperty("android_build_targetSdkVersion")?Integer.parseInt(project.android_build_targetSdkVersion):19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}

instrumentTest.setRoot('tests')
}

lintOptions {
abortOnError false
}
}
Binary file removed libs/nineoldandroids-2.4.0.jar
Binary file not shown.
108 changes: 0 additions & 108 deletions src/com/example/android/swipedismiss/MainActivity.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.example.android.swipedismiss;

import android.app.ActionBar;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.VelocityTracker;
Expand All @@ -26,6 +27,7 @@
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;

import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorListenerAdapter;
import com.nineoldandroids.animation.ValueAnimator;
Expand All @@ -43,16 +45,16 @@
* dismissable. {@link ListView} is given special treatment because by default it handles touches
* for its list items... i.e. it's in charge of drawing the pressed state (the list selector),
* handling list item clicks, etc.
*
* <p/>
* <p>After creating the listener, the caller should also call
* {@link ListView#setOnScrollListener(android.widget.AbsListView.OnScrollListener)}, passing
* in the scroll listener returned by {@link #makeScrollListener()}. If a scroll listener is
* already assigned, the caller should still pass scroll changes through to this listener. This will
* ensure that this {@link SwipeDismissListViewTouchListener} is paused during list view
* scrolling.</p>
*
* <p/>
* <p>Example usage:</p>
*
* <p/>
* <pre>
* SwipeDismissListViewTouchListener touchListener =
* new SwipeDismissListViewTouchListener(
Expand All @@ -68,10 +70,10 @@
* listView.setOnTouchListener(touchListener);
* listView.setOnScrollListener(touchListener.makeScrollListener());
* </pre>
*
* <p/>
* <p>This class Requires API level 12 or later due to use of {@link
* android.view.ViewPropertyAnimator}.</p>
*
* <p/>
* <p>For a generalized {@link android.view.View.OnTouchListener} that makes any view dismissable,
* see {@link SwipeDismissTouchListener}.</p>
*
Expand Down Expand Up @@ -112,7 +114,7 @@ public interface OnDismissCallback {
* @param reverseSortedPositions An array of positions to dismiss, sorted in descending
* order for convenience.
*/
void onDismiss(ListView listView, int[] reverseSortedPositions);
void onDismiss(ListView listView, int position, View dismissedView);
}

/**
Expand All @@ -122,10 +124,10 @@ public interface OnDismissCallback {
* @param callback The callback to trigger when the user has indicated that she would like to
* dismiss one or more list items.
*/
public SwipeDismissListViewTouchListener(ListView listView, OnDismissCallback callback) {
public SwipeDismissListViewTouchListener(ListView listView, OnDismissCallback callback, int minFlingVelocity) {
ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
mSlop = vc.getScaledTouchSlop();
mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
mMinFlingVelocity = minFlingVelocity;
mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
mAnimationTime = listView.getContext().getResources().getInteger(
android.R.integer.config_shortAnimTime);
Expand Down Expand Up @@ -214,12 +216,12 @@ public boolean onTouch(View view, MotionEvent motionEvent) {

float deltaX = motionEvent.getRawX() - mDownX;
mVelocityTracker.addMovement(motionEvent);
mVelocityTracker.computeCurrentVelocity(1000);
mVelocityTracker.computeCurrentVelocity((int) Float.MAX_VALUE);
float velocityX = Math.abs(mVelocityTracker.getXVelocity());
float velocityY = Math.abs(mVelocityTracker.getYVelocity());
boolean dismiss = false;
boolean dismissRight = false;
if (Math.abs(deltaX) > mViewWidth / 2) {
if (Math.abs(deltaX) > mViewWidth * 3 / 4) {
dismiss = true;
dismissRight = deltaX > 0;
} else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity
Expand Down Expand Up @@ -313,7 +315,7 @@ private void performDismiss(final View dismissView, final int dismissPosition) {
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();

ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
/* ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

animator.addListener(new AnimatorListenerAdapter() {
@Override
Expand All @@ -328,15 +330,15 @@ public void onAnimationEnd(Animator animation) {
for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
dismissPositions[i] = mPendingDismisses.get(i).position;
}
mCallback.onDismiss(mListView, dismissPositions);
mCallback.onDismiss(mListView, dismissPositions, dismissView,null);

ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
// Reset view presentation
setAlpha(pendingDismiss.view, 1f);
setTranslationX(pendingDismiss.view, 0);
lp = pendingDismiss.view.getLayoutParams();
lp.height = originalHeight;
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
pendingDismiss.view.setLayoutParams(lp);
}

Expand All @@ -354,6 +356,11 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
});

mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
animator.start();*/
setAlpha(dismissView, 1f);
setTranslationX(dismissView, 0);
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
dismissView.setLayoutParams(lp);
mCallback.onDismiss(mListView, dismissPosition, dismissView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void onAnimationEnd(Animator animation) {
// Reset view presentation
setAlpha(mView, 1f);
setTranslationX(mView, 0);
lp.height = originalHeight;
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
mView.setLayoutParams(lp);
}
});
Expand Down