Skip to content

Commit d313aa4

Browse files
authored
Merge pull request #1 from Commit451/kt
Conversion to Kotlin
2 parents 5d1cec5 + 1b3ece3 commit d313aa4

File tree

11 files changed

+1561
-1610
lines changed

11 files changed

+1561
-1610
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ jdk:
55

66
before_install:
77
- mkdir "$ANDROID_HOME/licenses" || true
8-
- echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
8+
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
99

1010
script: "./gradlew build"

app/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android-extensions'
3+
apply plugin: 'kotlin-android'
24

35
android {
4-
compileSdkVersion 28
6+
compileSdkVersion 29
57

68
defaultConfig {
79
applicationId "com.commit451.betterviewdraghelper.sample"
810
minSdkVersion 14
9-
targetSdkVersion 28
11+
targetSdkVersion 29
1012
versionCode 1
1113
versionName "1.0"
1214
}
@@ -22,6 +24,7 @@ android {
2224
}
2325

2426
dependencies {
25-
implementation 'androidx.appcompat:appcompat:1.0.0'
27+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28+
implementation 'androidx.appcompat:appcompat:1.1.0'
2629
implementation project(':translationviewdraghelper')
2730
}

app/src/main/java/com/commit451/betterviewdraghelper/sample/AllowsForDragFrameLayout.java

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.commit451.betterviewdraghelper.sample
2+
3+
import android.annotation.TargetApi
4+
import android.content.Context
5+
import android.util.AttributeSet
6+
import android.view.MotionEvent
7+
import android.view.View
8+
import android.widget.FrameLayout
9+
10+
import com.commit451.translationviewdraghelper.TranslationViewDragHelper
11+
12+
/**
13+
* FrameLayout that allows dragging its inner views around
14+
*/
15+
class AllowsForDragFrameLayout : FrameLayout {
16+
17+
private var viewDragHelper: TranslationViewDragHelper
18+
19+
private var callback: TranslationViewDragHelper.Callback = object : TranslationViewDragHelper.Callback() {
20+
override fun tryCaptureView(child: View, pointerId: Int): Boolean {
21+
//Any children can be captured
22+
return true
23+
}
24+
25+
override fun clampViewPositionHorizontal(child: View, left: Int, dx: Int): Int {
26+
//allow full movement along horizontal axis
27+
return left
28+
}
29+
30+
override fun clampViewPositionVertical(child: View, top: Int, dy: Int): Int {
31+
//allow full movement along vertical axis
32+
return top
33+
}
34+
}
35+
36+
constructor(context: Context) : super(context)
37+
38+
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
39+
40+
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
41+
42+
@TargetApi(21)
43+
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
44+
45+
init {
46+
viewDragHelper = TranslationViewDragHelper.create(this, 1.0f, callback)
47+
}
48+
49+
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
50+
return viewDragHelper.shouldInterceptTouchEvent(ev)
51+
}
52+
53+
override fun onTouchEvent(event: MotionEvent): Boolean {
54+
viewDragHelper.processTouchEvent(event)
55+
return true
56+
}
57+
}

app/src/main/java/com/commit451/betterviewdraghelper/sample/MainActivity.java

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.commit451.betterviewdraghelper.sample
2+
3+
import android.os.Bundle
4+
5+
import androidx.appcompat.app.AppCompatActivity
6+
7+
class MainActivity : AppCompatActivity() {
8+
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
setContentView(R.layout.activity_main)
12+
}
13+
}

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
buildscript {
2+
ext.kotlin_version = '1.3.50'
23
repositories {
34
google()
45
jcenter()
56
}
67
dependencies {
7-
classpath 'com.android.tools.build:gradle:3.2.1'
8+
classpath 'com.android.tools.build:gradle:3.5.1'
9+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
810
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
911
}
1012
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Oct 30 11:13:29 CDT 2018
1+
#Tue Oct 08 00:16:41 CDT 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

translationviewdraghelper/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android-extensions'
3+
apply plugin: 'kotlin-android'
24

35
android {
4-
compileSdkVersion 28
6+
compileSdkVersion 29
57

68
defaultConfig {
79
minSdkVersion 14
8-
targetSdkVersion 28
10+
targetSdkVersion 29
911
versionCode 1
1012
versionName "1.0"
1113
}
@@ -21,7 +23,8 @@ android {
2123
}
2224

2325
dependencies {
24-
api 'androidx.core:core:1.0.0'
26+
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
27+
api 'androidx.core:core:1.1.0'
2528
}
2629

2730
apply from: 'https://raw.githubusercontent.com/Commit451/gradle-android-javadocs/1.0.0/gradle-android-javadocs.gradle'

0 commit comments

Comments
 (0)