Skip to content

Commit

Permalink
Merge pull request #18 from aitsuki/fix-17
Browse files Browse the repository at this point in the history
Fix #17
  • Loading branch information
aitsuki committed Mar 13, 2022
2 parents da31ef4 + 8aab550 commit ac03316
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 4 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
compileSdk 31
defaultConfig {
applicationId "com.aitsuki.swipedemo"
minSdkVersion 16
targetSdkVersion 31
minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"
}
Expand All @@ -30,6 +30,7 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'com.aitsuki.swipedemo'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aitsuki.swipedemo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="false"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-1-all.zip
7 changes: 4 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ repositories {
}

android {
compileSdkVersion 31
compileSdk 31

defaultConfig {
minSdkVersion 15
targetSdkVersion 31
minSdk 15
targetSdk 31
consumerProguardFiles 'proguard-rules.pro'
}
buildTypes {
Expand All @@ -31,6 +31,7 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'com.aitsuki.swipe'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aitsuki.swipe">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
16 changes: 8 additions & 8 deletions library/src/main/java/com/aitsuki/swipe/SwipeLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ class SwipeLayout @JvmOverloads constructor(
// If menu is INVISIBLE, move it to outside. See isTouchMenu.
menuView.layout(left - menuView.width, menuView.top, left, menuView.bottom)
} else {
menuView.layout(left, menuView.top, left + menuView.width, menuView.bottom)
menuView.layout(right - menuView.width, menuView.top, right, menuView.bottom)
if (menuView is ViewGroup && menuView.childCount > 1) {
layoutLeftMenu(menuView, left, right)
}
Expand All @@ -764,17 +764,17 @@ class SwipeLayout @JvmOverloads constructor(

private fun layoutLeftMenu(menuView: ViewGroup, left: Int, right: Int) {
val onScreen = (right - left).toFloat() / menuView.width
var child = menuView.getChildAt(menuView.childCount - 1)
var childLeft = (right - child.width * onScreen).toInt()
child.layout(childLeft, child.top, childLeft + child.width, child.bottom)
var child = menuView.getChildAt(0)
var childRight = menuView.width
child.layout(childRight - child.width, child.top, childRight, child.bottom)
var prevChild = child
for (i in menuView.childCount - 2 downTo 0) {
for (i in 1 until menuView.childCount) {
child = menuView.getChildAt(i)
childLeft = (prevChild.left - child.width * onScreen).toInt()
childRight = (prevChild.right - prevChild.width * onScreen).toInt()
child.layout(
childLeft,
childRight - child.width,
child.top,
childLeft + child.width,
childRight ,
child.bottom
)
prevChild = child
Expand Down

0 comments on commit ac03316

Please sign in to comment.