Skip to content

Commit

Permalink
Merge pull request #1 from Commit451/kt
Browse files Browse the repository at this point in the history
Conversion to Kotlin
  • Loading branch information
Jawnnypoo authored Oct 8, 2019
2 parents 5d1cec5 + 1b3ece3 commit d313aa4
Show file tree
Hide file tree
Showing 11 changed files with 1,561 additions and 1,610 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ jdk:

before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"

script: "./gradlew build"
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "com.commit451.betterviewdraghelper.sample"
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -22,6 +24,7 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation project(':translationviewdraghelper')
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.commit451.betterviewdraghelper.sample

import android.annotation.TargetApi
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.widget.FrameLayout

import com.commit451.translationviewdraghelper.TranslationViewDragHelper

/**
* FrameLayout that allows dragging its inner views around
*/
class AllowsForDragFrameLayout : FrameLayout {

private var viewDragHelper: TranslationViewDragHelper

private var callback: TranslationViewDragHelper.Callback = object : TranslationViewDragHelper.Callback() {
override fun tryCaptureView(child: View, pointerId: Int): Boolean {
//Any children can be captured
return true
}

override fun clampViewPositionHorizontal(child: View, left: Int, dx: Int): Int {
//allow full movement along horizontal axis
return left
}

override fun clampViewPositionVertical(child: View, top: Int, dy: Int): Int {
//allow full movement along vertical axis
return top
}
}

constructor(context: Context) : super(context)

constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

@TargetApi(21)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)

init {
viewDragHelper = TranslationViewDragHelper.create(this, 1.0f, callback)
}

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
return viewDragHelper.shouldInterceptTouchEvent(ev)
}

override fun onTouchEvent(event: MotionEvent): Boolean {
viewDragHelper.processTouchEvent(event)
return true
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.commit451.betterviewdraghelper.sample

import android.os.Bundle

import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
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 @@
#Tue Oct 30 11:13:29 CDT 2018
#Tue Oct 08 00:16:41 CDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
9 changes: 6 additions & 3 deletions translationviewdraghelper/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -21,7 +23,8 @@ android {
}

dependencies {
api 'androidx.core:core:1.0.0'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api 'androidx.core:core:1.1.0'
}

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

0 comments on commit d313aa4

Please sign in to comment.