diff --git a/.gitignore b/.gitignore
index 3a01e433bcf974bb126f462f74b58107673bdf9c..37a4eb8b43d978ea05b2c6e3fb934f9b40dddd4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,31 +1,15 @@
-# Built application files
-*.apk
-*.ap_
-
-# Files for the Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-
-# Gradle files
-.gradle/
-build/
-/*/build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-#AndroidStudio files
-.idea/
*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
diff --git a/README.md b/README.md
index be0a3631f3974887ac26597d95dfc0a6f46b0fe7..13b79f7e09c4afb1875320c506d53c68f7597cb8 100644
--- a/README.md
+++ b/README.md
@@ -1,131 +1,84 @@
# SwipeStack
-A simple, customizable and easy to use swipeable view stack for Android.
-[ ](https://bintray.com/flschweiger/maven/swipestack/_latestVersion)
-[](http://www.apache.org/licenses/LICENSE-2.0)
-[](http://android-arsenal.com/details/1/3079)
+#### 项目介绍
+- 项目名称: SwipeStack
+- 所属系列:openharmony的第三方组件适配移植
+- 功能: 可滑动视图堆栈
+- 项目移植状态:完成
+- 调用差异:无
+- 开发版本:sdk6,DevEco Studio2.2 Beta1
+- 基线版本:0.3.0
-
-
-
-## QuickStart ##
-### Include the Gradle dependency ###
+#### 效果演示
-```java
-dependencies {
- compile 'link.fls:swipestack:0.3.0'
-}
-```
-
-### Use it in your layout file ###
-1. Use the `link.fls.swipestack.SwipeStack` view in your XML layout file
-2. Set the parent view's `clipChildren` attribute to `false`
-
-*Example:*
-
-```xml
-
-
-
-
-
-
-```
+#### 安装教程
-### Create an adapter ###
+1.在项目根目录下的build.gradle文件中,
-Create an adapter which holds the data and creates the views for the stack.
-
-*Example:*
-
-```java
-public class SwipeStackAdapter extends BaseAdapter {
-
- private List mData;
-
- public SwipeStackAdapter(List data) {
- this.mData = data;
- }
-
- @Override
- public int getCount() {
- return mData.size();
- }
-
- @Override
- public String getItem(int position) {
- return mData.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
- TextView textViewCard = (TextView) convertView.findViewById(R.id.textViewCard);
- textViewCard.setText(mData.get(position));
-
- return convertView;
+ ```gradle
+allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
}
}
-```
+ ```
-### Assign the adapter to the SwipeStack ###
+2.在entry模块的build.gradle文件中,
-Last, but not least, assign the adapter to the SwipeStack.
+ ```gradle
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:SwipeStack:0.0.1-SNAPSHOT')
+ ......
+ }
+ ```
-*Example:*
+在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行
-```java
-SwipeStack swipeStack = (SwipeStack) findViewById(R.id.swipeStack);
-swipeStack.setAdapter(new SwipeStackAdapter(mData));
-```
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
-That's it!
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
-## Callbacks ##
-Currently SwipeStack implements the following callbacks:
+#### 使用说明
-- the ` SwipeStackListener ` notifies you when a view was swiped to the left / right or when the stack becomes empty.
-- the ` SwipeProgressListener ` notifies you about the progress when the user starts / stops dragging a view around.
-## Attributes ##
+XML中添加控件:
-*All attributes are optional.*
+```xml
+
+```
-`allowed_swipe_directions` specifies the allowed swipe directions. *Default: both*
+```java
+ SwipeDirectionalView mSwipeStack;
+ mSwipeStack = (SwipeDirectionalView) findComponentById(ResourceTable.Id_swipeStack);
-`animation_duration` specifies the duration of the animations. *Default: 300ms*
+ for (int i = 0; i < 5; i++) {
+ mSwipeStack.addView(makeCard("Test " + mCount++), random.nextInt(20) - 10);
+ }
+ mSwipeStack.setSwipeStackListener(this);
+```
-`stack_size` specifies the maximum number of visible views. *Default: 3*
-`stack_spacing` specifies the vertical distance between two views. *Default: 12dp*
+#### 测试信息
-`stack_rotation` specifies the maximum random ratation (in degrees) of a card on the stack. *Default: 8*
+CodeCheck代码测试无异常
-`swipe_rotation` specifies the rotation (in degrees) of the view when it gets swiped left / right. *Default: 15*
+CloudTest代码测试无异常
-`swipe_opacity` specifies the opacity of the view when it gets swiped left / right. *Default: 1.0*
+病毒安全检测通过
-`scale_factor` specifies the scale factor of the views in the stack. *Default: 1.0*
+当前版本demo功能与原组件基本无差异
-`disable_hw_acceleration` set to `true` disables hardware acceleration. *Default: false*
+## 版本迭代
+- 0.0.1-SNAPSHOT
-## Copyright Notice ##
+## 版权和许可信息
```
Copyright (C) 2016 Frederik Schweiger
diff --git a/art/demo.gif b/art/demo.gif
deleted file mode 100644
index f68d4433dd71fdb131f26e1ef91a4d80a8147f04..0000000000000000000000000000000000000000
Binary files a/art/demo.gif and /dev/null differ
diff --git a/art/demo.mp4 b/art/demo.mp4
deleted file mode 100644
index 860bae2d8a19a9345abc1eb2fe2379a9f06d1a68..0000000000000000000000000000000000000000
Binary files a/art/demo.mp4 and /dev/null differ
diff --git a/art/screen1.png b/art/screen1.png
deleted file mode 100644
index 0897b7be5951753800150ca1f824abfd415e088a..0000000000000000000000000000000000000000
Binary files a/art/screen1.png and /dev/null differ
diff --git a/art/screen2.png b/art/screen2.png
deleted file mode 100644
index a0a92dace1d79cae87a308bb1924e97f788517ae..0000000000000000000000000000000000000000
Binary files a/art/screen2.png and /dev/null differ
diff --git a/build.gradle b/build.gradle
index 23b974aa28669ad2c2bee12c91b6600551069e04..49bd550bd2daf5240e23681f66bd1c5b835cc430 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,21 +1,36 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
buildscript {
repositories {
- jcenter()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0-beta5'
- classpath 'com.novoda:bintray-release:0.3.4'
+ classpath 'com.huawei.ohos:hap:2.4.5.0'
+ classpath 'com.huawei.ohos:decctest:1.2.4.1'
}
}
allprojects {
repositories {
- jcenter()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..be492496f9a20ac2d980ef4fc30061f4184c1c40 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,13 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 122a0dca2e800b3ccf474321fc5e63551f507d29..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec99730b4e8fcd90b57a0e8e01544fea7c31a89..9109989e3cbf666b0a3c8f48fd92bd03bb53b968 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/library/build.gradle b/library/build.gradle
index 234b0105b606108560d0f48b32505fa50c5fe3bb..14f5735bfabff299fbbac83b86b87a07cf3b1c21 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,38 +1,23 @@
-apply plugin: 'com.android.library'
-apply plugin: 'bintray-release'
-
-def final String VERSION_NAME = "0.3.0"
-def final int VERSION_CODE = 30
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
-
+apply plugin: 'com.huawei.ohos.library'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ compileSdkVersion 6
defaultConfig {
- minSdkVersion 16
- targetSdkVersion 23
- versionCode VERSION_CODE
- versionName VERSION_NAME
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.1.1'
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'org.jetbrains:annotations:19.0.0'
+ testImplementation 'junit:junit:4.13'
}
-
-publish {
- userOrg = 'flschweiger'
- groupId = 'link.fls'
- artifactId = 'swipestack'
- publishVersion = VERSION_NAME
- desc = 'A swipeable view stack for Android.'
- website = 'https://github.com/flschweiger/SwipeStack'
-}
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index b56929743be94ae90c619bbbbcffeeeeafa7aa41..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
diff --git a/library/src/main/java/link/fls/swipestack/SwipeHelper.java b/library/src/main/java/link/fls/swipestack/SwipeHelper.java
deleted file mode 100644
index 43b7b72fc278afdbf52ae19adca8d7a7390f818e..0000000000000000000000000000000000000000
--- a/library/src/main/java/link/fls/swipestack/SwipeHelper.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2016 Frederik Schweiger
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package link.fls.swipestack;
-
-import android.animation.Animator;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.animation.OvershootInterpolator;
-
-import link.fls.swipestack.util.AnimationUtils;
-
-public class SwipeHelper implements View.OnTouchListener {
-
- private final SwipeStack mSwipeStack;
- private View mObservedView;
-
- private boolean mListenForTouchEvents;
- private float mDownX;
- private float mDownY;
- private float mInitialX;
- private float mInitialY;
- private int mPointerId;
-
- private float mRotateDegrees = SwipeStack.DEFAULT_SWIPE_ROTATION;
- private float mOpacityEnd = SwipeStack.DEFAULT_SWIPE_OPACITY;
- private int mAnimationDuration = SwipeStack.DEFAULT_ANIMATION_DURATION;
-
- public SwipeHelper(SwipeStack swipeStack) {
- mSwipeStack = swipeStack;
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
-
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if(!mListenForTouchEvents || !mSwipeStack.isEnabled()) {
- return false;
- }
-
- v.getParent().requestDisallowInterceptTouchEvent(true);
- mSwipeStack.onSwipeStart();
- mPointerId = event.getPointerId(0);
- mDownX = event.getX(mPointerId);
- mDownY = event.getY(mPointerId);
-
- return true;
-
- case MotionEvent.ACTION_MOVE:
- int pointerIndex = event.findPointerIndex(mPointerId);
- if (pointerIndex < 0) return false;
-
- float dx = event.getX(pointerIndex) - mDownX;
- float dy = event.getY(pointerIndex) - mDownY;
-
- float newX = mObservedView.getX() + dx;
- float newY = mObservedView.getY() + dy;
-
- mObservedView.setX(newX);
- mObservedView.setY(newY);
-
- float dragDistanceX = newX - mInitialX;
- float swipeProgress = Math.min(Math.max(
- dragDistanceX / mSwipeStack.getWidth(), -1), 1);
-
- mSwipeStack.onSwipeProgress(swipeProgress);
-
- if (mRotateDegrees > 0) {
- float rotation = mRotateDegrees * swipeProgress;
- mObservedView.setRotation(rotation);
- }
-
- if (mOpacityEnd < 1f) {
- float alpha = 1 - Math.min(Math.abs(swipeProgress * 2), 1);
- mObservedView.setAlpha(alpha);
- }
-
- return true;
-
- case MotionEvent.ACTION_UP:
- v.getParent().requestDisallowInterceptTouchEvent(false);
- mSwipeStack.onSwipeEnd();
- checkViewPosition();
-
- return true;
-
- }
-
- return false;
- }
-
- private void checkViewPosition() {
- if(!mSwipeStack.isEnabled()) {
- resetViewPosition();
- return;
- }
-
- float viewCenterHorizontal = mObservedView.getX() + (mObservedView.getWidth() / 2);
- float parentFirstThird = mSwipeStack.getWidth() / 3f;
- float parentLastThird = parentFirstThird * 2;
-
- if (viewCenterHorizontal < parentFirstThird &&
- mSwipeStack.getAllowedSwipeDirections() != SwipeStack.SWIPE_DIRECTION_ONLY_RIGHT) {
- swipeViewToLeft(mAnimationDuration / 2);
- } else if (viewCenterHorizontal > parentLastThird &&
- mSwipeStack.getAllowedSwipeDirections() != SwipeStack.SWIPE_DIRECTION_ONLY_LEFT) {
- swipeViewToRight(mAnimationDuration / 2);
- } else {
- resetViewPosition();
- }
- }
-
- private void resetViewPosition() {
- mObservedView.animate()
- .x(mInitialX)
- .y(mInitialY)
- .rotation(0)
- .alpha(1)
- .setDuration(mAnimationDuration)
- .setInterpolator(new OvershootInterpolator(1.4f))
- .setListener(null);
- }
-
- private void swipeViewToLeft(int duration) {
- if (!mListenForTouchEvents) return;
- mListenForTouchEvents = false;
- mObservedView.animate().cancel();
- mObservedView.animate()
- .x(-mSwipeStack.getWidth() + mObservedView.getX())
- .rotation(-mRotateDegrees)
- .alpha(0f)
- .setDuration(duration)
- .setListener(new AnimationUtils.AnimationEndListener() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mSwipeStack.onViewSwipedToLeft();
- }
- });
- }
-
- private void swipeViewToRight(int duration) {
- if (!mListenForTouchEvents) return;
- mListenForTouchEvents = false;
- mObservedView.animate().cancel();
- mObservedView.animate()
- .x(mSwipeStack.getWidth() + mObservedView.getX())
- .rotation(mRotateDegrees)
- .alpha(0f)
- .setDuration(duration)
- .setListener(new AnimationUtils.AnimationEndListener() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mSwipeStack.onViewSwipedToRight();
- }
- });
- }
-
- public void registerObservedView(View view, float initialX, float initialY) {
- if (view == null) return;
- mObservedView = view;
- mObservedView.setOnTouchListener(this);
- mInitialX = initialX;
- mInitialY = initialY;
- mListenForTouchEvents = true;
- }
-
- public void unregisterObservedView() {
- if (mObservedView != null) {
- mObservedView.setOnTouchListener(null);
- }
- mObservedView = null;
- mListenForTouchEvents = false;
- }
-
- public void setAnimationDuration(int duration) {
- mAnimationDuration = duration;
- }
-
- public void setRotation(float rotation) {
- mRotateDegrees = rotation;
- }
-
- public void setOpacityEnd(float alpha) {
- mOpacityEnd = alpha;
- }
-
- public void swipeViewToLeft() {
- swipeViewToLeft(mAnimationDuration);
- }
-
- public void swipeViewToRight() {
- swipeViewToRight(mAnimationDuration);
- }
-
-}
diff --git a/library/src/main/java/link/fls/swipestack/SwipeStack.java b/library/src/main/java/link/fls/swipestack/SwipeStack.java
deleted file mode 100644
index 175e28da0c55d624b0d915c1b506ca4ae7957369..0000000000000000000000000000000000000000
--- a/library/src/main/java/link/fls/swipestack/SwipeStack.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (C) 2016 Frederik Schweiger
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package link.fls.swipestack;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.database.DataSetObserver;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Adapter;
-import android.widget.FrameLayout;
-
-import java.util.Random;
-
-public class SwipeStack extends ViewGroup {
-
- public static final int SWIPE_DIRECTION_BOTH = 0;
- public static final int SWIPE_DIRECTION_ONLY_LEFT = 1;
- public static final int SWIPE_DIRECTION_ONLY_RIGHT = 2;
-
- public static final int DEFAULT_ANIMATION_DURATION = 300;
- public static final int DEFAULT_STACK_SIZE = 3;
- public static final int DEFAULT_STACK_ROTATION = 8;
- public static final float DEFAULT_SWIPE_ROTATION = 30f;
- public static final float DEFAULT_SWIPE_OPACITY = 1f;
- public static final float DEFAULT_SCALE_FACTOR = 1f;
- public static final boolean DEFAULT_DISABLE_HW_ACCELERATION = true;
-
- private static final String KEY_SUPER_STATE = "superState";
- private static final String KEY_CURRENT_INDEX = "currentIndex";
-
- private Adapter mAdapter;
- private Random mRandom;
-
- private int mAllowedSwipeDirections;
- private int mAnimationDuration;
- private int mCurrentViewIndex;
- private int mNumberOfStackedViews;
- private int mViewSpacing;
- private int mViewRotation;
- private float mSwipeRotation;
- private float mSwipeOpacity;
- private float mScaleFactor;
- private boolean mDisableHwAcceleration;
- private boolean mIsFirstLayout = true;
-
- private View mTopView;
- private SwipeHelper mSwipeHelper;
- private DataSetObserver mDataObserver;
- private SwipeStackListener mListener;
- private SwipeProgressListener mProgressListener;
-
- public SwipeStack(Context context) {
- this(context, null);
- }
-
- public SwipeStack(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SwipeStack(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- readAttributes(attrs);
- initialize();
- }
-
- private void readAttributes(AttributeSet attributeSet) {
- TypedArray attrs = getContext().obtainStyledAttributes(attributeSet, R.styleable.SwipeStack);
-
- try {
- mAllowedSwipeDirections =
- attrs.getInt(R.styleable.SwipeStack_allowed_swipe_directions,
- SWIPE_DIRECTION_BOTH);
- mAnimationDuration =
- attrs.getInt(R.styleable.SwipeStack_animation_duration,
- DEFAULT_ANIMATION_DURATION);
- mNumberOfStackedViews =
- attrs.getInt(R.styleable.SwipeStack_stack_size, DEFAULT_STACK_SIZE);
- mViewSpacing =
- attrs.getDimensionPixelSize(R.styleable.SwipeStack_stack_spacing,
- getResources().getDimensionPixelSize(R.dimen.default_stack_spacing));
- mViewRotation =
- attrs.getInt(R.styleable.SwipeStack_stack_rotation, DEFAULT_STACK_ROTATION);
- mSwipeRotation =
- attrs.getFloat(R.styleable.SwipeStack_swipe_rotation, DEFAULT_SWIPE_ROTATION);
- mSwipeOpacity =
- attrs.getFloat(R.styleable.SwipeStack_swipe_opacity, DEFAULT_SWIPE_OPACITY);
- mScaleFactor =
- attrs.getFloat(R.styleable.SwipeStack_scale_factor, DEFAULT_SCALE_FACTOR);
- mDisableHwAcceleration =
- attrs.getBoolean(R.styleable.SwipeStack_disable_hw_acceleration,
- DEFAULT_DISABLE_HW_ACCELERATION);
- } finally {
- attrs.recycle();
- }
- }
-
- private void initialize() {
- mRandom = new Random();
-
- setClipToPadding(false);
- setClipChildren(false);
-
- mSwipeHelper = new SwipeHelper(this);
- mSwipeHelper.setAnimationDuration(mAnimationDuration);
- mSwipeHelper.setRotation(mSwipeRotation);
- mSwipeHelper.setOpacityEnd(mSwipeOpacity);
-
- mDataObserver = new DataSetObserver() {
- @Override
- public void onChanged() {
- super.onChanged();
- invalidate();
- requestLayout();
- }
- };
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Bundle bundle = new Bundle();
- bundle.putParcelable(KEY_SUPER_STATE, super.onSaveInstanceState());
- bundle.putInt(KEY_CURRENT_INDEX, mCurrentViewIndex - getChildCount());
- return bundle;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- if (state instanceof Bundle) {
- Bundle bundle = (Bundle) state;
- mCurrentViewIndex = bundle.getInt(KEY_CURRENT_INDEX);
- state = bundle.getParcelable(KEY_SUPER_STATE);
- }
-
- super.onRestoreInstanceState(state);
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
-
- if (mAdapter == null || mAdapter.isEmpty()) {
- mCurrentViewIndex = 0;
- removeAllViewsInLayout();
- return;
- }
-
- for (int x = getChildCount();
- x < mNumberOfStackedViews && mCurrentViewIndex < mAdapter.getCount();
- x++) {
- addNextView();
- }
-
- reorderItems();
-
- mIsFirstLayout = false;
- }
-
- private void addNextView() {
- if (mCurrentViewIndex < mAdapter.getCount()) {
- View bottomView = mAdapter.getView(mCurrentViewIndex, null, this);
- bottomView.setTag(R.id.new_view, true);
-
- if (!mDisableHwAcceleration) {
- bottomView.setLayerType(LAYER_TYPE_HARDWARE, null);
- }
-
- if (mViewRotation > 0) {
- bottomView.setRotation(mRandom.nextInt(mViewRotation) - (mViewRotation / 2));
- }
-
- int width = getWidth() - (getPaddingLeft() + getPaddingRight());
- int height = getHeight() - (getPaddingTop() + getPaddingBottom());
-
- LayoutParams params = bottomView.getLayoutParams();
- if (params == null) {
- params = new LayoutParams(
- FrameLayout.LayoutParams.WRAP_CONTENT,
- FrameLayout.LayoutParams.WRAP_CONTENT);
- }
-
- int measureSpecWidth = MeasureSpec.AT_MOST;
- int measureSpecHeight = MeasureSpec.AT_MOST;
-
- if (params.width == LayoutParams.MATCH_PARENT) {
- measureSpecWidth = MeasureSpec.EXACTLY;
- }
-
- if (params.height == LayoutParams.MATCH_PARENT) {
- measureSpecHeight = MeasureSpec.EXACTLY;
- }
-
- bottomView.measure(measureSpecWidth | width, measureSpecHeight | height);
- addViewInLayout(bottomView, 0, params, true);
-
- mCurrentViewIndex++;
- }
- }
-
- private void reorderItems() {
- for (int x = 0; x < getChildCount(); x++) {
- View childView = getChildAt(x);
- int topViewIndex = getChildCount() - 1;
-
- int distanceToViewAbove = (topViewIndex * mViewSpacing) - (x * mViewSpacing);
- int newPositionX = (getWidth() - childView.getMeasuredWidth()) / 2;
- int newPositionY = distanceToViewAbove + getPaddingTop();
-
- childView.layout(
- newPositionX,
- getPaddingTop(),
- newPositionX + childView.getMeasuredWidth(),
- getPaddingTop() + childView.getMeasuredHeight());
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- childView.setTranslationZ(x);
- }
-
- boolean isNewView = (boolean) childView.getTag(R.id.new_view);
- float scaleFactor = (float) Math.pow(mScaleFactor, getChildCount() - x);
-
- if (x == topViewIndex) {
- mSwipeHelper.unregisterObservedView();
- mTopView = childView;
- mSwipeHelper.registerObservedView(mTopView, newPositionX, newPositionY);
- }
-
- if (!mIsFirstLayout) {
-
- if (isNewView) {
- childView.setTag(R.id.new_view, false);
- childView.setAlpha(0);
- childView.setY(newPositionY);
- childView.setScaleY(scaleFactor);
- childView.setScaleX(scaleFactor);
- }
-
- childView.animate()
- .y(newPositionY)
- .scaleX(scaleFactor)
- .scaleY(scaleFactor)
- .alpha(1)
- .setDuration(mAnimationDuration);
-
- } else {
- childView.setTag(R.id.new_view, false);
- childView.setY(newPositionY);
- childView.setScaleY(scaleFactor);
- childView.setScaleX(scaleFactor);
- }
- }
- }
-
- private void removeTopView() {
- if (mTopView != null) {
- removeView(mTopView);
- mTopView = null;
- }
-
- if (getChildCount() == 0) {
- if (mListener != null) mListener.onStackEmpty();
- }
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int width = MeasureSpec.getSize(widthMeasureSpec);
- int height = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(width, height);
- }
-
- public void onSwipeStart() {
- if (mProgressListener != null) mProgressListener.onSwipeStart(getCurrentPosition());
- }
-
- public void onSwipeProgress(float progress) {
- if (mProgressListener != null)
- mProgressListener.onSwipeProgress(getCurrentPosition(), progress);
- }
-
- public void onSwipeEnd() {
- if (mProgressListener != null) mProgressListener.onSwipeEnd(getCurrentPosition());
- }
-
- public void onViewSwipedToLeft() {
- if (mListener != null) mListener.onViewSwipedToLeft(getCurrentPosition());
- removeTopView();
- }
-
- public void onViewSwipedToRight() {
- if (mListener != null) mListener.onViewSwipedToRight(getCurrentPosition());
- removeTopView();
- }
-
- /**
- * Returns the current adapter position.
- *
- * @return The current position.
- */
- public int getCurrentPosition() {
- return mCurrentViewIndex - getChildCount();
- }
-
- /**
- * Returns the adapter currently in use in this SwipeStack.
- *
- * @return The adapter currently used to display data in this SwipeStack.
- */
- public Adapter getAdapter() {
- return mAdapter;
- }
-
- /**
- * Sets the data behind this SwipeView.
- *
- * @param adapter The Adapter which is responsible for maintaining the
- * data backing this list and for producing a view to represent an
- * item in that data set.
- * @see #getAdapter()
- */
- public void setAdapter(Adapter adapter) {
- if (mAdapter != null) mAdapter.unregisterDataSetObserver(mDataObserver);
- mAdapter = adapter;
- mAdapter.registerDataSetObserver(mDataObserver);
- }
-
- /**
- * Returns the allowed swipe directions.
- *
- * @return The currently allowed swipe directions.
- */
- public int getAllowedSwipeDirections() {
- return mAllowedSwipeDirections;
- }
-
- /**
- * Sets the allowed swipe directions.
- *
- * @param directions One of {@link #SWIPE_DIRECTION_BOTH},
- * {@link #SWIPE_DIRECTION_ONLY_LEFT}, or {@link #SWIPE_DIRECTION_ONLY_RIGHT}.
- */
- public void setAllowedSwipeDirections(int directions) {
- mAllowedSwipeDirections = directions;
- }
-
- /**
- * Register a callback to be invoked when the user has swiped the top view
- * left / right or when the stack gets empty.
- *
- * @param listener The callback that will run
- */
- public void setListener(@Nullable SwipeStackListener listener) {
- mListener = listener;
- }
-
- /**
- * Register a callback to be invoked when the user starts / stops interacting
- * with the top view of the stack.
- *
- * @param listener The callback that will run
- */
- public void setSwipeProgressListener(@Nullable SwipeProgressListener listener) {
- mProgressListener = listener;
- }
-
- /**
- * Get the view from the top of the stack.
- *
- * @return The view if the stack is not empty or null otherwise.
- */
- public View getTopView() {
- return mTopView;
- }
-
- /**
- * Programmatically dismiss the top view to the right.
- */
- public void swipeTopViewToRight() {
- if (getChildCount() == 0) return;
- mSwipeHelper.swipeViewToRight();
- }
-
- /**
- * Programmatically dismiss the top view to the left.
- */
- public void swipeTopViewToLeft() {
- if (getChildCount() == 0) return;
- mSwipeHelper.swipeViewToLeft();
- }
-
- /**
- * Resets the current adapter position and repopulates the stack.
- */
- public void resetStack() {
- mCurrentViewIndex = 0;
- removeAllViewsInLayout();
- requestLayout();
- }
-
- /**
- * Interface definition for a callback to be invoked when the top view was
- * swiped to the left / right or when the stack gets empty.
- */
- public interface SwipeStackListener {
- /**
- * Called when a view has been dismissed to the left.
- *
- * @param position The position of the view in the adapter currently in use.
- */
- void onViewSwipedToLeft(int position);
-
- /**
- * Called when a view has been dismissed to the right.
- *
- * @param position The position of the view in the adapter currently in use.
- */
- void onViewSwipedToRight(int position);
-
- /**
- * Called when the last view has been dismissed.
- */
- void onStackEmpty();
- }
-
- /**
- * Interface definition for a callback to be invoked when the user
- * starts / stops interacting with the top view of the stack.
- */
- public interface SwipeProgressListener {
- /**
- * Called when the user starts interacting with the top view of the stack.
- *
- * @param position The position of the view in the currently set adapter.
- */
- void onSwipeStart(int position);
-
- /**
- * Called when the user is dragging the top view of the stack.
- *
- * @param position The position of the view in the currently set adapter.
- * @param progress Represents the horizontal dragging position in relation to
- * the start position of the drag.
- */
- void onSwipeProgress(int position, float progress);
-
- /**
- * Called when the user has stopped interacting with the top view of the stack.
- *
- * @param position The position of the view in the currently set adapter.
- */
- void onSwipeEnd(int position);
- }
-}
diff --git a/library/src/main/java/link/fls/swipestack/util/AnimationUtils.java b/library/src/main/java/link/fls/swipestack/util/AnimationUtils.java
deleted file mode 100644
index f5c8fe426c8caddfb5bce7d395442b778ef93bfe..0000000000000000000000000000000000000000
--- a/library/src/main/java/link/fls/swipestack/util/AnimationUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2016 Frederik Schweiger
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package link.fls.swipestack.util;
-
-import android.animation.Animator;
-
-public class AnimationUtils {
-
- public static abstract class AnimationEndListener implements Animator.AnimatorListener {
- @Override
- public void onAnimationStart(Animator animation) {
- // Do nothing
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- // Do nothing
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- // Do nothing
- }
- }
-}
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
deleted file mode 100644
index 0ec3fcddb29009d7d869a4aae8a60b15c6e1f9e0..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
deleted file mode 100644
index 4602a2483116b6d8ecb02dac256dc2e00c7ecefe..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 12dp
-
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index b4a09f324897c672134d105d73ce98a7154abd54..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- SwipeStack
-
diff --git a/library/src/main/res/values/tags.xml b/library/src/main/res/values/tags.xml
deleted file mode 100644
index 627694fe53fc775a450a628e091707d07b16f849..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/tags.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/sample/.gitignore b/sample/.gitignore
deleted file mode 100644
index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000
--- a/sample/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/sample/build.gradle b/sample/build.gradle
deleted file mode 100644
index 25e8ece0b9bdd0e2a776346f1aa56afb9d230d28..0000000000000000000000000000000000000000
--- a/sample/build.gradle
+++ /dev/null
@@ -1,29 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
-
- defaultConfig {
- applicationId "link.fls.swipestacksample"
- minSdkVersion 16
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile project(':library')
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:cardview-v7:23.1.1'
- compile 'com.android.support:design:23.1.1'
-}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
deleted file mode 100644
index 0863bec2391a2545949276d1283089c8a7f3b945..0000000000000000000000000000000000000000
--- a/sample/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/src/main/java/link/fls/swipestacksample/MainActivity.java b/sample/src/main/java/link/fls/swipestacksample/MainActivity.java
deleted file mode 100644
index 5eb22de2b2decc47739698f190cbc5d586f6db7c..0000000000000000000000000000000000000000
--- a/sample/src/main/java/link/fls/swipestacksample/MainActivity.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2016 Frederik Schweiger
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package link.fls.swipestacksample;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import link.fls.swipestack.SwipeStack;
-
-public class MainActivity extends AppCompatActivity implements SwipeStack.SwipeStackListener, View.OnClickListener {
-
- private Button mButtonLeft, mButtonRight;
- private FloatingActionButton mFab;
-
- private ArrayList mData;
- private SwipeStack mSwipeStack;
- private SwipeStackAdapter mAdapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- mSwipeStack = (SwipeStack) findViewById(R.id.swipeStack);
- mButtonLeft = (Button) findViewById(R.id.buttonSwipeLeft);
- mButtonRight = (Button) findViewById(R.id.buttonSwipeRight);
- mFab = (FloatingActionButton) findViewById(R.id.fabAdd);
-
- mButtonLeft.setOnClickListener(this);
- mButtonRight.setOnClickListener(this);
- mFab.setOnClickListener(this);
-
- mData = new ArrayList<>();
- mAdapter = new SwipeStackAdapter(mData);
- mSwipeStack.setAdapter(mAdapter);
- mSwipeStack.setListener(this);
-
- fillWithTestData();
- }
-
- private void fillWithTestData() {
- for (int x = 0; x < 5; x++) {
- mData.add(getString(R.string.dummy_text) + " " + (x + 1));
- }
- }
-
- @Override
- public void onClick(View v) {
- if (v.equals(mButtonLeft)) {
- mSwipeStack.swipeTopViewToLeft();
- } else if (v.equals(mButtonRight)) {
- mSwipeStack.swipeTopViewToRight();
- } else if (v.equals(mFab)) {
- mData.add(getString(R.string.dummy_fab));
- mAdapter.notifyDataSetChanged();
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.menuReset:
- mSwipeStack.resetStack();
- Snackbar.make(mFab, R.string.stack_reset, Snackbar.LENGTH_SHORT).show();
- return true;
- case R.id.menuGitHub:
- Intent browserIntent = new Intent(
- Intent.ACTION_VIEW, Uri.parse("https://github.com/flschweiger/SwipeStack"));
- startActivity(browserIntent);
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onViewSwipedToRight(int position) {
- String swipedElement = mAdapter.getItem(position);
- Toast.makeText(this, getString(R.string.view_swiped_right, swipedElement),
- Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onViewSwipedToLeft(int position) {
- String swipedElement = mAdapter.getItem(position);
- Toast.makeText(this, getString(R.string.view_swiped_left, swipedElement),
- Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onStackEmpty() {
- Toast.makeText(this, R.string.stack_empty, Toast.LENGTH_SHORT).show();
- }
-
- public class SwipeStackAdapter extends BaseAdapter {
-
- private List mData;
-
- public SwipeStackAdapter(List data) {
- this.mData = data;
- }
-
- @Override
- public int getCount() {
- return mData.size();
- }
-
- @Override
- public String getItem(int position) {
- return mData.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
- }
-
- TextView textViewCard = (TextView) convertView.findViewById(R.id.textViewCard);
- textViewCard.setText(mData.get(position));
-
- return convertView;
- }
- }
-}
diff --git a/sample/src/main/res/drawable-hdpi/ic_content_add.png b/sample/src/main/res/drawable-hdpi/ic_content_add.png
deleted file mode 100755
index c12a7a21ede24abf599984d0c215e462c0b3f90e..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-hdpi/ic_content_add.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-mdpi/ic_content_add.png b/sample/src/main/res/drawable-mdpi/ic_content_add.png
deleted file mode 100755
index 3422959c3b16bf7bc1e58f3735dd713af85133aa..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-mdpi/ic_content_add.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xhdpi/ic_content_add.png b/sample/src/main/res/drawable-xhdpi/ic_content_add.png
deleted file mode 100755
index 34a144d127042811d9c08394b1da13ab74046102..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xhdpi/ic_content_add.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxhdpi/ic_content_add.png b/sample/src/main/res/drawable-xxhdpi/ic_content_add.png
deleted file mode 100755
index 8370c67a47c7ed57ff61aefc69dbedadf125e903..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxhdpi/ic_content_add.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxxhdpi/ic_content_add.png b/sample/src/main/res/drawable-xxxhdpi/ic_content_add.png
deleted file mode 100755
index c1ba3b33c676395e2d3d69707f03afec205e6362..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxxhdpi/ic_content_add.png and /dev/null differ
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
deleted file mode 100644
index aa537beecd918007e0c231d6f6a7461e6168e700..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/src/main/res/layout/card.xml b/sample/src/main/res/layout/card.xml
deleted file mode 100644
index 815e0cbf48c732d6b870d536a0bff817be3fd55c..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/card.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/menu/main.xml b/sample/src/main/res/menu/main.xml
deleted file mode 100644
index 2c9adda94bd8ccfc412aa351376b00d715cf960e..0000000000000000000000000000000000000000
--- a/sample/src/main/res/menu/main.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher.png b/sample/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100755
index efbdb8497248765bca90b8f9b9268eed558dfbba..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100755
index f791f78677cbf74c84051566fd0e6bc64306e16f..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100755
index 3a241776d4f5d89205b8b500d67ff1d18231e361..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100755
index 7dd78fcddcf23fa386213b7d557c386251eb4dc4..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100755
index b7738c3d8a58c133ed6994bc7946385719b30e49..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
deleted file mode 100644
index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/sample/src/main/res/values/dimens.xml b/sample/src/main/res/values/dimens.xml
deleted file mode 100644
index e08b4a166111995ea9280c24943ada5346f3248a..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- 6dp
-
- 16dp
- 8dp
- 64dp
-
- 4dp
- 8dp
-
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
deleted file mode 100644
index 44766850fbc2151fb04a599a6714730968ddf1a7..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- SwipeStack Demo
-
- Swipe left
- Swipe right
- %1$s swiped to left!
- %1$s swiped to right!
- Test
- Fab Test
-
- Reset stack
- Stack reset!
- Card stack empty!
- View on GitHub
-
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
deleted file mode 100644
index 82e163e478efc0cece87f80bf9f355979878b3f3..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
diff --git a/settings.gradle b/settings.gradle
index 52baf7e648cbb87f360039dd6c3920b9f0db3aaa..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':sample', ':library'
+include ':entry', ':library'