Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.4.0'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.novoda:bintray-release:0.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
google()
}
}

Expand All @@ -27,10 +31,10 @@ ext {
publishVersion = '1.1.0'
licences = ['Apache-2.0']

compileSdkVersion = 26
buildToolsVersion = '26.0.1'
compileSdkVersion = 28
minSdkVersion = 16
targetSdkVersion = 25
targetSdkVersion = 28

supportLibVersion = '1.0.0-beta01'
}

supportLibVersion = '26.0.0'
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 03 13:36:54 WIB 2017
#Tue Feb 26 10:53:58 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
13 changes: 10 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.novoda.bintray-release'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion 16
Expand All @@ -12,7 +13,9 @@ android {
}

dependencies {
compile "com.android.support:appcompat-v7:$supportLibVersion"
implementation "androidx.appcompat:appcompat:$supportLibVersion"
implementation "androidx.annotation:annotation:1.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

publish {
Expand All @@ -23,4 +26,8 @@ publish {
publishVersion = rootProject.publishVersion
description = rootProject.description
licences = rootProject.licences
}
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.yarolegovich.slidingrootnav

import androidx.customview.widget.ViewDragHelper

/**
* Created by yarolegovich on 25.03.2017.
* Edited by Mehdi on 27.02.2019
*/

enum class SlideGravity {

LEFT {
override fun createHelper(): Helper {
return LeftHelper()
}
},
RIGHT {
override fun createHelper(): Helper {
return RightHelper()
}
};

internal abstract fun createHelper(): Helper

internal interface Helper {

fun getLeftAfterFling(flingVelocity: Float, maxDrag: Int): Int

fun getLeftToSettle(dragProgress: Float, maxDrag: Int): Int

fun getRootLeft(dragProgress: Float, maxDrag: Int): Int

fun getDragProgress(viewLeft: Int, maxDrag: Int): Float

fun clampViewPosition(left: Int, maxDrag: Int): Int

fun enableEdgeTrackingOn(dragHelper: ViewDragHelper)
}

internal class LeftHelper : Helper {

override fun getLeftAfterFling(flingVelocity: Float, maxDrag: Int): Int {
return if (flingVelocity > 0) maxDrag else 0
}

override fun getLeftToSettle(dragProgress: Float, maxDrag: Int): Int {
return if (dragProgress > 0.5f) maxDrag else 0
}

override fun getRootLeft(dragProgress: Float, maxDrag: Int): Int {
return (dragProgress * maxDrag).toInt()
}

override fun getDragProgress(viewLeft: Int, maxDrag: Int): Float {
return viewLeft.toFloat() / maxDrag
}

override fun clampViewPosition(left: Int, maxDrag: Int): Int {
return Math.max(0, Math.min(left, maxDrag))
}

override fun enableEdgeTrackingOn(dragHelper: ViewDragHelper) {
dragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT)
}
}

internal class RightHelper : Helper {

override fun getLeftAfterFling(flingVelocity: Float, maxDrag: Int): Int {
return if (flingVelocity > 0) 0 else -maxDrag
}

override fun getLeftToSettle(dragProgress: Float, maxDrag: Int): Int {
return if (dragProgress > 0.5f) -maxDrag else 0
}

override fun getRootLeft(dragProgress: Float, maxDrag: Int): Int {
return (-(dragProgress * maxDrag)).toInt()
}

override fun getDragProgress(viewLeft: Int, maxDrag: Int): Float {
return Math.abs(viewLeft).toFloat() / maxDrag
}

override fun clampViewPosition(left: Int, maxDrag: Int): Int {
return Math.max(-maxDrag, Math.min(left, 0))
}

override fun enableEdgeTrackingOn(dragHelper: ViewDragHelper) {
dragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT)
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.yarolegovich.slidingrootnav

/**
* Created by yarolegovich on 25.03.2017.
* Edited by Mehdi on 27.02.2019
*/

interface SlidingRootNav {

val isMenuClosed: Boolean

val isMenuOpened: Boolean

var isMenuLocked: Boolean

val layout: SlidingRootNavLayout

fun closeMenu()

fun closeMenu(animated: Boolean)

fun openMenu()

fun openMenu(animated: Boolean)

}
Loading